/**
 * Ancient Nutrition Backoffice — Theme System V1
 * Light / Dark / System mode design tokens & overrides
 */

:root {
    /* Semantic Background tokens */
    --bg-primary: #E5F2F7;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    /* Semantic Surface tokens */
    --surface-primary: #ffffff;
    --surface-secondary: #f8fafc;
    --surface-hover: #f1f5f9;

    /* Semantic Typography tokens */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Semantic Border tokens */
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;

    /* Semantic Input tokens */
    --input-background: #ffffff;
    --input-border: #cbd5e1;
    --input-text: #1e293b;
    --input-placeholder: #94a3b8;

    /* Semantic Shadow & Elevation */
    --shadow-color: rgba(15, 23, 42, 0.08);

    /* Brand and Functional Tokens */
    --brand-primary: #31545F;
    --brand-secondary: #274F5C;
    --brand-accent: #4A6974;

    /* Status Colors */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;

    /* Table Tokens */
    --table-header-bg: #f8fafc;
    --table-row-hover: #f1f5f9;
    --table-border: #e2e8f0;
}

/* -------------------------------------------------------------
 * DARK MODE PALETTE (Class-based html.dark)
 * Elegant Charcoal theme with high readability & WCAG AA contrast
 * ------------------------------------------------------------- */
html.dark {
    /* Dark Semantic Background tokens */
    --bg-primary: #0f1720;
    --bg-secondary: #131c26;
    --bg-tertiary: #18222e;

    /* Dark Semantic Surface tokens */
    --surface-primary: #18222e;
    --surface-secondary: #202d3d;
    --surface-hover: #273748;

    /* Dark Semantic Typography tokens */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Dark Semantic Border tokens */
    --border-primary: #273748;
    --border-secondary: #334458;

    /* Dark Semantic Input tokens */
    --input-background: #131c26;
    --input-border: #2e4157;
    --input-text: #f8fafc;
    --input-placeholder: #64748b;

    /* Dark Semantic Shadow */
    --shadow-color: rgba(0, 0, 0, 0.45);

    /* Dark Status Colors */
    --status-success: #34d399;
    --status-warning: #fbbf24;
    --status-danger: #f87171;
    --status-info: #60a5fa;

    /* Dark Table Tokens */
    --table-header-bg: #131c26;
    --table-row-hover: #202d3d;
    --table-border: #273748;
}

/* Global Application Overrides in Dark Mode */
html.dark body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

html.dark main {
    background-color: var(--bg-primary);
}

/* Preserve original brand logo and visual media integrity */
/* Sidebar Brand Section: Always pure white across Light, Dark, and System */
.sidebar-brand-header,
html.dark .sidebar-brand-header,
html.dark #appSidebar .sidebar-brand-header {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-bottom-color: #e2e8f0 !important;
}

.sidebar-brand-header .brand-logo-frame,
html.dark .sidebar-brand-header .brand-logo-frame,
html.dark .brand-logo-frame {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

html.dark .sidebar-brand-header button {
    color: #64748b !important;
    background-color: transparent !important;
}

html.dark .sidebar-brand-header button:hover {
    color: #1e293b !important;
    background-color: #f1f5f9 !important;
}

/* Ensure images, videos, canvas, icons never invert colors */
html.dark img,
html.dark video,
html.dark canvas,
html.dark svg,
html.dark .material-symbols-outlined {
    filter: none !important;
}

/* Cards & Surfaces */
html.dark .bg-white {
    background-color: var(--surface-primary);
    color: var(--text-primary);
}

html.dark .bg-gray-50,
html.dark .bg-slate-50 {
    background-color: var(--surface-secondary);
}

html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-slate-100,
html.dark .border-slate-200 {
    border-color: var(--border-primary);
}

/* Typography Overrides */
html.dark .text-gray-900,
html.dark .text-slate-900 {
    color: var(--text-primary);
}

html.dark .text-gray-800,
html.dark .text-slate-800,
html.dark .text-gray-700,
html.dark .text-slate-700 {
    color: var(--text-secondary);
}

html.dark .text-gray-600,
html.dark .text-gray-500,
html.dark .text-slate-500 {
    color: var(--text-muted);
}

html.dark .text-primary {
    color: #5eead4;
}

html.dark .text-accent {
    color: #94a3b8;
}

/* Inputs, Textareas, Selects */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
html.dark textarea,
html.dark select {
    background-color: var(--input-background);
    border-color: var(--input-border);
    color: var(--input-text);
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--input-placeholder);
}

