[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #080d18;
  --card-bg: #111827;
  --surface-raised: #172033;
  --surface-muted: #0d1525;
  --surface-hover: #1e293b;
  --border-color: #2a3649;
  --line: #2a3649;
  --text-main: #e5edf8;
  --text-muted: #9aa9bd;
  --muted: #9aa9bd;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-mid: #60a5fa;
  --primary-soft: #172b4d;
  --primary-rgb: 59, 130, 246;
  --navy: #60a5fa;
  --secondary-soft: #332b08;
  --sidebar-muted: #cbd5e1;
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-elevated: 0 18px 46px rgba(0, 0, 0, 0.52);

  --bs-body-color: var(--text-main);
  --bs-body-color-rgb: 229, 237, 248;
  --bs-body-bg: var(--bg-main);
  --bs-body-bg-rgb: 8, 13, 24;
  --bs-secondary-color: var(--text-muted);
  --bs-secondary-bg: var(--surface-raised);
  --bs-tertiary-color: var(--text-muted);
  --bs-tertiary-bg: var(--surface-muted);
  --bs-emphasis-color: #ffffff;
  --bs-emphasis-color-rgb: 255, 255, 255;
  --bs-border-color: var(--border-color);
  --bs-border-color-translucent: rgba(148, 163, 184, 0.2);
  --bs-link-color: #60a5fa;
  --bs-link-hover-color: #93c5fd;
  --bs-heading-color: var(--text-main);
  --bs-form-valid-color: #34d399;
  --bs-form-invalid-color: #fb7185;
}

[data-theme="dark"] body,
[data-theme="dark"] .app-main,
[data-theme="dark"] .app-content,
[data-theme="dark"] .view-section {
  background-color: var(--bg-main);
  color: var(--text-main);
}

