/* components.css — styles shared by every dashboard, loaded before each
 * dashboard's own static/styles.css (so a dashboard rule can still extend one).
 * Components: base page styles, scrollbars, segmented buttons, the
 * hours-source popover, sortable tables, record / month drill-down rows, the
 * detail panel, status banner, the Export CSV modal. The group editor and people picker live in
 * pickers.css.
 *
 * Theme: each dashboard sets its accent in its own styles.css :root —
 *   --accent       strong accent (selected-group marker)
 *   --accent-soft  pale accent (checked picker rows)
 */

/* =========================================================================
   Shared component styles — every page loads this (base.html).
   Holds the things Tailwind
   utility classes can't express cleanly (decorative marks, scrollbars,
   segmented toggles, risk indicators).
   ========================================================================= */

[hidden] {
    display: none !important;
}

/* Page height under the navbar. A top navbar (navbar.css) sets --nav-h to its
   height; every page root uses .app-h / var(--app-h) rather than 100vh so the
   page plus the bar fill the window exactly and never scroll the body. */
:root {
    --nav-h: 0px;
    --app-h: calc(100vh - var(--nav-h));
}
.app-h {
    height: var(--app-h);
}

html,
body {
    margin: 0;
    height: 100%;
    font-family:
        "IBM Plex Sans",
        system-ui,
        -apple-system,
        sans-serif;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.font-mono {
    font-variant-numeric: tabular-nums;
}

/* ---- custom scrollbars ---- */
.scroll-slate::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.scroll-slate::-webkit-scrollbar-thumb {
    background: rgb(203 213 225);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.scroll-slate::-webkit-scrollbar-thumb:hover {
    background: rgb(148 163 184);
    background-clip: padding-box;
}

.scroll-slate::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- segmented toggle buttons ---- */
.seg-btn {
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 7px;
    color: rgb(71 85 105);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    border: 1px solid transparent;
    background: none;
}

.seg-btn:hover {
    background: rgb(241 245 249);
}

.seg-btn.active {
    background: rgb(15 23 42);
    color: #fff;
}

/* Hours-worked data-source popover (settings gear) */
.time-source-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 268px;
    background: #fff;
    border: 1px solid rgb(226 232 240);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.25);
    padding: 12px;
    z-index: 9999;
}

.tsp-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgb(100 116 139);
}

.tsp-hint {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.4;
    color: rgb(100 116 139);
}

/* ---- sortable header caret ---- */
.sort-caret {
    opacity: 0;
    margin-left: 4px;
    transition: opacity 0.12s;
}

th.sortable:hover .sort-caret {
    opacity: 0.4;
}

th.sortable.sorted .sort-caret {
    opacity: 1;
}

/* ---- consumption bar (labor) ---- */
.consume-track {
    position: relative;
    height: 8px;
    width: 100%;
    border-radius: 9999px;
    background: rgb(241 245 249);
    overflow: hidden;
}

.consume-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s;
}

/* ---- expandable people sub-rows ---- */
.person-projects td {
    background: rgb(248 250 252);
    padding: 0;
}

.person-projects .inner {
    padding: 4px 16px 10px 40px;
}

.pp-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px dashed rgb(226 232 240);
}

.pp-row:last-child {
    border-bottom: 0;
}

/* ---- status banner ---- */
#status-banner.is-error {
    background: rgb(255 241 242);
    color: rgb(190 18 60);
}

#status-banner.is-loading {
    background: rgb(241 245 249);
    color: rgb(71 85 105);
}

/* =========================================================================
   Detail slide-over: monthly "Time" view
   ========================================================================= */
/* Wider detail slide-over on very large screens */
@media (min-width: 1860px) {
    #detail-panel {
        width: 840px;
    }
}

.month-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 4px;
    border-bottom: 1px solid rgb(241 245 249);
    cursor: pointer;
    transition: background 0.12s;
}

.month-row:hover {
    background: rgb(248 250 252);
}

.month-block {
    border-bottom: 1px solid rgb(241 245 249);
}

