/* =====================================================================
   "Windows" style — the invoicing WinForms app (InvoiceLinesdapper) as
   Windows 10 draws it, the same look OrdersSolution1 and Paychecked offer:
   SystemColors.Control grey (#f0f0f0) forms, white windows and grids, Segoe UI,
   square controls, light-blue hover, Highlight blue (#0078d7) selection, white
   title bars with a red close button, yellow tooltips. Light only, as the
   desktop app: no dark variant.

   Active while <html data-theme="windows"> (js/theme.js); style.css alone is
   the "Original" style. Every rule sits inside @scope, whose root adds no
   specificity, so each replaces exactly the style.css rule with the same
   selector — the borderless icon buttons (.recalc-btn, .approve-badge,
   .line-edit-btn, ...) stay borderless because one class outranks `button`.
   For the same reason a button's hover and pressed colours are variables the
   base `button` rule reads rather than backgrounds of their own: an icon
   button's `background: none` then wins on hover too, where a
   `button:hover:not(:disabled)` background would outrank `.line-edit-btn:hover`.
   ===================================================================== */

html[data-theme="windows"] {
    --win-face: #f0f0f0;        /* SystemColors.Control */
    --win-window: #ffffff;      /* SystemColors.Window */
    --win-highlight: #0078d7;   /* SystemColors.Highlight */
    --win-btn: #e1e1e1;
    --win-btn-border: #adadad;
    --win-hot: #e5f1fb;
    --win-hot-border: #0078d7;
    --win-down: #cce4f7;
    --win-down-border: #005499;
    --win-menu-hot: #cce8ff;
    --win-menu-hot-border: #99d1ff;
    --win-tab-border: #d9d9d9;
    --win-field-border: #7a7a7a;
    --win-tip: #ffffe1;         /* SystemColors.Info */
    --win-green: #107c10;
    --win-red: #e81123;

    /* style.css tokens, re-pointed at the Windows system colours */
    --bg: var(--win-face);
    --text-dark: #000;
    --text-secondary: #6d6d6d;
    --border: var(--win-btn-border);
    --divider: #e5e5e5;
    --radius: 0;
    --radius-sm: 0;

    --gradient-dark: linear-gradient(var(--win-window), var(--win-window));
    --gradient-info: linear-gradient(var(--win-highlight), var(--win-highlight));
    --gradient-success: linear-gradient(#06b025, #06b025);   /* the progress bar's green */
    --gradient-warning: linear-gradient(#ffb900, #ffb900);
    --gradient-danger: linear-gradient(var(--win-red), var(--win-red));
    --gradient-primary: linear-gradient(var(--win-highlight), var(--win-highlight));

    --shadow-card: none;
    --shadow-header: none;
    --shadow-header-info: none;
    --shadow-header-success: none;
    --shadow-header-warning: none;
    --shadow-btn: none;

    /* What `button` is drawn with; :hover / :active only move these */
    --win-btn-bg: var(--win-btn);
    --win-btn-line: var(--win-btn-border);

    color-scheme: light;
}

@scope (html[data-theme="windows"]) {

    /* -----------------------------------------------------------------
       Base
       ----------------------------------------------------------------- */

    body {
        font-family: "Segoe UI", Tahoma, "Noto Sans", system-ui, sans-serif;
        background-color: var(--win-face);
        color: #000;
        scrollbar-color: #c1c1c1 var(--win-face);
    }

    h1, h2, h3 { font-weight: 400; }

    a { color: #0066cc; }

    ::selection { background: var(--win-highlight); color: #fff; }

    /* -----------------------------------------------------------------
       Controls: TextBox, ComboBox, CheckBox
       ----------------------------------------------------------------- */

    label { color: #000; font-weight: 400; }

    input, select {
        padding: 0.45rem 0.5rem;
        background: var(--win-window);
        border: 1px solid var(--win-field-border);
        border-radius: 0;
        accent-color: var(--win-highlight);
        transition: none;
    }

    input:hover:not(:disabled):not([readonly]), select:hover:not(:disabled) { border-color: #171717; }
    input:focus, select:focus { border-color: var(--win-highlight); box-shadow: none; }
    input:disabled, select:disabled { background: var(--win-face); border-color: #cccccc; color: #6d6d6d; }

    .checkbox-label { color: #000; }

    /* -----------------------------------------------------------------
       Buttons: grey, square, light blue when pointed at
       ----------------------------------------------------------------- */

    button, .store-app-button {
        background: var(--win-btn-bg);
        color: #000;
        border: 1px solid var(--win-btn-line);
        border-radius: 0;
        font-weight: 400;
        letter-spacing: normal;
        box-shadow: none;
        transition: none;
    }

    button:hover, .store-app-button:hover {
        --win-btn-bg: var(--win-hot);
        --win-btn-line: var(--win-hot-border);
        transform: none;
        box-shadow: none;
        opacity: 1;
    }

    button:active {
        --win-btn-bg: var(--win-down);
        --win-btn-line: var(--win-down-border);
    }

    button:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

    button:disabled {
        --win-btn-bg: #cccccc;
        --win-btn-line: #bfbfbf;
        opacity: 1;
        color: #838383;
        box-shadow: none;
    }

    /* The coloured buttons are the form's AcceptButton: the blue frame Windows
       draws round the default button; Windows has no red ones. */
    .btn-info, .btn-success, .btn-danger {
        background: var(--win-btn-bg);
        color: #000;
        border-color: var(--win-highlight);
        box-shadow: inset 0 0 0 1px var(--win-highlight);
    }
    .btn-danger { color: #c42b1c; }
    .btn-info:disabled, .btn-success:disabled, .btn-danger:disabled { border-color: #bfbfbf; box-shadow: none; }

    .toggle-btn { border-radius: 0; border: 1px solid var(--win-btn-border); background-color: var(--win-window); }
    .toggle-btn:hover { background-color: var(--win-hot); border-color: var(--win-hot-border); }

    .lang-switch button { border-radius: 0; }

    /* -----------------------------------------------------------------
       Messages: the MessageBox's plain coloured panels
       ----------------------------------------------------------------- */

    .message { border-radius: 0; }
    .message.success { background-color: #dff6dd; color: #000; border-color: #9fd89f; }
    .message.error   { background-color: #fde7e9; color: #000; border-color: var(--win-red); }
    .message.warning { background-color: #fff4ce; color: #000; border-color: #f2c661; }
    .message.info    { background-color: var(--win-tip); color: #000; border-color: #767676; }

    /* -----------------------------------------------------------------
       Login: a small window
       ----------------------------------------------------------------- */

    .login-container {
        padding: 0 1.25rem 1.25rem;
        background: var(--win-face);
        border: 1px solid var(--win-field-border);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    }

    .login-container h1 {
        margin: 0 -1.25rem 1.25rem;
        padding: 0.5rem 0.75rem;
        background: var(--win-window);
        color: #000;
        text-align: left;
        font-size: 0.9rem;
        font-weight: 400;
    }

    /* -----------------------------------------------------------------
       Sidenav: a navigation pane docked to the left edge
       ----------------------------------------------------------------- */

    .sidenav {
        top: 0;
        left: 0;
        bottom: 0;
        padding: 0.5rem 0.4rem 1rem;
        background: var(--win-window);
        color: #000;
        border-right: 1px solid var(--win-tab-border);
    }

    .sidenav-brand { color: #000; font-weight: 400; }
    .sidenav-brand .material-symbols-rounded { color: var(--win-highlight); }
    .sidenav-divider { background: var(--win-tab-border); margin: 0 0.35rem 0.5rem; }

    .sidenav-link {
        color: #000;
        padding: 0.4rem 0.75rem;
        margin-bottom: 1px;
        border: 1px solid transparent;
        transition: none;
    }
    .sidenav-link:hover { background-color: var(--win-hot); color: #000; }
    .sidenav-link.active {
        background: var(--win-menu-hot);
        border-color: var(--win-menu-hot-border);
        color: #000;
        font-weight: 400;
        box-shadow: none;
    }

    .sidenav-backdrop { background: rgba(0, 0, 0, 0.25); }

    /* Docked rather than floating, so the gap beside it goes */
    @media (min-width: 1025px) {
        .main-content { margin-left: 250px; }
    }

    /* -----------------------------------------------------------------
       Top bar
       ----------------------------------------------------------------- */

    .breadcrumb span { font-weight: 400; }
    #userInfo { color: #000; }
    #userInfo.previewing { color: #c42b1c; }
    .company-switch { color: #000; }
    .company-switch select { border-radius: 0; border-color: var(--win-field-border); }
    .lang-switch button:hover { border-color: var(--win-hot-border); background: var(--win-hot); }
    .lang-switch button.active { border-color: var(--win-highlight); }
    .menu-toggle { background-color: var(--win-window); border: 1px solid var(--win-btn-border); }

    .developer-config { border-radius: 0; background: var(--win-tip); color: #000; border-color: #767676; }

    /* -----------------------------------------------------------------
       Cards: a window, the floating gradient header its title bar
       ----------------------------------------------------------------- */

    .card { background: var(--win-window); border: 1px solid var(--win-tab-border); }

    .table-card { margin-top: 1rem; }

    .card-header-gradient {
        margin: 0 0 0.5rem;
        padding: 0.45rem 0.75rem;
        background: var(--win-window);
        color: #000;
        border-bottom: 1px solid var(--win-tab-border);
    }

    .card-header-gradient h2, .card-header-gradient h3 { color: #000; font-weight: 400; font-size: 0.9rem; }

    /* The colours that tell the eligible and ineligible routes apart survive as
       a stripe down the title bar */
    .bg-gradient-info    { border-left: 3px solid var(--win-highlight); }
    .bg-gradient-success { border-left: 3px solid var(--win-green); }
    .bg-gradient-warning { border-left: 3px solid #ff8c00; }

    /* The close button in a window's corner: wide, flat, red when pointed at */
    .card-header-gradient .header-actions button {
        align-self: stretch;
        margin: -0.45rem -0.75rem -0.45rem 0;
        padding: 0 0.9rem;
        background: transparent;
        border: 0;
        color: #000;
    }
    .card-header-gradient .header-actions button:hover { background: var(--win-red); color: #fff; }
    .modal .card-header-gradient .header-actions button { padding: 0 0.9rem; }

    /* Segmented switches: CheckBoxes in Button appearance, the pressed one down */
    .fuel-price-mode-switch, .lines-customer-switch { border-radius: 0; box-shadow: none; gap: 0; }

    .fuel-price-mode-switch button,
    .lines-customer-switch button,
    .lines-customer-switch button:hover {
        border: 1px solid var(--win-btn-line);
        margin-right: -1px;
        border-radius: 0;
        background: var(--win-btn-bg);
        color: #000;
        font-weight: 400;
    }

    .fuel-price-mode-switch button.active,
    .lines-customer-switch button.active,
    .lines-customer-switch button.active:hover {
        background: var(--win-down);
        border-color: var(--win-down-border);
        color: #000;
        position: relative;
        z-index: 1;
    }

    .fuel-price-mode-switch button:disabled { opacity: 1; }

    /* -----------------------------------------------------------------
       Tables: the DataGridView
       ----------------------------------------------------------------- */

    .table-container { background: var(--win-window); }

    th, td { padding: 0.4rem 0.6rem; }

    th {
        background-color: var(--win-window);
        color: #000;
        font-size: 0.8rem;
        font-weight: 400;
        text-transform: none;
        letter-spacing: normal;
        border-right: 1px solid var(--divider);
        border-bottom: 1px solid var(--win-tab-border);
    }

    td { border-bottom-color: #f0f0f0; }

    #linesTable tbody tr.route-even td { background-color: var(--win-window); }
    #linesTable tbody tr.route-odd td  { background-color: #f5f9fd; }

    table.day-sections > tbody > tr > td { background-color: var(--win-window); }
    table.day-sections tr.date-group-start > td { border-top: 1px solid var(--win-tab-border); }
    table.day-sections > tbody > tr.row-approved > td { background-color: #dff6dd; }
    table.day-sections > tbody > tr.row-pending-approval > td,
    #linesTable tbody tr.row-pending-approval td { background-color: #fff4ce; }
    tr.fuel-default-selected > td { background-color: var(--win-menu-hot); }

    .line-details th, .fuel-defaults-bulk-row th { background-color: var(--win-face); }

    #linesTable td.day-total-label { color: #000; font-weight: 400; text-transform: none; letter-spacing: normal; font-size: 0.8rem; }

    .fuel-tables.bulk-armed td.desc-cell:hover { background: var(--win-hot); }

    .stub-container, .filters { background: var(--win-window); border-radius: 0; }

    .billing-header-handle { border: 0; }
    .billing-header-handle:hover { background: var(--win-hot); }

    .billing-header .admin-bar { border-bottom-color: var(--win-tab-border); }

    /* -----------------------------------------------------------------
       Contractor sidebar: a ListBox
       ----------------------------------------------------------------- */

    .company-sidebar-header {
        background: var(--win-face);
        color: #000;
        font-size: 0.8rem;
        font-weight: 400;
        text-transform: none;
        letter-spacing: normal;
        padding: 0.4rem 0.75rem;
        border-bottom-color: var(--win-tab-border);
    }

    .company-list { padding: 1px; }
    .company-item { padding: 0.3rem 0.6rem; }
    .company-item:hover { background: var(--win-hot); }
    .company-item.active { background: var(--win-highlight); color: #fff; }
    .company-item-code { font-weight: 400; }
    .company-item-count { border-radius: 0; background: transparent; color: var(--text-secondary); font-weight: 400; }
    .company-item.active .company-item-count { background: transparent; }
    .company-item-approved { color: var(--win-green); }

    /* -----------------------------------------------------------------
       Fuel surcharge sections and totals
       ----------------------------------------------------------------- */

    .fuel-week + .fuel-week { border-top: 1px solid var(--win-tab-border); }
    .fuel-week-head h3 { font-size: 0.95rem; }
    .total-item span { font-weight: 600; }
    .total-item.highlighted span { color: var(--win-green); }

    .company-choice-option, .return-address-option { border-radius: 0; }
    .company-choice-option:hover, .return-address-option:hover { background: var(--win-hot); }

    /* -----------------------------------------------------------------
       Account and Settings
       ----------------------------------------------------------------- */

    .account-section h2 { font-size: 0.95rem; color: #003399; }

    .section-count, .access-chip, .course-pill, .pending-unverified { border-radius: 0; }

    .theme-option { border: 1px solid var(--win-tab-border); background: var(--win-window); }
    .theme-option:hover { background: var(--win-hot); border-color: var(--win-hot-border); }
    .theme-option:has(input:checked) { background: var(--win-menu-hot); border-color: var(--win-menu-hot-border); }
    .theme-option:has(input:focus-visible) { outline: 1px dotted #000; outline-offset: -4px; }
    .theme-option-name { font-weight: 400; }

    /* -----------------------------------------------------------------
       Dialogs: a Windows 10 window on a barely dimmed screen
       ----------------------------------------------------------------- */

    .modal-backdrop { background: rgba(0, 0, 0, 0.12); }

    .modal {
        margin-top: 0;
        padding-bottom: 0.75rem;
        background: var(--win-face);
        border: 1px solid var(--win-field-border);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    }

    .modal .card-header-gradient { border-bottom: 0; border-left: 0; }

    /* -----------------------------------------------------------------
       Courses
       ----------------------------------------------------------------- */

    .course-card { border: 1px solid var(--win-tab-border); }
    .course-card:hover { transform: none; border-color: var(--win-hot-border); }
    .course-card-top { border-radius: 0; }
    .course-badge { border-radius: 0; }
    .course-badge.large { border-radius: 50%; }
    .course-qnum { border-radius: 0; background: var(--win-highlight); }
    .course-watch-track { background: #e6e6e6; border: 1px solid #bcbcbc; border-radius: 0; }
    .course-question { border-color: var(--win-tab-border); background: var(--win-window); }
    .course-question legend { font-weight: 400; color: #003399; }
    .course-summary { background: #dff6dd; border-left-color: var(--win-green); }
    .course-locked { background: #fff4ce; color: #000; }
    .course-result.passed { background: #dff6dd; color: #000; }
    .course-result.failed { background: #fff4ce; color: #000; }
    .course-edit-modal textarea { border: 1px solid var(--win-field-border); border-radius: 0; background: var(--win-window); }
}