[data-theme="dark"] .app-header,
[data-theme="dark"] .custom-card,
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .offcanvas,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .user-dropdown,
[data-theme="dark"] .toast,
[data-theme="dark"] .popover,
[data-theme="dark"] .list-group-item,
[data-theme="dark"] .accordion-item,
[data-theme="dark"] .connection-card,
[data-theme="dark"] .provider-card,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .board .card,
[data-theme="dark"] form.modal.small-modal {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item,
[data-theme="dark"] .user-dropdown-item,
[data-theme="dark"] .modal-title,
[data-theme="dark"] .card-title,
[data-theme="dark"] .page-title,
[data-theme="dark"] .form-label,
[data-theme="dark"] label,
[data-theme="dark"] legend {
  color: var(--text-main);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus,
[data-theme="dark"] .user-dropdown-item:hover,
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
  background: var(--surface-hover);
  color: #fff;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-check-input,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] .form-range,
[data-theme="dark"] textarea,
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
[data-theme="dark"] select {
  background-color: var(--surface-muted);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus {
  background-color: #101a2c;
  color: #fff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
  color: #718096;
  opacity: 1;
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled,
[data-theme="dark"] input:disabled,
[data-theme="dark"] textarea:disabled {
  background-color: #151d2c;
  color: #718096;
  opacity: 1;
}

[data-theme="dark"] .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

[data-theme="dark"] .btn-light,
[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-close,
[data-theme="dark"] form.modal.small-modal .modal-actions button:not(.primary),
[data-theme="dark"] .calendar-controls button,
[data-theme="dark"] .dash-stage-select {
  background-color: var(--surface-raised);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-light:hover,
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] form.modal.small-modal .modal-actions button:not(.primary):hover,
[data-theme="dark"] .calendar-controls button:hover {
  background-color: var(--surface-hover);
  color: #fff;
  border-color: #46546a;
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
}

[data-theme="dark"] .table {
  --bs-table-color: var(--text-main);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border-color);
  --bs-table-striped-color: var(--text-main);
  --bs-table-striped-bg: rgba(148, 163, 184, 0.045);
  --bs-table-hover-color: #fff;
  --bs-table-hover-bg: rgba(59, 130, 246, 0.09);
  color: var(--text-main);
}

[data-theme="dark"] .table-light,
[data-theme="dark"] .table > thead,
[data-theme="dark"] .articles-table thead th {
  --bs-table-bg: var(--surface-raised);
  --bs-table-color: var(--text-main);
  background: var(--surface-raised);
  color: var(--text-main);
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
  border-color: var(--border-color);
}

[data-theme="dark"] .pagination {
  --bs-pagination-color: var(--text-main);
  --bs-pagination-bg: var(--card-bg);
  --bs-pagination-border-color: var(--border-color);
  --bs-pagination-hover-color: #fff;
  --bs-pagination-hover-bg: var(--surface-hover);
  --bs-pagination-hover-border-color: #46546a;
  --bs-pagination-disabled-color: #64748b;
  --bs-pagination-disabled-bg: var(--surface-muted);
  --bs-pagination-disabled-border-color: var(--border-color);
}

[data-theme="dark"] .alert {
  color: var(--text-main);
  border-color: color-mix(in srgb, currentColor 28%, transparent);
}

[data-theme="dark"] .alert-info {
  --bs-alert-bg: #102b3d;
  --bs-alert-color: #bae6fd;
  --bs-alert-border-color: #155e75;
}

[data-theme="dark"] .alert-success {
  --bs-alert-bg: #0d2d24;
  --bs-alert-color: #a7f3d0;
  --bs-alert-border-color: #166534;
}

[data-theme="dark"] .alert-warning {
  --bs-alert-bg: #332609;
  --bs-alert-color: #fde68a;
  --bs-alert-border-color: #854d0e;
}

[data-theme="dark"] .alert-danger {
  --bs-alert-bg: #38151c;
  --bs-alert-color: #fecdd3;
  --bs-alert-border-color: #9f1239;
}

[data-theme="dark"] hr,
[data-theme="dark"] .dropdown-divider,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer {
  border-color: var(--border-color);
}

[data-theme="dark"] .text-dark,
[data-theme="dark"] .articles-title,
[data-theme="dark"] .article-detail-title,
[data-theme="dark"] .article-detail-item strong,
[data-theme="dark"] .article-detail-block h6,
[data-theme="dark"] .wizard-review-section-title,
[data-theme="dark"] .wizard-choice-title,
[data-theme="dark"] .wizard-step-indicator .step-item.done .step-label,
[data-theme="dark"] .wizard-step-indicator .step-item.active .step-label,
[data-theme="dark"] .login-brand h1 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .articles-footer,
[data-theme="dark"] .article-detail-item,
[data-theme="dark"] .article-detail-media-item,
[data-theme="dark"] .article-detail-media-item img,
[data-theme="dark"] .article-detail-pre,
[data-theme="dark"] .article-detail-body,
[data-theme="dark"] .calendar-weekday,
[data-theme="dark"] .calendar-day.other-month,
[data-theme="dark"] .studio-serp-preview,
[data-theme="dark"] .notif-item.unread {
  background: var(--surface-muted) !important;
  color: var(--text-main);
}

[data-theme="dark"] .wizard-step-indicator .step-dot,
[data-theme="dark"] .wizard-choice-card,
[data-theme="dark"] .wizard-choice-radio,
[data-theme="dark"] .jalali-datepicker .form-control,
[data-theme="dark"] .jalali-datepicker-panel,
[data-theme="dark"] .jalali-datepicker-panel button,
[data-theme="dark"] .connection-card,
[data-theme="dark"] form.modal.small-modal textarea {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .wizard-choice-card:hover,
[data-theme="dark"] .wizard-choice-card.is-selected,
[data-theme="dark"] .jalali-datepicker-panel button:hover {
  background: var(--surface-hover);
}

[data-theme="dark"] .calendar-day {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .calendar-day:hover {
  background: var(--surface-hover);
}

[data-theme="dark"] .seo-issue-card.severity-high {
  background: #35151d;
  border-color: #9f1239;
}

[data-theme="dark"] .seo-issue-card.severity-medium {
  background: #332609;
  border-color: #854d0e;
}

[data-theme="dark"] .seo-issue-card.severity-low {
  background: #0d2d24;
  border-color: #166534;
}

[data-theme="dark"] .badge-published,
[data-theme="dark"] .badge-approved,
[data-theme="dark"] .cal-event.published {
  background: #12372d;
  color: #6ee7b7;
  border-color: #166534;
}

[data-theme="dark"] .badge-draft,
[data-theme="dark"] .cal-event.draft {
  background: #253044;
  color: #cbd5e1;
  border-color: #475569;
}

[data-theme="dark"] .badge-generating,
[data-theme="dark"] .cal-event.generating {
  background: #202b59;
  color: #a5b4fc;
  border-color: #4338ca;
}

[data-theme="dark"] .badge-review,
[data-theme="dark"] .cal-event.review {
  background: #3a2b0c;
  color: #fcd34d;
  border-color: #a16207;
}

[data-theme="dark"] .badge-rejected,
[data-theme="dark"] .cal-event.rejected {
  background: #3b1720;
  color: #fda4af;
  border-color: #be123c;
}

[data-theme="dark"] .badge-flow,
[data-theme="dark"] [class*="badge-flow-"] {
  background: #2a2445;
  color: #c4b5fd;
  border-color: #5b4c8f;
}

[data-theme="dark"] .badge-channel-website {
  background: #12372d;
  color: #6ee7b7;
  border-color: #059669;
}

[data-theme="dark"] .badge-channel-instagram {
  background: #43213a;
  color: #f9a8d4;
  border-color: #be185d;
}

[data-theme="dark"] .badge-channel-linkedin {
  background: #123653;
  color: #7dd3fc;
  border-color: #0369a1;
}

[data-theme="dark"] .serp-title {
  color: #8ab4f8;
}

[data-theme="dark"] .login-body {
  background:
    radial-gradient(circle at 20% 15%, rgba(59, 130, 246, 0.16), transparent 34%),
    radial-gradient(circle at 80% 85%, rgba(245, 196, 0, 0.08), transparent 32%),
    var(--bg-main);
}

[data-theme="dark"] .login-card {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-color);
  box-shadow: var(--shadow-elevated);
}

[data-theme="dark"] .login-brand-icon,
[data-theme="dark"] .sidebar-brand .brand-icon-wrap {
  background: #f8fafc;
}

[data-theme="dark"] .swal2-popup,
[data-theme="dark"] .swal2-toast {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-elevated);
}

[data-theme="dark"] .swal2-title,
[data-theme="dark"] .swal2-html-container,
[data-theme="dark"] .swal2-close {
  color: var(--text-main);
}

[data-theme="dark"] .swal2-timer-progress-bar {
  background: var(--primary);
}

[data-theme="dark"] .ck.ck-editor__main > .ck-editor__editable,
[data-theme="dark"] .ck.ck-toolbar,
[data-theme="dark"] .ck.ck-dropdown__panel,
[data-theme="dark"] .ck.ck-list,
[data-theme="dark"] .ck.ck-balloon-panel {
  --ck-color-base-background: var(--card-bg);
  --ck-color-base-foreground: var(--surface-raised);
  --ck-color-base-border: var(--border-color);
  --ck-color-text: var(--text-main);
  --ck-color-toolbar-background: var(--surface-muted);
  --ck-color-button-default-hover-background: var(--surface-hover);
  --ck-color-button-on-background: var(--primary-soft);
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .ck.ck-editor__editable:not(.ck-editor__nested-editable).ck-focused {
  border-color: var(--primary);
}

[data-theme="dark"] ::selection {
  background: rgba(59, 130, 246, 0.42);
  color: #fff;
}

[data-theme="dark"] {
  scrollbar-color: #475569 var(--surface-muted);
}

[data-theme="dark"] .app-sidebar,
[data-theme="dark"] .app-sidebar * {
  scrollbar-color: transparent transparent;
  scrollbar-width: none;
}
