/* ═══════════════════════════════════════════════════════
   MD → DOCX Converter — SOTA Design System
   ═══════════════════════════════════════════════════════ */

/* ─── Reset & Custom Properties ─── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Core palette — Dark (default): warm charcoal, not pure black */
  --bg-primary: #1a1b23;
  --bg-secondary: #1f2029;
  --bg-tertiary: #262730;
  --bg-surface: #2c2d38;
  --bg-surface-hover: #343541;
  --bg-elevated: #3b3c4a;

  /* Text */
  --text-primary: #e8e9ed;
  --text-secondary: #9d9fac;
  --text-tertiary: #6e7082;
  --text-muted: #4e5062;

  /* Accent — electric blue/purple gradient */
  --accent-primary: #7c6cf0;
  --accent-secondary: #a29bfe;
  --accent-bright: #918cf8;
  --accent-glow: rgba(124, 108, 240, 0.2);
  --accent-gradient: linear-gradient(135deg, #7c6cf0 0%, #918cf8 50%, #a78bfa 100%);

  /* Status */
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-default: rgba(255, 255, 255, 0.11);
  --border-hover: rgba(255, 255, 255, 0.18);
  --border-accent: rgba(124, 108, 240, 0.4);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(124, 108, 240, 0.12);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Orb colors (for ambient bg) */
  --orb-1: #7c6cf0;
  --orb-2: #918cf8;
  --orb-3: #a78bfa;
}

/* ─── Light Theme ─── */
[data-theme="light"] {
  --bg-primary: #dfe2ec;
  --bg-secondary: #e8eaf4;
  --bg-tertiary: #d6d9e5;
  --bg-surface: #d0d3e0;
  --bg-surface-hover: #c7cad9;
  --bg-elevated: #bec2d2;

  --text-primary: #1e2035;
  --text-secondary: #3f4360;
  --text-tertiary: #5f6380;
  --text-muted: #8b8fa5;

  --accent-primary: #6355d8;
  --accent-secondary: #7c6cf0;
  --accent-bright: #8b7ff5;
  --accent-glow: rgba(99, 85, 216, 0.18);
  --accent-gradient: linear-gradient(135deg, #6355d8 0%, #8b7ff5 50%, #a594ff 100%);

  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-default: rgba(0, 0, 0, 0.13);
  --border-hover: rgba(0, 0, 0, 0.22);
  --border-accent: rgba(99, 85, 216, 0.4);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --shadow-glow: 0 0 30px rgba(99, 85, 216, 0.14);

  --orb-1: rgba(99, 85, 216, 0.1);
  --orb-2: rgba(124, 108, 240, 0.08);
  --orb-3: rgba(155, 143, 245, 0.06);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-smooth), color var(--transition-smooth);
}

/* ─── Ambient Background ─── */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float 25s ease-in-out infinite;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--orb-1) 0%, transparent 70%);
  top: -10%;
  left: -5%;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--orb-2) 0%, transparent 70%);
  top: 50%;
  right: -10%;
  animation-delay: -8s;
}

.orb-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--orb-3) 0%, transparent 70%);
  bottom: -10%;
  left: 30%;
  animation-delay: -16s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(30px, -40px) scale(1.1);
  }

  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }

  75% {
    transform: translate(40px, 30px) scale(1.05);
  }
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  background: rgba(26, 27, 35, 0.7);
  position: sticky;
  top: 0;
  z-index: 100;
}

[data-theme="light"] .header {
  background: rgba(223, 226, 236, 0.8);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ─── Theme Toggle Button ─── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-default);
}

.theme-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  transition: var(--transition-default);
}

/* In dark mode (default): show sun icon, hide moon */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }

/* In light mode: show moon icon, hide sun */
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ─── Main Layout ─── */
.main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  height: calc(100vh - 73px);
}

/* ─── Panel Shared ─── */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(31, 32, 41, 0.75);
  backdrop-filter: blur(10px);
  height: 48px;
  flex-shrink: 0;
}

[data-theme="light"] .panel-header {
  background: rgba(232, 234, 244, 0.8);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.panel-title svg {
  color: var(--accent-secondary);
}

.panel-actions {
  display: flex;
  gap: 4px;
}

/* ─── Editor Panel ─── */
.editor-panel {
  border-right: 1px solid var(--border-subtle);
  position: relative;
}

.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#editor {
  width: 100%;
  height: 100%;
}

