/* ═══════════════════════════════════════════════════════
   MailGen Design System — style.css
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── 1. TOKENS ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base: #0D0F14;
  --bg-surface: #13161E;
  --bg-elevated: #1C2030;
  --bg-overlay: #252A3A;

  /* Brand — Departman Altın */
  --accent: #ecc01b;
  --accent-hover: #d4aa15;
  --accent-muted: rgba(236, 192, 27, 0.14);
  --accent-glow: rgba(236, 192, 27, 0.35);

  /* Secondary — Amber */
  --accent-2: #f59e0b;
  --accent-2-muted: rgba(245, 158, 11, 0.12);

  /* Semantic */
  --success: #22D48F;
  --warning: #F5A623;
  --error: #F55B5B;

  /* Text */
  --text-primary: #F0F2FF;
  --text-secondary: #8A90B0;
  --text-muted: #4A5068;
  --text-inverse: #0D0F14;
  /* used on accent bg — dark text readable on gold */

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(236, 192, 27, 0.55);

  /* Typography */
  --font-base: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --text-xs: 0.70rem;
  --text-sm: 0.813rem;
  --text-base: 0.938rem;
  --text-md: 1.063rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.75rem;

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semi: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-base: 1.55;
  --lh-relaxed: 1.75;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 0 24px var(--accent-glow);

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-base: cubic-bezier(0.4, 0, 0.2, 1);

  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 350ms;
  --dur-enter: 450ms;
}

/* ─── 2. RESET ───────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

button {
  font-family: var(--font-base);
  cursor: pointer;
  border: none;
  background: none;
}

input,
textarea,
select {
  font-family: var(--font-base);
}

img,
svg {
  display: block;
}

/* ─── 3. LAYOUT ─────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── 4. SIDEBAR ────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--dur-slow) var(--ease-out);
  overflow: hidden;
}

/* sidebar always open — no collapsed state */

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--text-base);
  color: var(--text-primary);
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--text-md);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-logo-text span {
  color: var(--text-secondary);
  font-weight: var(--fw-regular);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4) var(--space-3);
}

.sidebar-body::-webkit-scrollbar {
  width: 3px;
}

.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) var(--space-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-out);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -var(--space-3);
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transform: translateX(-12px);
}

.nav-item.danger {
  color: var(--error);
}

.nav-item.danger:hover {
  background: rgba(245, 91, 91, 0.1);
  color: var(--error);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  border: 1px solid var(--border-focus);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--accent);
  flex-shrink: 0;
}

/* ─── 5. PAGE HEADER ────────────────────────────────── */
.page-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
  white-space: nowrap;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ─── 6. BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-out);
  border: none;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: var(--text-xs);
}

.btn-md {
  padding: 10px 20px;
  font-size: var(--text-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: var(--text-base);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: #0D0F14;
  /* dark text for contrast on gold */
  box-shadow: var(--shadow-accent);
  font-weight: var(--fw-semi);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-focus);
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
}

.btn-danger:hover {
  background: rgba(245, 91, 91, 0.12);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: var(--text-primary);
}