/* Tables */
html.dark table {
    border-color: var(--table-border);
}

html.dark thead th {
    background-color: var(--table-header-bg);
    color: var(--text-secondary);
    border-color: var(--table-border);
}

html.dark tbody tr {
    background-color: var(--surface-primary);
    border-color: var(--table-border);
}

html.dark tbody tr:hover {
    background-color: var(--table-row-hover);
}

/* Modals & Drawers */
html.dark #orderProductsContent,
html.dark #userActionPanel #panelContent,
html.dark #productPanelContent,
html.dark #productActionPanel #panelContent,
html.dark #confirmModal #confirmContent {
    background-color: var(--surface-primary);
    border-color: var(--border-primary);
    color: var(--text-primary);
}

/* Toasts */
html.dark #toastContainer > div {
    background-color: var(--surface-primary);
    border-color: var(--border-primary);
    color: var(--text-primary);
}

/* =============================================================
 * NOTIFICATION POPOVER — DARK MODE V1.2
 * Harmonious charcoal surfaces with turquoise accents & dark scrollbar
 * ============================================================= */

/* 1. Main popover container & bell trigger */
html.dark #notificationPopover {
    background-color: #18222e !important;
    background: #18222e !important;
    border-color: #273748 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.55), 0 8px 10px -6px rgba(0, 0, 0, 0.55) !important;
}

html.dark #notificationBellBtn {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-secondary) !important;
}
html.dark #notificationBellBtn:hover {
    color: #2dd4bf !important;
    background-color: var(--surface-hover) !important;
}

/* 2. Popover Header */
html.dark #notificationPopoverHeader,
html.dark #notificationPopover > div:first-child {
    background-color: #131c26 !important;
    background: #131c26 !important;
    border-bottom: 1px solid #273748 !important;
    border-bottom-color: #273748 !important;
}

html.dark #notificationPopoverHeader h3,
html.dark #notificationPopover > div:first-child h3 {
    color: #f8fafc !important;
}

html.dark #notificationPopoverHeader .material-symbols-outlined.text-primary,
html.dark #notificationPopover > div:first-child .material-symbols-outlined.text-primary {
    color: #2dd4bf !important;
}

html.dark #notificationPopoverHeader button,
html.dark #notificationPopover > div:first-child button {
    color: #2dd4bf !important;
    transition: color 0.15s ease-in-out;
}
html.dark #notificationPopoverHeader button:hover,
html.dark #notificationPopover > div:first-child button:hover {
    color: #99f6e4 !important;
}

html.dark #notificationPopoverHeader a,
html.dark #notificationPopover > div:first-child a {
    color: #94a3b8 !important;
    transition: color 0.15s ease-in-out;
}
html.dark #notificationPopoverHeader a:hover,
html.dark #notificationPopover > div:first-child a:hover {
    color: #f8fafc !important;
}

/* 3. Web Push Popover Status Bar */
html.dark #webPushPopoverBar {
    border-bottom: 1px solid #273748 !important;
}

html.dark #webPushPopoverBar.bg-emerald-50\/70,
html.dark #webPushPopoverBar[class*="bg-emerald"] {
    background-color: rgba(6, 78, 59, 0.28) !important;
    background: rgba(6, 78, 59, 0.28) !important;
    border-bottom-color: rgba(16, 185, 129, 0.25) !important;
}

html.dark #webPushPopoverBar .text-emerald-700 {
    color: #6ee7b7 !important;
}

html.dark #webPushPopoverBar .bg-emerald-500 {
    background-color: #34d399 !important;
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

html.dark #webPushPopoverBar button[onclick*="sendTest"] {
    color: #2dd4bf !important;
}
html.dark #webPushPopoverBar button[onclick*="sendTest"]:hover {
    color: #99f6e4 !important;
}

html.dark #webPushPopoverBar.bg-primary\/5,
html.dark #webPushPopoverBar[class*="bg-primary"] {
    background-color: rgba(39, 55, 72, 0.4) !important;
    background: rgba(39, 55, 72, 0.4) !important;
    border-bottom-color: #273748 !important;
}

html.dark #webPushPopoverBar .text-gray-600 {
    color: #cbd5e1 !important;
}

html.dark #webPushPopoverBar button[onclick*="subscribe"] {
    color: #2dd4bf !important;
}
html.dark #webPushPopoverBar button[onclick*="subscribe"]:hover {
    color: #99f6e4 !important;
}

/* 4. Notification List & Items */
html.dark #notificationList {
    background-color: #18222e !important;
    background: #18222e !important;
}

