/* Dark theme overrides are applied only when html[data-theme="dark"] is set.
   Light theme remains unchanged by default. */

html[data-theme='dark'] {
  color-scheme: dark;
  background-color: #0f172a; /* slate-900 */
}

html[data-theme='dark'] body {
  background-color: #0f172a !important;
  color: #e2e8f0 !important; /* slate-200 */
}

/* Links */
html[data-theme='dark'] a { color: #93c5fd; }
html[data-theme='dark'] a:hover, html[data-theme='dark'] a:focus { color: #bfdbfe; }

/* Generic containers */
html[data-theme='dark'] .container,
html[data-theme='dark'] .main-content { color: #e5e7eb; }

/* Cards, modals, dropdowns */
html[data-theme='dark'] .card,
html[data-theme='dark'] .modal-content,
html[data-theme='dark'] .offcanvas,
html[data-theme='dark'] .list-group-item,
html[data-theme='dark'] .dropdown-menu,
html[data-theme='dark'] .popover,
html[data-theme='dark'] .toast {
  background-color: #111827; /* gray-900 */
  color: #e5e7eb;
  border-color: #374151; /* gray-700 */
}

/* Generic light backgrounds used in templates */
html[data-theme='dark'] .bg-white,
html[data-theme='dark'] .bg-light,
html[data-theme='dark'] .navbar-light,
html[data-theme='dark'] .dropdown-menu,
html[data-theme='dark'] .offcanvas,
html[data-theme='dark'] .toast,
html[data-theme='dark'] .list-group-item {
  background-color: #111827 !important;
  color: #e5e7eb !important;
  border-color: #374151 !important;
}

/* Common custom containers in our templates */
html[data-theme='dark'] .left-section,
html[data-theme='dark'] .right-section,
html[data-theme='dark'] .side-menu,
html[data-theme='dark'] .user-card,
html[data-theme='dark'] .feature-card,
html[data-theme='dark'] .app-card,
html[data-theme='dark'] .integration-card,
html[data-theme='dark'] .feature-box,
html[data-theme='dark'] .product-card,
html[data-theme='dark'] .product-header {
  background-color: #111827 !important;
  color: #e5e7eb !important;
  border-color: #374151 !important;
}

html[data-theme='dark'] .dropdown-item { color: #e5e7eb; }
html[data-theme='dark'] .dropdown-item:hover,
html[data-theme='dark'] .dropdown-item:focus { background-color: #1f2937; color: #ffffff; }

/* Card headers/footers and titles */
html[data-theme='dark'] .card-header,
html[data-theme='dark'] .card-footer { background-color: #0b1220; border-color: #374151; color: #e5e7eb; }
html[data-theme='dark'] .card-title, 
html[data-theme='dark'] .card-subtitle { color: #f3f4f6; }
html[data-theme='dark'] .text-muted { color: #9ca3af !important; }
html[data-theme='dark'] .text-secondary { color: #cbd5e1 !important; }
html[data-theme='dark'] .text-body { color: #e5e7eb !important; }

/* Headings and section titles used in templates */
html[data-theme='dark'] h1,
html[data-theme='dark'] h2,
html[data-theme='dark'] h3,
html[data-theme='dark'] h4,
html[data-theme='dark'] h5,
html[data-theme='dark'] h6,
html[data-theme='dark'] .section-title { color: #e5e7eb !important; }

/* Tables */
html[data-theme='dark'] .table { color: #e5e7eb; }
html[data-theme='dark'] .table thead { background-color: #0b1220; color: #f3f4f6; }
html[data-theme='dark'] .table tbody tr { border-color: #374151; }
html[data-theme='dark'] .table-striped > tbody > tr:nth-of-type(odd) { --bs-table-accent-bg: #0b1220; color: #e5e7eb; }

/* Alerts */
html[data-theme='dark'] .alert { color: #e5e7eb; border-color: #374151; }
html[data-theme='dark'] .alert-primary { background-color: #1d314f; }
html[data-theme='dark'] .alert-secondary { background-color: #1f2937; }
html[data-theme='dark'] .alert-success { background-color: #123524; }
html[data-theme='dark'] .alert-danger { background-color: #3a0d0d; }
html[data-theme='dark'] .alert-warning { background-color: #3a2a0d; color: #fde68a; }
html[data-theme='dark'] .alert-info { background-color: #0e364a; }

/* Badges and pills */
html[data-theme='dark'] .badge { color: #111827; }
/* Ensure solid badge variants remain readable on dark surfaces */
html[data-theme='dark'] .badge.bg-light { color: #111827 !important; }
html[data-theme='dark'] .badge.bg-secondary,
html[data-theme='dark'] .badge.bg-dark { color: #f3f4f6 !important; }
html[data-theme='dark'] .badge.bg-warning { color: #111827 !important; }

/* Breadcrumbs */
html[data-theme='dark'] .breadcrumb { background-color: transparent; }
html[data-theme='dark'] .breadcrumb .breadcrumb-item, 
html[data-theme='dark'] .breadcrumb .breadcrumb-item a { color: #cbd5e1; }

/* Forms: keep inputs, textareas, editors LIGHT in dark mode */
html[data-theme='dark'] input,
html[data-theme='dark'] textarea,
html[data-theme='dark'] select,
html[data-theme='dark'] .form-control,
html[data-theme='dark'] .form-select,
html[data-theme='dark'] .form-check-input {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da !important;
}
html[data-theme='dark'] .form-control::placeholder { color: #6c757d; }

/* Ensure checkbox/radio ticks are visible in dark theme */
html[data-theme='dark'] .form-check-input {
  background-color: #ffffff !important;
  border-color: #9ca3af !important;
}
html[data-theme='dark'] .form-check-input:checked {
  background-color: #0d6efd !important; /* Bootstrap primary */
  border-color: #0d6efd !important;
}
html[data-theme='dark'] .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.25) !important;
}

/* Common rich-text editors */
html[data-theme='dark'] .tox,
html[data-theme='dark'] .tox .tox-edit-area__iframe,
html[data-theme='dark'] .tox .tox-edit-area,
html[data-theme='dark'] .ql-container,
html[data-theme='dark'] .ql-editor,
html[data-theme='dark'] .ck-editor__editable,
html[data-theme='dark'] .ProseMirror {
  background-color: #ffffff !important;
  color: #212529 !important;
}

/* Simple navbar (pricing page) dark adaptation */
html[data-theme='dark'] .navbar-simple { background: rgba(17, 24, 39, 0.95); box-shadow: 0 2px 10px rgba(0,0,0,.5); }
html[data-theme='dark'] .navbar-simple .logo { color: #e5e7eb; }
html[data-theme='dark'] .navbar-simple .btn-light { background-color: #e5e7eb; color: #111827; border-color: #e5e7eb; }
html[data-theme='dark'] .navbar-simple .btn-outline-light { color: #e5e7eb; border-color: #9ca3af; }

/* Pricing/product cards colors */
html[data-theme='dark'] .product-card { background-color: #111827; border-color: #374151; }
html[data-theme='dark'] .product-header { background-color: #0b1220; border-bottom-color: #374151; }
html[data-theme='dark'] .product-name { color: #f3f4f6; }
html[data-theme='dark'] .product-description { color: #cbd5e1; }
html[data-theme='dark'] .price-display { color: #f3f4f6; }

/* AI Shop Plans page (market_subscriptions) */
html[data-theme='dark'] .plan-features {
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%) !important; /* elegant darker block */
  color: #e5e7eb !important;
  border: 1px solid #1f2937 !important; /* refined border */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 1px 2px rgba(0,0,0,0.3) !important;
}
html[data-theme='dark'] .plan-features h6 {
  color: #cbd5e1 !important;
  border-bottom-color: #374151 !important;
}
html[data-theme='dark'] .plan-features li:hover:not(.feature-disabled) {
  background: rgba(59, 130, 246, 0.06) !important;
}
html[data-theme='dark'] .plan-features .text-muted { color: #9ca3af !important; }
/* Quota highlight color in dark mode */
html[data-theme='dark'] .quota-highlight { color: #93c5fd !important; }
/* Use white brace image in dark theme */
html[data-theme='dark'] .ai-credit-row .brace-right::before {
  background: url('/media/images/bracewhite.png') center/contain no-repeat !important;
}

/* Accordion (Report Templates page) */
html[data-theme='dark'] .accordion-item { background-color: #111827 !important; border-color: #374151 !important; }
html[data-theme='dark'] .accordion-button { background-color: #0b1220 !important; color: #e5e7eb !important; }
html[data-theme='dark'] .accordion-button:not(.collapsed) { color: #f3f4f6 !important; background-color: #0b1220 !important; box-shadow: inset 0 -1px 0 #374151 !important; }
html[data-theme='dark'] .accordion-button::after { filter: invert(1) brightness(1.2); }
/* Custom accordion-like rows in reporttemplates/home.html */
html[data-theme='dark'] .modality-header { background-color: #0b1220 !important; color: #e5e7eb !important; }
html[data-theme='dark'] .modality-header:hover { background-color: #111827 !important; }
html[data-theme='dark'] .body-part-header { background-color: #111827 !important; color: #e5e7eb !important; border-left-color: #3b82f6 !important; }
html[data-theme='dark'] .body-part-header:hover { background-color: #0b1220 !important; }
html[data-theme='dark'] .template-item { background-color: #0b1220 !important; color: #e5e7eb !important; }
html[data-theme='dark'] .template-item:hover { background-color: #111827 !important; }
html[data-theme='dark'] .list-group-item { border-bottom-color: #374151 !important; }

/* Structured Reports: TIRADS form specific fixes for contrast */
html[data-theme='dark'] .nodule-section {
  background-color: #0b1220 !important; /* darker panel */
  color: #e5e7eb !important;            /* light text */
  border: 1px solid #374151 !important; /* clear border */
}
html[data-theme='dark'] .nodule-section label {
  color: #e5e7eb !important;
}
html[data-theme='dark'] .nodule-section .input-group-text {
  background-color: #ffffff !important;
  color: #111827 !important;
  border-color: #ced4da !important;
  height: calc(1.5em + .5rem + 2px) !important; /* match .form-control-sm */
  padding: .25rem .5rem !important;
  font-size: .875rem !important;
}
html[data-theme='dark'] .tirads-score { color: #60a5fa !important; } /* brighter blue */

/* HR, borders */
html[data-theme='dark'] hr, html[data-theme='dark'] .border, html[data-theme='dark'] .border-top, html[data-theme='dark'] .border-bottom { border-color: #374151 !important; }

/* Labels */
html[data-theme='dark'] .form-check-label, html[data-theme='dark'] label { color: #e5e7eb; }

/* Bootstrap text colors for contrast */
/* Prevent Bootstrap utility classes from forcing low-contrast text */
html[data-theme='dark'] .text-dark { color: #e5e7eb !important; }
html[data-theme='dark'] .text-black { color: #e5e7eb !important; }
html[data-theme='dark'] .text-white { color: #f3f4f6 !important; }
html[data-theme='dark'] .bg-white .text-white,
html[data-theme='dark'] .bg-light .text-white { color: #111827 !important; }
html[data-theme='dark'] .text-muted { color: #9ca3af !important; }

/* Footer adjustments */
html[data-theme='dark'] .footer-custom { background: linear-gradient(135deg, #0b1220 0%, #0b1220 100%); color: #e5e7eb; }
html[data-theme='dark'] .footer-custom a { color: #cbd5e1; }
html[data-theme='dark'] .footer-custom a:hover { color: #93c5fd; }
html[data-theme='dark'] .footer-custom .footer-bottom { background: rgba(255,255,255,0.06); }

/* Buttons: maintain default, but ensure outline variants have visible text */
html[data-theme='dark'] .btn-outline-light { color: #e5e7eb !important; border-color: #e5e7eb !important; }
html[data-theme='dark'] .btn-outline-dark { color: #e5e7eb !important; border-color: #9ca3af !important; }

/* Buttons generally keep Bootstrap defaults; ensure outline variants have contrast */
html[data-theme='dark'] .btn-outline-secondary { color: #e5e7eb; border-color: #9ca3af; }

/* iRadSpeech page specific: keep credit indicator light, editors light; darken surrounding regions */
html[data-theme='dark'] .credits-display,
html[data-theme='dark'] .credit-counter {
  background-color: #111827 !important;
  color: #e5e7eb !important;
  border-color: #374151 !important;
}
html[data-theme='dark'] .transcription-text,
html[data-theme='dark'] #generatedReportText,
html[data-theme='dark'] #fullscreenTextarea { 
  background-color: #f3f4f6 !important; /* light gray for better comfort */
  color: #111827 !important; 
}
/* Surrounding panels dark (actual classes on the page) */
html[data-theme='dark'] .speech-container,
html[data-theme='dark'] .simple-header,
html[data-theme='dark'] .three-column-layout,
html[data-theme='dark'] .left-sidebar,
html[data-theme='dark'] .center-section,
html[data-theme='dark'] .right-section,
html[data-theme='dark'] .mic-controls-center,
html[data-theme='dark'] .fullscreen-container,
html[data-theme='dark'] .fullscreen-header,
html[data-theme='dark'] .fullscreen-mic-controls,
html[data-theme='dark'] .title-section {
  background-color: #0b1220 !important;
  color: #e5e7eb !important;
}

/* Keep specific light areas */
html[data-theme='dark'] .preview-area { background-color: #ffffff !important; color: #111827 !important; border-color: #e5e7eb !important; }

/* iRadSpeech left panel: dark cards and rows, but keep search light */
html[data-theme='dark'] .tree-view { background-color: #0b1220 !important; border-color: #374151 !important; }
html[data-theme='dark'] .sidebar-template-navigation .accordion-button { 
  background-color: #111827 !important; 
  color: #e5e7eb !important; 
  border-color: #374151 !important;
}
html[data-theme='dark'] .sidebar-template-navigation .accordion-button:not(.collapsed) { 
  background-color: #0b1220 !important; 
  color: #f3f4f6 !important; 
  border-color: #3b82f6 !important; 
}
html[data-theme='dark'] .sidebar-template-navigation .accordion-flush .accordion-button { 
  background-color: #0b1220 !important; 
  color: #e5e7eb !important; 
}
html[data-theme='dark'] .sidebar-template-navigation .list-group-item { 
  background-color: #0b1220 !important; 
  color: #e5e7eb !important; 
}
html[data-theme='dark'] .sidebar-template-navigation .list-group-item:hover { 
  background-color: #111827 !important; 
}
/* Keep search input and results light */
html[data-theme='dark'] .sidebar-template-navigation .form-control-sm,
html[data-theme='dark'] .sidebar-template-navigation .input-group-text,
html[data-theme='dark'] #sidebarTemplateResults { 
  background-color: #ffffff !important; 
  color: #111827 !important; 
  border-color: #e5e7eb !important; 
}

/* Softer layout separators in iRadSpeech */
html[data-theme='dark'] .left-sidebar,
html[data-theme='dark'] .center-section,
html[data-theme='dark'] .right-section { border-right-color: transparent !important; border-left-color: transparent !important; box-shadow: none !important; }
html[data-theme='dark'] .simple-header { border-bottom-color: transparent !important; }


/* Quota exceeded modal (iRadSpeech, Reports):
   The modal content uses a white background even in dark theme.
   Keep the title and message dark for proper contrast. */
html[data-theme='dark'] #quota-modal-title { color: #1F2937 !important; }
html[data-theme='dark'] #quota-modal-message { color: #6B7280 !important; }

/* Report Generator (report_generator_g/index.html) dark theme fixes */
html[data-theme='dark'] .template-info h5 { color: #e5e7eb !important; }
html[data-theme='dark'] .template-info p { color: #cbd5e1 !important; }
html[data-theme='dark'] .template-info em { color: #e5e7eb !important; background-color: rgba(255,255,255,0.06) !important; border-left-color: #3b82f6 !important; }
html[data-theme='dark'] #instructionsCollapse { color: #cbd5e1 !important; }
html[data-theme='dark'] .credits-display-simple { color: #e5e7eb !important; background: #0b1220 !important; border: 1px solid #1f2937 !important; border-radius: 8px; padding: 6px 10px; display: inline-block; }
html[data-theme='dark'] #reportsUsed, 
html[data-theme='dark'] #reportsTotal { color: #f3f4f6 !important; }
html[data-theme='dark'] .template-info .bi-chevron-down { color: #e5e7eb !important; }