/* ─── 7. INPUTS ─────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--text-base);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  outline: none;
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.input.error {
  border-color: var(--error);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: var(--lh-relaxed);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-label.required::after {
  content: ' *';
  color: var(--error);
}

.input-error {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: var(--space-1);
}

/* ─── 8. CARDS ──────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--dur-base), transform var(--dur-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ─── 9. BADGES ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
}

.badge-accent {
  background: var(--accent-muted);
  color: var(--accent);
}

.badge-success {
  background: rgba(34, 212, 143, 0.15);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
}

.badge-error {
  background: rgba(245, 91, 91, 0.15);
  color: var(--error);
}

.badge-muted {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.badge-cyan {
  background: var(--accent-2-muted);
  color: var(--accent-2);
}

/* ─── 10. MODAL ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  opacity: 0;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-slow) var(--ease-out);
}

.modal-overlay.open .modal {
  transform: scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-md);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur-fast);
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── 11. DRAWER (Slide Panel) ──────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 41;
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  font-size: var(--text-md);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
}

/* ─── 12. TOAST ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 100;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--text-primary);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in var(--dur-slow) var(--ease-out);
}

.toast.removing {
  animation: toast-out var(--dur-base) var(--ease-in) forwards;
}

.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-success {
  border-color: var(--success);
}

.toast-success svg {
  color: var(--success);
}

.toast-error {
  border-color: var(--error);
}

.toast-error svg {
  color: var(--error);
}

.toast-warning {
  border-color: var(--warning);
}

.toast-warning svg {
  color: var(--warning);
}

.toast-info {
  border-color: var(--accent);
}

.toast-info svg {
  color: var(--accent);
}

/* ─── 13. SKELETON LOADER ───────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -600px 0;
  }

  100% {
    background-position: 600px 0;
  }
}

.skeleton {
  background: linear-gradient(90deg,
      var(--bg-elevated) 25%,
      var(--bg-overlay) 50%,
      var(--bg-elevated) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ─── 13.5 SMART SUGGESTIONS ──────────────────────────── */
.suggestion-container {
  position: relative;
}

.suggestion-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  animation: fadeSlideUp 0.2s var(--ease-out);
}

.suggestion-item {
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-item:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

/* ─── 14. TABS ──────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--dur-fast);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── 15. QUILL DARK OVERRIDES ──────────────────────── */
.ql-toolbar.ql-snow {
  background: var(--bg-surface) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 10px 16px;
}

.ql-toolbar.ql-snow .ql-stroke {
  stroke: var(--text-secondary) !important;
}

.ql-toolbar.ql-snow .ql-fill {
  fill: var(--text-secondary) !important;
}

.ql-toolbar.ql-snow .ql-picker {
  color: var(--text-secondary) !important;
}

.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow .ql-active .ql-stroke {
  stroke: var(--accent) !important;
}

.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow .ql-active .ql-fill {
  fill: var(--accent) !important;
}

.ql-toolbar.ql-snow .ql-picker-options {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
}

.ql-toolbar.ql-snow .ql-picker-item {
  color: var(--text-primary) !important;
}

.ql-container.ql-snow {
  border: none !important;
}

/* Email preview keeps white BG */
.email-preview .ql-editor {
  background: #fff;
  color: #1a1a2e;
  font-family: Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.7;
  padding: 32px 40px;
}

/* Admin editor — dark */
.admin-editor .ql-editor {
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-family: Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.7;
  min-height: 320px;
  padding: 24px 28px;
}

/* ─── 16. ANIMATIONS ─────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(24px);
  }
}

.anim-enter {
  animation: fadeSlideUp var(--dur-enter) var(--ease-out) both;
}

/* Stagger for lists */
.stagger>*:nth-child(1) {
  animation-delay: 0ms;
}

.stagger>*:nth-child(2) {
  animation-delay: 50ms;
}

.stagger>*:nth-child(3) {
  animation-delay: 100ms;
}

.stagger>*:nth-child(4) {
  animation-delay: 150ms;
}

.stagger>*:nth-child(5) {
  animation-delay: 200ms;
}

.stagger>*:nth-child(6) {
  animation-delay: 250ms;
}

.stagger>*:nth-child(n+7) {
  animation-delay: 300ms;
}

/* ─── 17. SCROLLBARS ─────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── 18. FILTER CHIPS ───────────────────────────────── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast);
}

.chip:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0D0F14;
  font-weight: var(--fw-semi);
}

/* ─── 19. AI SUGGESTION CARDS ────────────────────────── */
.suggestion-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: all var(--dur-fast) var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.suggestion-card:hover {
  border-color: var(--accent);
}

.suggestion-card .original {
  color: var(--error);
  text-decoration: line-through;
  font-size: var(--text-sm);
}

.suggestion-card .proposed {
  color: var(--success);
  font-weight: var(--fw-semi);
  font-size: var(--text-md);
}

.suggestion-card .reason {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-overlay);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

.suggestion-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* ─── 20. EMPTY STATE ────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-20);
  gap: var(--space-4);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 320px;
}

