/* ============================================================
 * Cell3D — Dark skin for content pages
 * ------------------------------------------------------------
 * The Awaiken template is driven almost entirely by 8 :root
 * variables (var() is used 300+ times, hardcoded hex ~29).
 * So the backbone of the dark theme is simply remapping those
 * variables under html[data-theme="dark"]; the rest of this
 * file patches the handful of places that use hardcoded light
 * colours or inline light backgrounds (index / Statistics /
 * Search / Download etc.).
 *
 * Loaded on content pages only. Viewers use viewer-light.css.
 * ============================================================ */

/* ---------- 1. Core variable remap ---------- */
html[data-theme="dark"] {
    --primary-color:      #0d1b26;  /* deep slate (was #023047) */
    --secondary-color:    #16232e;  /* panel / secondary surface */
    --text-color:         #b9c4cc;  /* body text on dark */
    --accent-color:       #0b2a3a;
    --white-color:        #0b141b;  /* "white" surfaces become dark */
    --black-color:        #e8eef2;  /* "black" text becomes light */
    --divider-color:      #ffffff1f;
    --dark-divider-color: #ffffff1f;
}

/* Global surfaces + smooth transition */
html[data-theme="dark"],
html[data-theme="dark"] body {
    background-color: #0b141b;
    color: var(--text-color);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main-header,
html[data-theme="dark"] .header-sticky,
html[data-theme="dark"] section,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .chart-panel {
    transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}

/* Headings keep the light accent for readability */
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 {
    color: #eaf2f6;
}

/* ---------- 2. Header / navigation ---------- */
html[data-theme="dark"] header.main-header {
    background-color: #0b141bcc;
    border-bottom: 1px solid var(--divider-color);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
html[data-theme="dark"] .header-sticky.sticky {
    background-color: #0b141bf2;
}
html[data-theme="dark"] .main-menu ul li a { color: #dfe7ec; }
html[data-theme="dark"] .main-menu ul li a:hover,
html[data-theme="dark"] .main-menu ul li a:focus { color: #6cc7e6; }
html[data-theme="dark"] .main-menu ul ul { background-color: var(--secondary-color); }

/* ---------- 3. Footer ---------- */
/* Give the footer a lighter panel shade than the body (#0b141b) plus a top
   divider, so it reads as a distinct block instead of blending in. */
html[data-theme="dark"] .main-footer {
    background-color: #16232e;
    background-blend-mode: multiply;
    border-top: 1px solid #ffffff1f;
}
html[data-theme="dark"] .main-footer * { color: #b9c4cc; }
html[data-theme="dark"] .main-footer h1,
html[data-theme="dark"] .main-footer h2,
html[data-theme="dark"] .main-footer h3,
html[data-theme="dark"] .main-footer h4,
html[data-theme="dark"] .main-footer h5,
html[data-theme="dark"] .main-footer h6,
html[data-theme="dark"] .main-footer a:hover { color: #eaf2f6; }
html[data-theme="dark"] .footer-copyright-text,
html[data-theme="dark"] .footer-links a { color: #9fb0ba; }

/* ---------- 4. Cards / panels / sections (generic) ---------- */
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .chart-panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .box,
html[data-theme="dark"] .panel {
    background: #111e28 !important;
    border-color: #ffffff14 !important;
    box-shadow: 0 2px 16px rgba(0,0,0,.45) !important;
    color: var(--text-color);
}

/* ---------- 5. Tables ---------- */
html[data-theme="dark"] table,
html[data-theme="dark"] .table {
    color: var(--text-color);
    background-color: transparent;
}
html[data-theme="dark"] table th,
html[data-theme="dark"] .table th {
    background-color: #16232e;
    color: #eaf2f6;
    border-color: #ffffff14 !important;
}
html[data-theme="dark"] table td,
html[data-theme="dark"] .table td { border-color: #ffffff0f !important; }
html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd),
html[data-theme="dark"] tbody tr:nth-of-type(odd) { background-color: #0f1a23; }
html[data-theme="dark"] tbody tr:hover { background-color: #172732; }

/* DataTables chrome (Browser / Search list views) */
html[data-theme="dark"] .dataTables_wrapper,
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_length,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter { color: var(--text-color); }
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-color) !important; }
html[data-theme="dark"] .dataTables_filter input,
html[data-theme="dark"] .dataTables_length select {
    background-color: #0f1a23;
    color: #eaf2f6;
    border: 1px solid #ffffff26;
}

/* ---------- 6. Forms / inputs ---------- */
html[data-theme="dark"] input:not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background-color: #0f1a23;
    color: #eaf2f6;
    border-color: #ffffff26;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #7c8b95; }

/* ---------- 7. Buttons ---------- */
html[data-theme="dark"] .btn-default {
    background-color: #16232e;
    color: #eaf2f6;
}
html[data-theme="dark"] .btn-default:hover { background-color: #1d3140; }

/* ---------- 8. Missing template vars used by About/Help/API ---------- */
/* These pages reference --cw-* / rgba(2,6,23,..) dark-on-light text.
   Redefine the cw palette so their cards/hero become dark surfaces. */
html[data-theme="dark"] {
    --cw-bg:      #111e28;
    --cw-border:  #ffffff1f;
    --cw-muted:   #9fb0ba;
}

/* ---------- 9. index.html / Mapping.html — upload UI ---------- */
html[data-theme="dark"] .upload-container { background: #111e28 !important; color: var(--text-color) !important; }
html[data-theme="dark"] .upload-area { background: #0f1a23 !important; border-color: #33566b !important; }
html[data-theme="dark"] .upload-area:hover,
html[data-theme="dark"] .upload-area.dragover { background: #13202b !important; }
html[data-theme="dark"] .subtitle { color: #9fb0ba !important; }
html[data-theme="dark"] .toast { background: #111e28 !important; color: #eaf2f6 !important; }
html[data-theme="dark"] .toast .title { color: #eaf2f6 !important; }
html[data-theme="dark"] .file-info,
html[data-theme="dark"] .info-box { background: #10202b !important; color: var(--text-color) !important; }
html[data-theme="dark"] .column-mapping { background: #1a1610 !important; }
html[data-theme="dark"] .error-msg { background: #2a1416 !important; color: #ffb3b8 !important; }
html[data-theme="dark"] .preview-table th { background: #16232e !important; color: #eaf2f6 !important; }
html[data-theme="dark"] .preview-table td { color: var(--text-color) !important; border-color: #ffffff14 !important; }
html[data-theme="dark"] .mapping-label { color: var(--text-color) !important; }
html[data-theme="dark"] .mapping-select { background: #0f1a23 !important; color: #eaf2f6 !important; }

/* ---------- 10. Statistics.jsp ---------- */
html[data-theme="dark"] .stat-card { background: #111e28 !important; }
html[data-theme="dark"] .stat-card .card-value { color: #eaf2f6 !important; }
html[data-theme="dark"] .stat-card .card-label { color: #9fb0ba !important; }
html[data-theme="dark"] .stat-card .card-icon { color: #4cb8d4 !important; }
html[data-theme="dark"] .chart-panel { background: #111e28 !important; }
html[data-theme="dark"] .chart-panel h4 { color: #dfe7ec !important; }
html[data-theme="dark"] .stat-legend .badge-item { background: #16232e !important; color: var(--text-color) !important; }

/* ---------- 11. Download.jsp ---------- */
html[data-theme="dark"] .download-intro,
html[data-theme="dark"] .dl-table-wrap { background: #111e28 !important; color: var(--text-color) !important; }
html[data-theme="dark"] .download-intro h4 { color: #eaf2f6 !important; }
html[data-theme="dark"] .dl-tab { background: #16232e !important; color: var(--text-color) !important; }
html[data-theme="dark"] .dl-tab:hover { background: #1d3140 !important; }
html[data-theme="dark"] .dl-dataset-table { background: #111e28 !important; color: var(--text-color) !important; }
html[data-theme="dark"] .dl-dataset-table thead th { background: #16232e !important; color: #eaf2f6 !important; }
html[data-theme="dark"] .dl-dataset-table tbody tr:nth-child(even) { background: #0f1a23 !important; }
html[data-theme="dark"] .dl-dataset-table tbody tr:hover { background: #172732 !important; }
html[data-theme="dark"] .dl-dataset-table tbody td { color: var(--text-color) !important; border-color: #ffffff0f !important; }
html[data-theme="dark"] .dl-toolbar .search-box input { background: #0f1a23 !important; color: #eaf2f6 !important; border-color: #ffffff26 !important; }
html[data-theme="dark"] .export-btn { background: #16232e !important; color: var(--text-color) !important; }
html[data-theme="dark"] .export-btn:hover { background: #1d3140 !important; }

/* ---------- 12. About.html / Help.html — cw-* cards (Ant Design) ---------- */
html[data-theme="dark"] .cw-hero,
html[data-theme="dark"] .cw-card,
html[data-theme="dark"] .cw-left,
html[data-theme="dark"] .ant-card {
    background: #111e28 !important;
    border-color: #ffffff1f !important;
    color: var(--text-color) !important;
}
html[data-theme="dark"] .cw-badge { background: #16232e !important; color: #cdd9e0 !important; border-color: #ffffff1f !important; }
html[data-theme="dark"] .cw-muted,
html[data-theme="dark"] .cw-feature-desc { color: #9fb0ba !important; }
html[data-theme="dark"] .ant-typography,
html[data-theme="dark"] .ant-typography p,
html[data-theme="dark"] .ant-card-body,
html[data-theme="dark"] .ant-card-head-title,
html[data-theme="dark"] .ant-list-item,
html[data-theme="dark"] .ant-collapse-content-box { color: var(--text-color) !important; }
html[data-theme="dark"] .ant-card-head { background: #111e28 !important; color: #eaf2f6 !important; border-color: #ffffff1f !important; }
html[data-theme="dark"] .ant-divider { border-color: #ffffff1f !important; }
html[data-theme="dark"] .ant-divider-inner-text,
html[data-theme="dark"] .ant-divider-inner-text h2 { color: #eaf2f6 !important; }
html[data-theme="dark"] .ant-anchor-link-title { color: #9fb0ba !important; }
html[data-theme="dark"] .ant-anchor-link-active > .ant-anchor-link-title { color: #4cb8d4 !important; }
html[data-theme="dark"] .cw-kbd { background: #16232e !important; color: #cdd9e0 !important; border-color: #ffffff26 !important; }

/* ---------- 13. API.html — quickstart / code blocks ---------- */
/* Code blocks are already dark (#0b1020) — leave them.
   Quickstart panels use light #f5f7ff → darken. */
html[data-theme="dark"] .api-quickstart { background: #10202b !important; border-color: #ffffff1f !important; }
html[data-theme="dark"] .api-quickstart-title,
html[data-theme="dark"] .api-header-title { color: #eaf2f6 !important; }
html[data-theme="dark"] .api-header-subtitle,
html[data-theme="dark"] .api-step-desc,
html[data-theme="dark"] .api-quickstart-body { color: #9fb0ba !important; }

/* ---------- 14. Browser.jsp / Search.jsp — sidebar + React cards ---------- */
/* The React "cards" are classless <div> with an inline white background at
   varying nesting depths, so structural selectors are brittle. React reflects
   background:'#fff' to the DOM as "background: rgb(255, 255, 255)", and a
   stylesheet !important beats an inline style that lacks !important — so match
   the white-background inline style directly. Property name is included to
   avoid catching white *text* colours. */
html[data-theme="dark"] #advancedSearchRoot [style*="background: rgb(255, 255, 255)"],
html[data-theme="dark"] #advancedSearchRoot [style*="background:#fff"],
html[data-theme="dark"] #advancedSearchRoot [style*="background: #fff"],
html[data-theme="dark"] #advancedSearchRoot [style*="background: white"],
html[data-theme="dark"] .dataset-content > div {
    background-color: #111e28 !important;
    border-color: #ffffff1f !important;
    color: var(--text-color) !important;
}
html[data-theme="dark"] .dataset-sider {
    background: #0f1a23 !important;
    border-color: #ffffff1f !important;
    color: var(--text-color) !important;
}
html[data-theme="dark"] .dataset-sider h4,
html[data-theme="dark"] #advancedSearchRoot h3,
html[data-theme="dark"] #advancedSearchRoot h4,
html[data-theme="dark"] #advancedSearchRoot h5 { color: #eaf2f6 !important; }
/* Muted helper <p> text (inline color:#888/#999) inside the cards */
html[data-theme="dark"] #advancedSearchRoot p[style*="color: rgb(136, 136, 136)"],
html[data-theme="dark"] #advancedSearchRoot [style*="color: rgb(153, 153, 153)"] { color: #9fb0ba !important; }
html[data-theme="dark"] .gene-example-chip { background: #16232e !important; border-color: #33566b !important; color: #cdd9e0 !important; }
html[data-theme="dark"] .gene-example-chip:hover { background: #1d3140 !important; }

/* Ant Design widgets (tables, selects, inputs, checkboxes, tabs) */
html[data-theme="dark"] .ant-table,
html[data-theme="dark"] .ant-table-thead > tr > th,
html[data-theme="dark"] .ant-table-tbody > tr > td,
html[data-theme="dark"] .ant-table-cell {
    background: #111e28 !important;
    color: var(--text-color) !important;
    border-color: #ffffff14 !important;
}
html[data-theme="dark"] .ant-table-thead > tr > th { color: #eaf2f6 !important; }
html[data-theme="dark"] .ant-table-tbody > tr:hover > td,
html[data-theme="dark"] .ant-table-tbody > tr.ant-table-row:hover > td { background: #172732 !important; }
html[data-theme="dark"] .ant-table-placeholder,
html[data-theme="dark"] .ant-empty-description { background: #111e28 !important; color: #9fb0ba !important; }
html[data-theme="dark"] .ant-select-selector,
html[data-theme="dark"] .ant-input,
html[data-theme="dark"] .ant-input-affix-wrapper,
html[data-theme="dark"] .ant-input-number,
html[data-theme="dark"] .ant-picker {
    background: #0f1a23 !important;
    color: #eaf2f6 !important;
    border-color: #ffffff26 !important;
}
html[data-theme="dark"] .ant-select-selection-item,
html[data-theme="dark"] .ant-select-selection-placeholder { color: #cdd9e0 !important; }
html[data-theme="dark"] .ant-select-dropdown {
    background: #16232e !important;
    color: #eaf2f6 !important;
}
html[data-theme="dark"] .ant-select-item { color: var(--text-color) !important; }
html[data-theme="dark"] .ant-select-item-option-active,
html[data-theme="dark"] .ant-select-item-option-selected { background: #1d3140 !important; color: #eaf2f6 !important; }
html[data-theme="dark"] .ant-checkbox-wrapper,
html[data-theme="dark"] .ant-radio-wrapper { color: var(--text-color) !important; }
html[data-theme="dark"] .ant-tabs { color: var(--text-color) !important; }
html[data-theme="dark"] .ant-tabs-tab { color: #9fb0ba !important; }
html[data-theme="dark"] .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn { color: #4cb8d4 !important; }
html[data-theme="dark"] .ant-tabs-ink-bar { background: #4cb8d4 !important; }
html[data-theme="dark"] .ant-btn-default { background: #16232e !important; color: #eaf2f6 !important; border-color: #ffffff26 !important; }
html[data-theme="dark"] .ant-pagination,
html[data-theme="dark"] .ant-pagination-item a { color: var(--text-color) !important; }
html[data-theme="dark"] .ant-pagination-item { background: #16232e !important; border-color: #ffffff26 !important; }
html[data-theme="dark"] .ant-pagination-item-active { border-color: #4cb8d4 !important; }
html[data-theme="dark"] .ant-pagination-item-active a { color: #4cb8d4 !important; }

/* ---------- 9. The toggle button itself ---------- */
.cell3d-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: 10px;
    border: 1px solid rgba(127,127,127,.35);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: transform .25s ease, background-color .25s ease, border-color .25s ease;
    vertical-align: middle;
}
.cell3d-theme-toggle:hover { transform: scale(1.1); border-color: #6cc7e6; }
.cell3d-theme-toggle .tt-ico { pointer-events: none; }

.cell3d-theme-toggle-item {
    display: flex;
    align-items: center;
}

/* Floating fallback (pages without a navbar/header) */
.cell3d-theme-toggle-floating {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100000;
    background: rgba(255,255,255,.9);
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
html[data-theme="dark"] .cell3d-theme-toggle-floating {
    background: rgba(17,30,40,.92);
}