html.dark #notificationList.divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
    border-color: #273748 !important;
    border-top-color: #273748 !important;
}

html.dark #notificationList > div[onclick],
html.dark .notification-item {
    transition: background-color 0.15s ease-in-out;
}

/* Read Items */
html.dark #notificationList > div[onclick].hover\:bg-gray-50:not([class*="bg-primary"]),
html.dark .notification-item-read {
    background-color: transparent !important;
}
html.dark #notificationList > div[onclick].hover\:bg-gray-50:not([class*="bg-primary"]):hover,
html.dark .notification-item-read:hover {
    background-color: #202d3d !important;
}

/* Unread Items */
html.dark #notificationList > div[onclick][class*="bg-primary"],
html.dark .notification-item-unread {
    background-color: rgba(45, 212, 191, 0.08) !important;
}
html.dark #notificationList > div[onclick][class*="bg-primary"]:hover,
html.dark .notification-item-unread:hover {
    background-color: rgba(45, 212, 191, 0.15) !important;
}

/* Unread Dot */
html.dark #notificationList span.rounded-full.bg-primary {
    background-color: #2dd4bf !important;
    box-shadow: 0 0 6px rgba(45, 212, 191, 0.5);
}

/* Item Titles */
html.dark #notificationList > div[onclick][class*="bg-primary"] p.text-gray-800,
html.dark .notification-item-unread p.text-gray-800 {
    color: #f8fafc !important;
}
html.dark #notificationList > div[onclick]:not([class*="bg-primary"]) p.text-gray-800,
html.dark .notification-item-read p.text-gray-800 {
    color: #cbd5e1 !important;
}
html.dark #notificationList > div[onclick]:hover p.text-gray-800,
html.dark .notification-item:hover p.text-gray-800 {
    color: #2dd4bf !important;
}

/* Item Message Body */
html.dark #notificationList p.text-gray-600 {
    color: #94a3b8 !important;
}

/* Item Time */
html.dark #notificationList span.text-gray-400 {
    color: #64748b !important;
}

/* Item Severity Icons */
html.dark #notificationList .material-symbols-outlined.text-primary {
    color: #2dd4bf !important;
}
html.dark #notificationList .material-symbols-outlined.text-amber-500 {
    color: #fbbf24 !important;
}
html.dark #notificationList .material-symbols-outlined.text-emerald-500 {
    color: #34d399 !important;
}
html.dark #notificationList .material-symbols-outlined.text-amber-600 {
    color: #f59e0b !important;
}
html.dark #notificationList .material-symbols-outlined.text-red-500 {
    color: #f87171 !important;
}

/* Empty State / Loading State */
html.dark #notificationList .text-gray-400 {
    color: #94a3b8 !important;
}
html.dark #notificationList .text-gray-300 {
    color: #475569 !important;
}

/* 5. Custom Dark Scrollbar for Notification List */
html.dark #notificationList::-webkit-scrollbar {
    width: 6px;
}
html.dark #notificationList::-webkit-scrollbar-track {
    background: #131c26;
}
html.dark #notificationList::-webkit-scrollbar-thumb {
    background: #273748;
    border-radius: 9999px;
}
html.dark #notificationList::-webkit-scrollbar-thumb:hover {
    background: #334458;
}
html.dark #notificationList {
    scrollbar-width: thin;
    scrollbar-color: #273748 #131c26;
}

/* 6. Popover Footer */
html.dark #notificationPopoverFooter,
html.dark #notificationPopover > div:last-child {
    background-color: #131c26 !important;
    background: #131c26 !important;
    border-top: 1px solid #273748 !important;
    border-top-color: #273748 !important;
}

html.dark #notificationPopoverFooter a,
html.dark #notificationPopover > div:last-child a {
    color: #2dd4bf !important;
    transition: color 0.15s ease-in-out;
}
html.dark #notificationPopoverFooter a:hover,
html.dark #notificationPopover > div:last-child a:hover {
    color: #99f6e4 !important;
}

html.dark #notificationPopoverFooter a span.material-symbols-outlined,
html.dark #notificationPopover > div:last-child a span.material-symbols-outlined {
    color: inherit !important;
}

/* =============================================================
 * THEME DROPDOWN SELECTOR — DARK MODE V1.3
 * Charcoal header (#131c26), soft white/gray text (#cbd5e1),
 * discreet borders (#273748), WCAG AA contrast.
 * ============================================================= */
