/* cws_dark.css : dark theme for the CMS contestant web server (CWS).
 * Active only when <html data-theme="dark"> (set by the small script in base.html:
 * saved choice from the navbar button, else the device setting prefers-color-scheme).
 * Loaded after bootstrap.css and cws_style.css; every rule is scoped to the dark theme,
 * so the light theme is unchanged.  Remove the <link> in base.html (or use --rollback) to undo. */

html[data-theme="dark"] {
    color-scheme: dark;
    --d-bg: #14171c;
    --d-panel: #1c2027;
    --d-panel2: #232933;
    --d-stripe: #181c22;
    --d-hover: #2a313c;
    --d-border: #353d4a;
    --d-text: #d9dee6;
    --d-muted: #8d97a7;
    --d-link: #6db3ff;
    --d-link-hover: #a1cdff;
    --d-input: #10131a;
}

/* ---- base ---- */
html[data-theme="dark"] body {
    background-color: var(--d-bg);
    color: var(--d-text);
}
html[data-theme="dark"] a { color: var(--d-link); }
html[data-theme="dark"] a:hover { color: var(--d-link-hover); }
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: #eef1f5;
}
html[data-theme="dark"] h1 small, html[data-theme="dark"] h2 small, html[data-theme="dark"] h3 small,
html[data-theme="dark"] h4 small, html[data-theme="dark"] small, html[data-theme="dark"] .muted {
    color: var(--d-muted);
}
html[data-theme="dark"] .page-header { border-bottom-color: var(--d-border); }
html[data-theme="dark"] hr { border-top-color: var(--d-border); border-bottom-color: #0d0f13; }
html[data-theme="dark"] blockquote { border-left-color: var(--d-border); }
html[data-theme="dark"] code, html[data-theme="dark"] pre {
    background-color: var(--d-input);
    border-color: var(--d-border);
    color: #e3e8ef;
}
html[data-theme="dark"] pre code { background-color: transparent; }
html[data-theme="dark"] ::selection { background: #2f6db5; color: #fff; }

/* ---- top bar ---- */
html[data-theme="dark"] .navbar-inner,
html[data-theme="dark"] .navbar-fixed-top .navbar-inner {
    background-color: var(--d-panel);
    background-image: none;
    border-color: var(--d-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .navbar .brand,
html[data-theme="dark"] .navbar .brand:hover { color: #eef1f5; text-shadow: none; }
html[data-theme="dark"] .navbar-text,
html[data-theme="dark"] .navbar .navbar-text { color: var(--d-text); }
html[data-theme="dark"] .navbar-text strong { color: #fff; }
html[data-theme="dark"] .navbar-text em { color: var(--d-muted); }

/* ---- side menu, wells, login box ---- */
html[data-theme="dark"] .well,
html[data-theme="dark"] .hero-unit {
    background-color: var(--d-panel);
    border-color: var(--d-border);
    color: var(--d-text);
    box-shadow: none;
}
html[data-theme="dark"] .hero-unit h1 { color: #fff; }
html[data-theme="dark"] .nav-list > li > a,
html[data-theme="dark"] .nav-list .nav-header {
    text-shadow: none;
}
html[data-theme="dark"] .nav-list > li > a { color: var(--d-text); }
html[data-theme="dark"] .nav-list .nav-header { color: var(--d-muted); }
html[data-theme="dark"] .nav-list > li > a:hover { background-color: var(--d-hover); color: #fff; }
html[data-theme="dark"] .nav-list > .active > a,
html[data-theme="dark"] .nav-list > .active > a:hover {
    background-color: #2f6db5;
    color: #fff;
    text-shadow: none;
}
html[data-theme="dark"] .nav-list .divider {
    background-color: var(--d-border);
    border-bottom-color: transparent;
    box-shadow: none;
}
html[data-theme="dark"] .nav-tabs,
html[data-theme="dark"] .nav-tabs > li > a { border-color: var(--d-border); }
html[data-theme="dark"] .nav-tabs > li > a:hover { background-color: var(--d-hover); border-color: var(--d-border); }
html[data-theme="dark"] .nav-tabs > .active > a,
html[data-theme="dark"] .nav-tabs > .active > a:hover {
    background-color: var(--d-bg);
    border-color: var(--d-border);
    border-bottom-color: transparent;
    color: #fff;
}
html[data-theme="dark"] .nav-pills > li > a:hover { background-color: var(--d-hover); }
html[data-theme="dark"] .nav-pills > .active > a,
html[data-theme="dark"] .nav-pills > .active > a:hover { background-color: #2f6db5; color: #fff; }
html[data-theme="dark"] #countdown_box,
html[data-theme="dark"] #server_time_box { color: var(--d-text); }
html[data-theme="dark"] #countdown_label,
html[data-theme="dark"] #server_time_label { color: var(--d-muted); }
html[data-theme="dark"] .license_notice { color: var(--d-muted); }

/* ---- tables ---- */
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td { border-top-color: var(--d-border); }
html[data-theme="dark"] .table thead th {
    background-color: var(--d-panel2);
    color: #eef1f5;
    border-bottom-color: var(--d-border);
}
html[data-theme="dark"] .table-bordered,
html[data-theme="dark"] .table-bordered th,
html[data-theme="dark"] .table-bordered td { border-color: var(--d-border); }
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td,
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) th { background-color: var(--d-stripe); }
html[data-theme="dark"] .table tbody tr:hover td,
html[data-theme="dark"] .table tbody tr:hover th { background-color: var(--d-hover); }
html[data-theme="dark"] .table.table-nohover > tbody > tr:hover > td,
html[data-theme="dark"] .table.table-nohover > tbody > tr:hover > th { background-color: transparent !important; }
html[data-theme="dark"] .table td, html[data-theme="dark"] .table th { color: var(--d-text); }
html[data-theme="dark"] .table thead th { color: #eef1f5; }

/* ---- forms ---- */
html[data-theme="dark"] label,
html[data-theme="dark"] legend,
html[data-theme="dark"] .control-label { color: var(--d-text); }
html[data-theme="dark"] legend { border-bottom-color: var(--d-border); }
html[data-theme="dark"] .help-block,
html[data-theme="dark"] .help-inline { color: var(--d-muted); }
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="file"],
html[data-theme="dark"] .uneditable-input {
    background-color: var(--d-input);
    border-color: var(--d-border);
    color: var(--d-text);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] input[type="text"]:focus,
html[data-theme="dark"] input[type="password"]:focus,
html[data-theme="dark"] input[type="number"]:focus {
    border-color: #4a90d9;
    box-shadow: 0 0 6px rgba(74, 144, 217, 0.6);
    background-color: var(--d-input);
    color: #fff;
}
html[data-theme="dark"] ::placeholder { color: #6b7585; }
html[data-theme="dark"] select option { background-color: var(--d-input); color: var(--d-text); }
html[data-theme="dark"] input[disabled], html[data-theme="dark"] select[disabled],
html[data-theme="dark"] textarea[disabled] { background-color: var(--d-panel); color: var(--d-muted); }

/* ---- buttons ---- */
html[data-theme="dark"] .btn {
    background-color: #2a313c;
    background-image: none;
    border-color: #3d4655;
    color: var(--d-text);
    text-shadow: none;
    box-shadow: none;
}
html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] .btn:focus { background-color: #353d4a; color: #fff; }
html[data-theme="dark"] .btn.disabled, html[data-theme="dark"] .btn[disabled] {
    background-color: #232933; color: var(--d-muted); opacity: 0.65;
}
html[data-theme="dark"] .btn-primary { background-color: #2f6db5; border-color: #2a5f9e; color: #fff; }
html[data-theme="dark"] .btn-primary:hover { background-color: #3a7fcf; }
html[data-theme="dark"] .btn-success { background-color: #2f8a45; border-color: #297a3d; color: #fff; }
html[data-theme="dark"] .btn-success:hover { background-color: #39a156; }
html[data-theme="dark"] .btn-info { background-color: #2a7f9a; border-color: #246f88; color: #fff; }
html[data-theme="dark"] .btn-info:hover { background-color: #3393b2; }
html[data-theme="dark"] .btn-warning { background-color: #b9770e; border-color: #a2690c; color: #fff; }
html[data-theme="dark"] .btn-warning:hover { background-color: #d28a14; }
html[data-theme="dark"] .btn-danger { background-color: #b3392f; border-color: #9c3128; color: #fff; }
html[data-theme="dark"] .btn-danger:hover { background-color: #cc443a; }
html[data-theme="dark"] .btn .caret { border-top-color: currentColor; border-bottom-color: currentColor; }
html[data-theme="dark"] .close { color: #fff; text-shadow: none; opacity: 0.6; }
html[data-theme="dark"] .close:hover { color: #fff; opacity: 1; }
html[data-theme="dark"] .dropdown-menu { background-color: var(--d-panel2); border-color: var(--d-border); }
html[data-theme="dark"] .dropdown-menu li > a { color: var(--d-text); }
html[data-theme="dark"] .dropdown-menu li > a:hover { background-color: #2f6db5; color: #fff; }
html[data-theme="dark"] .dropdown-menu .divider { background-color: var(--d-border); border-bottom-color: transparent; }
html[data-theme="dark"] .label, html[data-theme="dark"] .badge { text-shadow: none; }

/* ---- alerts, notifications, modal ---- */
html[data-theme="dark"] .alert {
    background-color: #3a3220; border-color: #5f5129; color: #ecd58c; text-shadow: none;
}
html[data-theme="dark"] .alert-heading { color: inherit; }
html[data-theme="dark"] .alert-error, html[data-theme="dark"] .alert-danger {
    background-color: #3d2326; border-color: #6b3338; color: #f2a9a9;
}
html[data-theme="dark"] .alert-success { background-color: #1f3726; border-color: #2f5a3a; color: #9fdaab; }
html[data-theme="dark"] .alert-info { background-color: #1b303f; border-color: #2c5068; color: #a3d3ee; }
html[data-theme="dark"] .modal {
    background-color: var(--d-panel);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--d-text);
}
html[data-theme="dark"] .modal-header { border-bottom-color: var(--d-border); }
html[data-theme="dark"] .modal-footer {
    background-color: #181c22; border-top-color: var(--d-border); box-shadow: none;
}

/* ---- announcements, questions, messages (blue boxes) ---- */
html[data-theme="dark"] div.announcement_list div.announcement,
html[data-theme="dark"] div.question_list div.question,
html[data-theme="dark"] div.question_list div.answer,
html[data-theme="dark"] div.question_list div.no_answer,
html[data-theme="dark"] div.message_list div.message {
    background-color: #1b303f;
    border-color: #2c5068;
    color: #a3d3ee;
    text-shadow: none;
}

/* ---- score cells (re-declared: the striped rows above would otherwise hide them) ---- */
html[data-theme="dark"] .task_score.score_0 { background-color: hsla(0, 70%, 45%, 0.55); }
html[data-theme="dark"] .task_score.score_0_100 { background-color: hsla(48, 80%, 42%, 0.55); }
html[data-theme="dark"] .task_score.score_100 { background-color: hsla(130, 55%, 36%, 0.6); }
html[data-theme="dark"] .submission_list td.public_score.undefined,
html[data-theme="dark"] .submission_list td.total_score.undefined,
html[data-theme="dark"] .user_test_list tbody tr td.memory.undefined { color: var(--d-muted); }
html[data-theme="dark"] .table tbody td.public_score.score_0,
html[data-theme="dark"] .table tbody td.total_score.score_0 { background-color: hsla(0, 70%, 45%, 0.55); }
html[data-theme="dark"] .table tbody td.public_score.score_0_100,
html[data-theme="dark"] .table tbody td.total_score.score_0_100 { background-color: hsla(48, 80%, 42%, 0.55); }
html[data-theme="dark"] .table tbody td.public_score.score_100,
html[data-theme="dark"] .table tbody td.total_score.score_100 { background-color: hsla(130, 55%, 36%, 0.6); }
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.public_score.score_0,
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.total_score.score_0 { background-color: hsla(0, 70%, 45%, 0.55); }
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.public_score.score_0_100,
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.total_score.score_0_100 { background-color: hsla(48, 80%, 42%, 0.55); }
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.public_score.score_100,
html[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td.total_score.score_100 { background-color: hsla(130, 55%, 36%, 0.6); }
html[data-theme="dark"] .table tbody tr:hover td.public_score.score_0,
html[data-theme="dark"] .table tbody tr:hover td.total_score.score_0 { background-color: hsla(0, 70%, 50%, 0.68); }
html[data-theme="dark"] .table tbody tr:hover td.public_score.score_0_100,
html[data-theme="dark"] .table tbody tr:hover td.total_score.score_0_100 { background-color: hsla(48, 80%, 46%, 0.68); }
html[data-theme="dark"] .table tbody tr:hover td.public_score.score_100,
html[data-theme="dark"] .table tbody tr:hover td.total_score.score_100 { background-color: hsla(130, 55%, 40%, 0.72); }

/* ---- submission details, attachments, contest list ---- */
html[data-theme="dark"] #submission_detail .subtask-head {
    background-color: var(--d-panel2);
    box-shadow: 0 0 2px 2px #2d3441 inset;
    color: var(--d-text);
}
html[data-theme="dark"] #attachments ul li a:hover { background-color: var(--d-hover); }
html[data-theme="dark"] .contest-list li > a {
    background-color: var(--d-panel);
    border-color: var(--d-border);
}
html[data-theme="dark"] .contest-list li > a:hover { background-color: var(--d-hover); }

/* ---- small icons (the chevrons in the submission list) ---- */
html[data-theme="dark"] [class^="icon-"]:not(.icon-white),
html[data-theme="dark"] [class*=" icon-"]:not(.icon-white) { filter: invert(1) brightness(1.1); }

/* ---- theme toggle button in the top bar ---- */
#theme_toggle { min-width: 2.4em; }
