/**
 * Office-Style Rich Text Editor CSS
 * DIGITARA Portal Kompetisi & Olimpiade
 * Styled like Microsoft Office Word Ribbon Toolbar
 */

.office-editor-wrapper {
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 0.5rem;
}

.office-editor-wrapper:focus-within {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Office Ribbon Toolbar Header */
.office-editor-toolbar {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1.5px solid #e2e8f0;
  padding: 0.45rem 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}

.oe-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.35rem;
  border-right: 1px solid #cbd5e1;
}

.oe-toolbar-group:last-child {
  border-right: none;
}

/* Toolbar Buttons */
.oe-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #334155;
  border-radius: 5px;
  width: 32px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.oe-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #cbd5e1;
}

.oe-btn.is-active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Format Dropdown */
.oe-select {
  height: 30px;
  padding: 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  cursor: pointer;
  outline: none;
}

.oe-select:hover {
  border-color: #94a3b8;
}

.oe-select:focus {
  border-color: #0284c7;
}

/* Color Picker Button */
.oe-color-btn {
  position: relative;
  overflow: hidden;
}

.oe-color-btn input[type="color"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Editor Editable Area */
.office-editor-body {
  padding: 1.1rem 1.25rem;
  min-height: 160px;
  max-height: 480px;
  overflow-y: auto;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.95rem;
  line-height: 1.75;
  color: #1e293b;
  outline: none;
  background: #ffffff;
}

.office-editor-body:empty:before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
  display: block;
}

/* HTML Source Code Mode */
.office-editor-source {
  width: 100%;
  height: 100%;
  min-height: 160px;
  padding: 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
  border: none;
  outline: none;
  resize: vertical;
  display: none;
}

/* Typography styles inside editor & public view */
.office-editor-body p,
.rich-content-view p {
  margin: 0 0 0.85rem 0;
}

.office-editor-body p:last-child,
.rich-content-view p:last-child {
  margin-bottom: 0;
}

.office-editor-body h1, .rich-content-view h1 { font-size: 1.6rem; font-weight: 800; margin: 1.2rem 0 0.6rem; color: #0B2545; }
.office-editor-body h2, .rich-content-view h2 { font-size: 1.35rem; font-weight: 800; margin: 1.1rem 0 0.5rem; color: #0B2545; }
.office-editor-body h3, .rich-content-view h3 { font-size: 1.15rem; font-weight: 700; margin: 0.9rem 0 0.4rem; color: #0B2545; }
.office-editor-body h4, .rich-content-view h4 { font-size: 1rem; font-weight: 700; margin: 0.8rem 0 0.35rem; color: #0B2545; }

.office-editor-body ul, .rich-content-view ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin: 0 0 0.85rem 0;
}

.office-editor-body ol, .rich-content-view ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin: 0 0 0.85rem 0;
}

.office-editor-body li, .rich-content-view li {
  margin-bottom: 0.3rem;
}

.office-editor-body blockquote, .rich-content-view blockquote {
  border-left: 4px solid var(--c-primary, #0091B9);
  background: #f1f5f9;
  padding: 0.65rem 1rem;
  margin: 0.85rem 0;
  border-radius: 0 8px 8px 0;
  color: #334155;
  font-style: italic;
}

.office-editor-body a, .rich-content-view a {
  color: var(--c-primary, #0091B9);
  text-decoration: underline;
}

/* Explicit Text Alignments */
.office-editor-body [style*="text-align: justify"],
.rich-content-view [style*="text-align: justify"],
.office-editor-body [align="justify"],
.rich-content-view [align="justify"] {
  text-align: justify !important;
  text-justify: inter-word;
}

.office-editor-body [style*="text-align: center"],
.rich-content-view [style*="text-align: center"],
.office-editor-body [align="center"],
.rich-content-view [align="center"] {
  text-align: center !important;
}

.office-editor-body [style*="text-align: right"],
.rich-content-view [style*="text-align: right"],
.office-editor-body [align="right"],
.rich-content-view [align="right"] {
  text-align: right !important;
}

.office-editor-body [style*="text-align: left"],
.rich-content-view [style*="text-align: left"],
.office-editor-body [align="left"],
.rich-content-view [align="left"] {
  text-align: left !important;
}