html.dark #themeDropdownMenu {
    background-color: #18222e !important;
    background: #18222e !important;
    border-color: #273748 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.55), 0 8px 10px -6px rgba(0, 0, 0, 0.55) !important;
}

html.dark #themeDropdownMenu > div:first-child {
    background-color: #131c26 !important;
    background: #131c26 !important;
    border-bottom: 1px solid #273748 !important;
    border-bottom-color: #273748 !important;
}

html.dark #themeDropdownMenu > div:first-child span {
    color: #cbd5e1 !important;
}

html.dark #themeDropdownMenu button[data-theme-option] {
    color: #cbd5e1 !important;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

html.dark #themeDropdownMenu button[data-theme-option]:hover,
html.dark #themeDropdownMenu button[data-theme-option]:focus {
    background-color: #202d3d !important;
    color: #f8fafc !important;
}

html.dark #themeDropdownMenu button[data-theme-option] .theme-check-icon {
    color: #2dd4bf !important;
}

/* =============================================================
 * ACTION PANELS, MODALS & IFRAMES — DARK MODE V1.3
 * Comprehensive adaptation for all backoffice action interfaces.
 * Charcoal background (#131c26), differentiated card surfaces (#18222e),
 * soft white headings (#f8fafc), legible muted text (#94a3b8 / #cbd5e1),
 * discreet borders (#273748), preserved button identity & WCAG AA contrast.
 * ============================================================= */

/* 1. Base Modal Body & Container (Applies to all modal-mode iframes) */
html.dark body,
html.dark body.modal-mode {
    background-color: var(--bg-primary) !important;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html.dark main.bg-white,
html.dark main[class*="bg-white"] {
    background-color: var(--bg-primary) !important;
    background: var(--bg-primary) !important;
}

html.dark .form-card,
html.dark .card,
html.dark .refund-card,
html.dark .cancel-card {
    background-color: var(--surface-primary) !important;
    background: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45) !important;
}

html.dark body.modal-mode .form-card,
html.dark body.modal-mode .card,
html.dark body.modal-mode .refund-card,
html.dark body.modal-mode .cancel-card {
    background-color: var(--bg-primary) !important;
    background: var(--bg-primary) !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* 2. Global Drawer / Slide-Over for Action Iframes */
html.dark #iframeActionContent {
    background-color: #18222e !important;
    background: #18222e !important;
    border-color: #273748 !important;
}

html.dark #iframeActionPanel .flex-1.relative,
html.dark #actionIframe {
    background-color: #131c26 !important;
    background: #131c26 !important;
}