/* ─── 20. SPLIT VIEW ─────────────────────────────────── */
.split-view {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.split-left {
  width: 45%;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-right {
  flex: 1;
  background: var(--bg-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sticky-bar {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ─── 21. REDUCED MOTION ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── 22. RESPONSIVE ─────────────────────────────────── */

/* ── Tablet (≤1024px) ── */
@media (max-width: 1024px) {

  /* Sidebar collapses to icon-only strip */
  .sidebar {
    width: 60px;
    overflow: hidden;
    flex-shrink: 0;
  }

  .sidebar-logo-text,
  .nav-item-label,
  .sidebar-section-label,
  .sidebar-footer .user-info,
  #templateList,
  #categoryFilters,
  #templateSearch {
    display: none;
  }

  /* Split view: show form by default, preview togglable */
  .split-left {
    width: 100%;
  }

  .split-right {
    display: none;
  }

  .split-right.tab-active {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 20;
  }

  /* Show tab-switch buttons (defined in HTML) */
  .mobile-tabs {
    display: flex !important;
  }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {

  /* Sidebar becomes a slide-in overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* All sidebar content visible when overlay is open */
  .sidebar.sidebar-open .sidebar-logo-text,
  .sidebar.sidebar-open .nav-item-label,
  .sidebar.sidebar-open .sidebar-section-label,
  .sidebar.sidebar-open #templateList,
  .sidebar.sidebar-open #categoryFilters,
  .sidebar.sidebar-open #templateSearch {
    display: block;
  }


  /* Hamburger toggle button — hidden on desktop */
  .sidebar-toggle-btn {
    display: flex !important;
  }

  /* Main content fills full width when sidebar is hidden */
  .app-shell {
    flex-direction: column;
  }

  .main-view {
    width: 100%;
  }

  /* App header shrinks */
  .app-header {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }

  .app-header .btn {
    padding: 7px 10px;
    font-size: var(--text-xs);
  }

  /* Subject builder → stack inputs */
  .subject-inputs {
    grid-template-columns: 1fr;
  }

  /* Form inner more compact */
  .form-inner {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  /* Preview card padding */
  .email-preview {
    padding: 16px 14px;
  }

  /* Toast → bottom center */
  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: none;
  }

  /* Login page → hide left decorative panel, show form full-width */
  .login-left {
    display: none !important;
  }

  .login-right {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: var(--space-8) var(--space-6) !important;
  }

  /* Welcome page adjustments */
  .hero-title {
    font-size: var(--text-xl) !important;
  }
}

/* ── Small Mobile (≤480px) ── */
@media (max-width: 480px) {

  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-2) var(--space-3);
  }

  #pageTitle {
    font-size: var(--text-sm) !important;
  }

  .btn-sm {
    padding: 5px 8px;
    font-size: 11px;
  }

  .subject-builder {
    padding: var(--space-3);
  }

  .subject-preview-row {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .login-right {
    padding: var(--space-6) var(--space-4) !important;
  }

  .toast-container {
    left: var(--space-2);
    right: var(--space-2);
    bottom: var(--space-2);
  }
}

/* ─── SUBJECT LINE BUILDER ────────────────────────────── */

.subject-builder {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.subject-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-pill {
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
}

.toggle-pill::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur-fast), background var(--dur-fast);
}

.toggle-label input[type="checkbox"]:checked+.toggle-pill {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.toggle-label input[type="checkbox"]:checked+.toggle-pill::after {
  transform: translateX(15px);
  background: var(--accent);
}

.subject-inputs {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: var(--space-2);
}

.subject-preview-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-overlay);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
}

.subject-preview-text {
  flex: 1;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
  transition: color var(--dur-fast);
}

@media (max-width: 640px) {
  .split-view {
    flex-direction: column;
  }
}