.month-block:last-child {
    border-bottom: 0;
}

.month-block.expanded {
    background: rgb(248 250 252);
}

.month-top {
    padding: 2px 4px 10px 26px;
}

.month-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px dashed rgb(226 232 240);
}

.month-top-row:last-child {
    border-bottom: 0;
}

/* =========================================================================
   People loading indicator + date-range emphasis
   ========================================================================= */
.people-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgb(100 116 139);
}

.people-loading .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgb(203 213 225);
    border-top-color: rgb(15 23 42);
    border-radius: 9999px;
    animation: people-spin 0.6s linear infinite;
}

@keyframes people-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Controls that change values (contract value, labor budget, milestones, future
   projects), hidden for access levels that can't edit (base.html sets the flag;
   the server refuses those changes regardless). */
html[data-can-edit="false"] [data-edit] {
    display: none !important;
}
/* ... and the note shown in their place, only to those levels */
html[data-can-edit="true"] [data-view-only] {
    display: none !important;
}
/* Controls locked by frontend_shared/access.js (or the milestone editor) look it. */
html[data-can-edit="false"] [data-locked]:disabled {
    cursor: default;
    opacity: 0.6;
}

/* ---- dropdown.js: the stylized dropdown (never the browser's native <select>) ---- */
.dd {
    position: relative;
}
.dd-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: rgb(248 250 252);
    border: 1px solid rgb(203 213 225);
    border-radius: 6px;
    font-size: 14px;
    color: rgb(15 23 42);
    text-align: left;
    cursor: pointer;
}
.dd-btn:hover {
    border-color: rgb(148 163 184);
}
.dd-btn svg {
    flex: none;
    color: rgb(100 116 139);
}
.dd-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dd-list {
    position: absolute;
    z-index: 40;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid rgb(203 213 225);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.dd.is-up .dd-list {
    top: auto;
    bottom: calc(100% + 4px);
}
.dd-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 14px;
    color: rgb(30 41 59);
    white-space: nowrap;
    cursor: pointer;
}
.dd-opt.is-active {
    background: rgb(241 245 249);
}
.dd-opt.is-chosen {
    font-weight: 600;
}
.dd-hint {
    font-size: 11px;
    font-weight: 600;
    color: rgb(3 105 161);
    background: rgb(224 242 254);
    border-radius: 9999px;
    padding: 1px 8px;
}
.dd-btn:focus-visible {
    outline: 2px solid rgb(14 165 233);
    outline-offset: 2px;
}

/* =========================================================================
   Export CSV: the file-name modal (csv_export.js)
   ========================================================================= */
.csv-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.csv-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(15 23 42 / 0.4);
}
.csv-modal-box {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid rgb(226 232 240);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgb(15 23 42 / 0.25);
}
.csv-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: rgb(15 23 42);
}
.csv-modal-label {
    display: block;
    margin: 16px 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgb(100 116 139);
}
.csv-filename {
    display: flex;
    align-items: center;
    border: 1px solid rgb(203 213 225);
    border-radius: 8px;
    overflow: hidden;
}
.csv-filename:focus-within {
    border-color: rgb(100 116 139);
    box-shadow: 0 0 0 3px rgb(203 213 225 / 0.5);
}
.csv-filename input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 0;
    outline: none;
    font-size: 14px;
    color: rgb(15 23 42);
}
.csv-filename span {
    padding: 8px 10px;
    background: rgb(248 250 252);
    border-left: 1px solid rgb(226 232 240);
    font-size: 14px;
    color: rgb(100 116 139);
}
.csv-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgb(226 232 240);
    background: rgb(226 232 240);
    color: rgb(30 41 59);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s;
}
.csv-btn:hover {
    background: rgb(203 213 225);
}
.csv-btn.is-primary {
    background: rgb(51 65 85);
    border-color: rgb(51 65 85);
    color: #fff;
}
.csv-btn.is-primary:hover {
    background: rgb(30 41 59);
}