/* 3. Factura Modal (ingresar_factura.php) */
html.dark .invoice-header {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .invoice-title h2 {
    color: var(--text-primary) !important;
}

html.dark .invoice-subtitle {
    color: var(--text-muted) !important;
}

html.dark .invoice-icon {
    background: rgba(124, 58, 237, 0.2) !important;
    color: #c084fc !important;
}

html.dark .order-box {
    background: rgba(124, 58, 237, 0.1) !important;
    border: 1px solid rgba(124, 58, 237, 0.28) !important;
    border-left: 4px solid #a855f7 !important;
}

html.dark .info-row {
    border-bottom-color: var(--border-primary) !important;
}

html.dark .order-label {
    color: #94a3b8 !important;
}

html.dark .order-value {
    color: var(--text-primary) !important;
}

html.dark .order-value.highlight {
    color: #c084fc !important;
}

html.dark .form-label {
    color: var(--text-secondary) !important;
}

html.dark .form-input {
    background-color: var(--input-background) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

html.dark .form-input:focus {
    border-color: #a855f7 !important;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2) !important;
}

html.dark .upload-area {
    background-color: #131c26 !important;
    border: 2px dashed #334458 !important;
    border-color: #334458 !important;
}

html.dark .upload-area:hover,
html.dark .upload-area.dragover {
    background-color: rgba(124, 58, 237, 0.12) !important;
    border-color: #a855f7 !important;
}

html.dark .upload-area.has-file {
    background-color: rgba(16, 185, 129, 0.12) !important;
    border-color: #10b981 !important;
}

html.dark .upload-icon {
    color: #64748b !important;
}

html.dark .upload-area.has-file .upload-icon {
    color: #34d399 !important;
}

html.dark .upload-text {
    color: var(--text-primary) !important;
}

html.dark .upload-subtext {
    color: var(--text-muted) !important;
}

html.dark .file-name {
    color: #34d399 !important;
}

html.dark .confirm-modal-content {
    background-color: var(--surface-primary) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6) !important;
}

html.dark .confirm-modal-title {
    color: var(--text-primary) !important;
}

html.dark .confirm-modal-text {
    color: var(--text-secondary) !important;
}

html.dark .confirm-modal-btn-cancel {
    background-color: #202d3d !important;
    color: var(--text-secondary) !important;
}

html.dark .confirm-modal-btn-cancel:hover {
    background-color: #273748 !important;
    color: #ffffff !important;
}

html.dark .loading-overlay {
    background: rgba(19, 28, 38, 0.92) !important;
}

html.dark .loading-text {
    color: #cbd5e1 !important;
}

/* 4. Pagos Efectivo & Datáfono (registrar_pago_efectivo.php & registrar_pago_datafono.php) */
html.dark .header-bar {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .header-title {
    color: var(--text-primary) !important;
}

html.dark .header-subtitle {
    color: var(--text-muted) !important;
}

html.dark .info-table {
    background: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark .info-row + .info-row {
    border-top: 1px solid var(--border-primary) !important;
    border-top-color: var(--border-primary) !important;
}

html.dark .info-label {
    color: var(--text-muted) !important;
}

html.dark .info-value {
    color: var(--text-primary) !important;
}

html.dark .info-row.highlight-pending {
    background: rgba(16, 185, 129, 0.12) !important;
}

html.dark .info-row.highlight-pending .info-label {
    color: #6ee7b7 !important;
}

html.dark .info-row.highlight-pending .info-value {
    color: #34d399 !important;
}

html.dark .confirmation-prompt {
    background: rgba(6, 78, 59, 0.25) !important;
    border: 2px solid rgba(16, 185, 129, 0.35) !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
    color: #a7f3d0 !important;
}

html.dark .alert-warning {
    background: rgba(146, 64, 14, 0.2) !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    color: #fde68a !important;
}

html.dark .alert-info {
    background: rgba(6, 78, 59, 0.2) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    color: #a7f3d0 !important;
}

html.dark .alert-error {
    background: rgba(153, 27, 27, 0.2) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: #fecaca !important;
}

html.dark .badge-pending,
html.dark .status-pill.pending {
    background: rgba(245, 158, 11, 0.18) !important;
    color: #fbbf24 !important;
    border: 1px solid rgba(245, 158, 11, 0.35) !important;
}

html.dark .badge-paid,
html.dark .status-pill.paid {
    background: rgba(16, 185, 129, 0.18) !important;
    color: #34d399 !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
}

/* 5. Reembolsos (completar_reembolso.php) */
html.dark .refund-header {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .refund-title h1 {
    color: var(--text-primary) !important;
}

html.dark .refund-subtitle {
    color: var(--text-muted) !important;
}

html.dark .refund-icon {
    background: rgba(217, 119, 6, 0.18) !important;
    color: #fbbf24 !important;
}

html.dark .order-summary {
    background: rgba(180, 83, 9, 0.12) !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    border-left: 4px solid #f59e0b !important;
}

html.dark .summary-row + .summary-row {
    border-top: 1px solid rgba(245, 158, 11, 0.2) !important;
    border-top-color: rgba(245, 158, 11, 0.2) !important;
}

html.dark .summary-label {
    color: #fde68a !important;
}

html.dark .summary-value {
    color: var(--text-primary) !important;
}

html.dark .summary-value.highlight-amount {
    color: #fbbf24 !important;
}

html.dark .btn-secondary {
    background-color: #202d3d !important;
    border-color: #334458 !important;
    color: var(--text-secondary) !important;
}

html.dark .btn-secondary:hover {
    background-color: #273748 !important;
    color: #ffffff !important;
}

html.dark .msg-error {
    background: rgba(153, 27, 27, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #fecaca !important;
}

/* 6. Guías CCR (ver_guia.php & agregar_guia.php) */
html.dark .header,
html.dark .guia-header {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .title h1,
html.dark .guia-title h2 {
    color: var(--text-primary) !important;
}

html.dark .subtitle,
html.dark .guia-subtitle {
    color: var(--text-muted) !important;
}

html.dark .title-icon {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

html.dark .details,
html.dark .customer-info {
    background: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark .detail-row {
    background: #131c26 !important;
}

html.dark .detail-row + .detail-row {
    border-top: 1px solid var(--border-primary) !important;
    border-top-color: var(--border-primary) !important;
}

html.dark .detail-label,
html.dark .customer-info strong {
    color: var(--text-muted) !important;
}

html.dark .detail-value,
html.dark .customer-info span {
    color: var(--text-primary) !important;
}

html.dark .guide-number,
html.dark .info-box {
    background: rgba(30, 58, 138, 0.22) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    border-left: 4px solid #3b82f6 !important;
}

html.dark .guide-number strong {
    color: #93c5fd !important;
}

html.dark .document-viewer,
html.dark .file-upload-area {
    background: #131c26 !important;
    border-color: #334458 !important;
}

html.dark .file-upload-area:hover {
    background: rgba(59, 130, 246, 0.12) !important;
    border-color: #3b82f6 !important;
}

/* 7. Actas & Firmas (ver_entrega.php & firmar_entrega.php) */
html.dark .delivery-meta,
html.dark .audit-card {
    background: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark .meta-item + .meta-item,
html.dark .audit-field + .audit-field {
    border-color: var(--border-primary) !important;
}

html.dark .meta-label {
    color: var(--text-muted) !important;
}

html.dark .meta-value {
    color: var(--text-primary) !important;
}

html.dark .acta-shell {
    background: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark .image-shell {
    background: rgba(6, 78, 59, 0.2) !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
}

html.dark .firmar-page,
html.dark .firmar-page.bg-white {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html.dark .firmar-page .form-card {
    background-color: transparent !important;
}

html.dark .firmar-page .info-item,
html.dark .firmar-page .products-box {
    background: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark .firmar-page .info-label,
html.dark .firmar-page .products-title,
html.dark .firmar-page .signature-section-title {
    color: var(--text-primary) !important;
}

html.dark .firmar-page .info-value,
html.dark .firmar-page .products-list,
html.dark .firmar-page .signature-section-subtitle {
    color: var(--text-muted) !important;
}

html.dark .firmar-page .signature-section {
    background: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
}

html.dark .firmar-page .signature-pad-container {
    background: #131c26 !important;
    border-color: #334458 !important;
    background-image: 
        linear-gradient(#202d3d 1px, transparent 1px),
        linear-gradient(90deg, #202d3d 1px, transparent 1px) !important;
}

html.dark .firmar-page .signature-pad-container::before {
    color: #475569 !important;
}

/* 8. Comprobante de Entrega (comprobante_entrega.php) */
html.dark .delivery-header {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .delivery-title h2,
html.dark .section-heading {
    color: var(--text-primary) !important;
}

html.dark .delivery-subtitle {
    color: var(--text-muted) !important;
}

html.dark .delivery-icon {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

html.dark .info-grid {
    border-color: var(--border-primary) !important;
    background: #131c26 !important;
}

html.dark .guide-box {
    background: rgba(30, 58, 138, 0.22) !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
}

html.dark .guide-badge-row {
    border-bottom-color: rgba(59, 130, 246, 0.25) !important;
}

html.dark .guide-number-tag {
    color: #93c5fd !important;
}

html.dark .guide-preview-wrapper {
    background: #131c26 !important;
    border-color: #334458 !important;
}

html.dark .btn-guide-open {
    background: #202d3d !important;
    border-color: #334458 !important;
    color: #60a5fa !important;
}

html.dark .btn-guide-open:hover {
    background: #273748 !important;
    color: #93c5fd !important;
}

html.dark .no-guide-card {
    background: #131c26 !important;
    border-color: #334458 !important;
    color: var(--text-muted) !important;
}

html.dark .btn-action-photo {
    background: #202d3d !important;
    border-color: #334458 !important;
    color: var(--text-primary) !important;
}

html.dark .btn-action-photo:hover {
    background: #273748 !important;
}

html.dark .btn-action-photo.primary-action {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    color: #93c5fd !important;
}

html.dark .btn-change-photo {
    background: #202d3d !important;
    border-color: #334458 !important;
    color: var(--text-secondary) !important;
}

html.dark .btn-change-photo:hover {
    background: #273748 !important;
    color: #ffffff !important;
}

/* 9. Verificación de Pago y Cancelación de Pedido (verificar_pago.php & cancelar_pedido.php) */
html.dark .verificar-page,
html.dark .verificar-page.bg-white {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html.dark .verificar-page .form-card {
    background-color: transparent !important;
}

html.dark .payment-title h2 {
    color: var(--text-primary) !important;
}

html.dark .payment-subtitle {
    color: var(--text-muted) !important;
}

html.dark .verificar-page .info-box {
    background: rgba(39, 79, 92, 0.25) !important;
    border: 1px solid rgba(45, 212, 191, 0.3) !important;
    border-left: 4px solid #14b8a6 !important;
}

html.dark .info-box strong,
html.dark .info-box span {
    color: var(--text-primary) !important;
}

html.dark .verificar-page label {
    color: var(--text-secondary) !important;
}

html.dark .verificar-page input,
html.dark .verificar-page #referencia {
    background-color: var(--input-background) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

html.dark .cancel-page {
    color: var(--text-primary) !important;
}

html.dark .cancel-header {
    border-bottom: 1px solid var(--border-primary) !important;
    border-bottom-color: var(--border-primary) !important;
}

html.dark .cancel-title h1 {
    color: #f87171 !important;
}

html.dark .cancel-subtitle {
    color: var(--text-muted) !important;
}

html.dark .cancel-icon {
    background: rgba(239, 68, 68, 0.2) !important;
}

html.dark .cancel-card .order-summary {
    background: rgba(185, 28, 28, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    border-left: 4px solid #ef4444 !important;
}

html.dark .cancel-card .summary-row + .summary-row {
    border-top: 1px solid rgba(239, 68, 68, 0.2) !important;
    border-top-color: rgba(239, 68, 68, 0.2) !important;
}

html.dark .cancel-warning {
    background: rgba(154, 52, 18, 0.2) !important;
    color: #fed7aa !important;
    border: 1px solid rgba(249, 115, 22, 0.35) !important;
}

html.dark .cancel-warning-danger {
    background: rgba(185, 28, 28, 0.18) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
}

html.dark .cancel-warning-amber {
    background: rgba(180, 83, 9, 0.18) !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
    color: #fde68a !important;
}

html.dark .cancel-label {
    color: var(--text-secondary) !important;
}

html.dark .cancel-textarea {
    background-color: var(--input-background) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

html.dark .cancel-help {
    color: var(--text-muted) !important;
}

html.dark .cancel-btn-secondary {
    background-color: #202d3d !important;
    border-color: #334458 !important;
    color: #cbd5e1 !important;
}

html.dark .cancel-btn-secondary:hover {
    background-color: #273748 !important;
    color: #ffffff !important;
}

/* 10. Drawers, Slide-Overs & Modals across all modules */
html.dark #userActionPanel #panelContent,
html.dark #productPanelContent,
html.dark #productHistoryContent,
html.dark #productImagesContent,
html.dark #fullscreenEditorContent,
html.dark #confirmModal #confirmContent,
html.dark #customerDetailsPanel #panelContent,
html.dark #cuponActionPanel #panelContent,
html.dark #cuponActionPanel #panelContent > div,
html.dark #promocionActionPanel #panelContent,
html.dark #promocionActionPanel #panelContent > div,
html.dark #tarifaActionPanel #panelContent,
html.dark #tarifaActionPanel #panelContent > div,
html.dark #inventoryAdjustPanel #panelContent,
html.dark #orderProductsContent,
html.dark #historyContent > div,
html.dark #uploadModal > div > div > div {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

html.dark #userActionPanel .border-t,
html.dark #productPanelContent .border-t,
html.dark #productHistoryContent .border-t,
html.dark #productImagesContent .border-t,
html.dark #fullscreenEditorContent .border-t,
html.dark #confirmModal .border-t,
html.dark #customerDetailsPanel .border-t,
html.dark #cuponActionPanel .border-t,
html.dark #promocionActionPanel .border-t,
html.dark #tarifaActionPanel .border-t,
html.dark #inventoryAdjustPanel .border-t,
html.dark #orderProductsContent .border-t,
html.dark #historyModal .border-t,
html.dark #historyModal div[class*="border-t"],
html.dark #uploadModal .border-t {
    background-color: #131c26 !important;
    border-top: 1px solid var(--border-primary) !important;
    border-top-color: var(--border-primary) !important;
}

/* Modal de Productos de Pedido (#orderProductsModal) */
html.dark #orderProductsList li {
    background-color: #18222e !important;
    border-color: #273748 !important;
    color: #f8fafc !important;
    box-shadow: none !important;
}

html.dark #orderProductsList li .text-gray-900 {
    color: #f8fafc !important;
}

html.dark #orderProductsList li .text-gray-500 {
    color: #94a3b8 !important;
}

html.dark #orderProductsList li .text-gray-700 {
    color: #cbd5e1 !important;
}

html.dark #orderProductsList li img {
    background-color: #131c26 !important;
    border-color: #273748 !important;
}

html.dark #orderProductsList li div[class*="bg-gray-100"] {
    background-color: #202d3d !important;
    border-color: #273748 !important;
    color: #94a3b8 !important;
}

html.dark #orderProductsContent button.border-gray-300,
html.dark #confirmModal button.border-gray-300,
html.dark #userActionPanel button.border-gray-300,
html.dark #productHistoryContent button.border-gray-300,
html.dark #productImagesContent button.border-gray-300,
html.dark #historyModal button.border-gray-300 {
    background-color: #202d3d !important;
    border-color: #334458 !important;
    color: #cbd5e1 !important;
}

html.dark #orderProductsContent button.border-gray-300:hover,
html.dark #confirmModal button.border-gray-300:hover,
html.dark #userActionPanel button.border-gray-300:hover,
html.dark #productHistoryContent button.border-gray-300:hover,
html.dark #productImagesContent button.border-gray-300:hover,
html.dark #historyModal button.border-gray-300:hover {
    background-color: #273748 !important;
    color: #ffffff !important;
}

/* Modal de Historial (#historyModal en Cupones y Promociones) */
html.dark #historyModal table {
    border-color: #273748 !important;
}

html.dark #historyModal thead,
html.dark #historyModal thead tr,
html.dark #historyModal thead th,
html.dark #historyModal thead.bg-gray-50 {
    background-color: #131c26 !important;
    color: #94a3b8 !important;
    border-color: #273748 !important;
}

html.dark #historyTableBody,
html.dark #historyTableBody tr,
html.dark #historyTableBody td {
    background-color: #18222e !important;
    color: #f8fafc !important;
    border-color: #273748 !important;
}

html.dark #historyTableBody tr:hover {
    background-color: #202d3d !important;
}

/* Ficha del Cliente (#customerDetailsPanel en Clientes) */
html.dark #customerDetailsPanel .bg-gray-50 {
    background-color: #131c26 !important;
    border-color: #273748 !important;
}

html.dark #customerDetailsPanel .text-primary {
    color: #5eead4 !important;
}

html.dark #customerDetailsPanel .text-gray-600 {
    color: #cbd5e1 !important;
}

html.dark #customerDetailsPanel .text-gray-500 {
    color: #94a3b8 !important;
}

html.dark #customerDetailsPanel div[class*="bg-blue-50"] {
    background-color: rgba(30, 58, 138, 0.25) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

html.dark #customerDetailsPanel div[class*="bg-green-50"] {
    background-color: rgba(6, 78, 59, 0.25) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

/* Modales de Historial e Imágenes de Producto */
html.dark #productHistoryLogsContainer,
html.dark #productImagesContent > div:nth-child(2) {
    background-color: #131c26 !important;
}

html.dark #productImagesContent .bg-white {
    background-color: #18222e !important;
    border-color: #273748 !important;
    color: #f8fafc !important;
}