#editor .CodeMirror {
  height: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
}

#editor .CodeMirror-gutters {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  color: var(--text-muted);
}

#editor .CodeMirror-linenumber {
  color: var(--text-muted);
}

#editor .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] #editor .CodeMirror-activeline-background {
  background: rgba(0, 0, 0, 0.03);
}

#editor .CodeMirror-selected {
  background: rgba(108, 92, 231, 0.25);
}

#editor .CodeMirror-cursor {
  border-left: 1px solid var(--accent);
}

#editor .CodeMirror-code {
  padding: 20px 0;
}

#editor .CodeMirror-scroll {
  padding-left: 24px;
  padding-right: 24px;
}

/* Drop overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 27, 35, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-default);
  z-index: 10;
}

[data-theme="light"] .drop-overlay {
  background: rgba(223, 226, 236, 0.94);
}

.drop-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drop-content {
  text-align: center;
  color: var(--accent-secondary);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.drop-content svg {
  margin-bottom: 12px;
}

.drop-content p {
  font-size: 1rem;
  font-weight: 500;
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* ─── Settings Panel ─── */
.settings-panel {
  background: var(--bg-secondary);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.settings-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

/* ─── Theme Grid ─── */
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-card {
  position: relative;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  transition: var(--transition-default);
  overflow: hidden;
}

.theme-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
  transform: translateY(-1px);
}

.theme-card.active {
  border-color: var(--accent-primary);
  background: rgba(108, 92, 231, 0.08);
  box-shadow: 0 0 0 1px var(--accent-primary), var(--shadow-glow);
}

[data-theme="light"] .theme-card.active {
  background: rgba(91, 76, 219, 0.06);
  box-shadow: 0 0 0 1.5px var(--accent-primary), var(--shadow-glow);
}

.theme-card.active::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-card.active::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  font-weight: 700;
}

.theme-colors {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .theme-swatch {
  border-color: rgba(0, 0, 0, 0.1);
}

.theme-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.theme-desc {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* ─── Toggle Switch ─── */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.toggle:hover {
  background: var(--bg-surface);
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-elevated);
  border-radius: 10px;
  border: 1px solid var(--border-default);
  transition: var(--transition-default);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: var(--transition-default);
}

.toggle input:checked+.toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle input:checked+.toggle-slider::after {
  transform: translateX(16px);
  background: white;
}

.toggle-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 450;
}

/* ─── Convert Button ─── */
.convert-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.convert-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-default);
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: var(--shadow-glow), var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
  opacity: 0;
  transition: var(--transition-default);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(124, 108, 240, 0.3), var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-convert {
  width: 100%;
  justify-content: center;
}

.btn-text,
.btn-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-text[hidden],
.btn-loader[hidden] {
  display: none;
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ─── Status Message ─── */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  animation: slide-up 0.3s ease-out;
}

.status.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
}

[data-theme="light"] .status.success {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.25);
}

[data-theme="light"] .status.error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
}

.status-icon::before {
  font-size: 1rem;
}

.status.success .status-icon::before {
  content: '✓';
}

.status.error .status-icon::before {
  content: '✕';
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Quick Reference ─── */
.quick-ref {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
}

.quick-ref .panel-header {
  padding: 10px 20px;
}

.ref-code {
  margin: 0 20px 8px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
}

.ref-code code {
  font-family: inherit;
}

.ref-note {
  padding: 0 20px 14px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.ref-note code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  color: var(--accent-secondary);
}

.ref-desc {
  padding: 0 20px 10px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.ref-desc code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  color: var(--accent-secondary);
}

.ref-fields {
  padding: 0 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ref-fields p {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.ref-fields code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.63rem;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  color: var(--accent-bright);
  font-weight: 500;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Panel Credits ─── */
.panel-credits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.2s;
}

.panel-credits:hover {
  opacity: 1;
}

.credits-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.credits-link:hover {
  color: var(--accent);
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
    min-height: calc(100vh - 73px);
  }

  .editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 45vh;
  }

  .settings-panel {
    max-height: 55vh;
  }

  .theme-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .quick-ref {
    display: none;
  }
}

@media (max-width: 500px) {
  .theme-grid {
    grid-template-columns: 1fr 1fr;
  }

  .header {
    padding: 12px 16px;
  }

  .settings-content {
    padding: 14px;
  }
}