html.dark #productImagesContent .text-primary {
    color: #5eead4 !important;
}

/* Toasts Globales */
html.dark #toastContainer > div {
    background-color: #18222e !important;
    border-color: #273748 !important;
    color: #f8fafc !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

html.dark #toastContainer .text-gray-700 {
    color: #f8fafc !important;
}

html.dark #toastContainer .text-gray-400 {
    color: #94a3b8 !important;
}

/* Selector de Apariencia */
html.dark #themeDropdownMenuHeader {
    background-color: #131c26 !important;
    background: #131c26 !important;
    border-bottom: 1px solid #273748 !important;
    border-bottom-color: #273748 !important;
}

html.dark #themeDropdownMenuHeader span {
    color: #cbd5e1 !important;
}

html.dark #fullscreenEditorWYSIWYG {
    background-color: var(--surface-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-primary) !important;
}

html.dark #fullscreenEditorModal .bg-white {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

html.dark #fullscreenEditorModal .bg-gray-50 {
    background-color: #131c26 !important;
}

html.dark #uploadModal .bg-white {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
}

html.dark #uploadModal .bg-gray-50 {
    background-color: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark #uploadModal select,
html.dark #userActionPanel select,
html.dark #productPanelContent select {
    background-color: var(--input-background) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

html.dark #previewsContainer {
    background-color: #131c26 !important;
    border-color: var(--border-primary) !important;
}

html.dark [id^="card-item-"] {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
}

html.dark [id^="photo-card-"] {
    background-color: var(--surface-primary) !important;
    border-color: var(--border-primary) !important;
}

/* PRINT MEDIA PROTECTION */
@media print {
    html, html.dark, body, body.modal-mode {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    
    .card, .form-card, .acta-shell, table, tbody tr {
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border-color: #cccccc !important;
    }
}
