/*
 * CCT app primitives, shared by every logged-in page.
 *
 * The rules of the app: show a smart default, keep real options one tap
 * away, move instead of jumping, and confirm what every action did.
 * Pages compose these pieces; colours come from cct-tokens.css.
 */

/* ── Motion ─────────────────────────────────────────────────────────────── */
@keyframes cct-rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cct-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cct-enter { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.cct-enter { animation: cct-enter 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ── Sheets ─────────────────────────────────────────────────────────────── */
.cct-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(7, 7, 12, 0.78);
    animation: cct-fade 0.2s ease-out;
}

.cct-sheet-backdrop[hidden] { display: none; }

.cct-sheet {
    width: 100%;
    max-width: 580px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    box-sizing: border-box;
    border-radius: var(--cct-radius-modal, 20px);
    background: var(--cct-surface, #13131c);
    border: 1px solid var(--cct-line, #26263a);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    color: var(--cct-text, #f4f3fa);
    animation: cct-rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Sliding panels inside a sheet ─────────────────────────────────────── */
.cct-slides { overflow: hidden; }

.cct-slide-track {
    display: flex;
    align-items: flex-start;
    width: 100%;
    transition: transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cct-slide-panel {
    flex: 0 0 100%;
    box-sizing: border-box;
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Summary rows: what will happen, one tap from its options ───────────── */
.cct-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 66px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--cct-line, #26263a);
    background: var(--cct-raised, #1b1b28);
    color: var(--cct-text, #f4f3fa);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cct-row:hover { border-color: #3a3a55; }

.cct-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cct-row-label { font-size: 12px; color: var(--cct-text-3, #85829b); }
.cct-row-value { font-weight: 600; }
.cct-row-why { font-size: 13px; color: var(--cct-text-3, #85829b); }
.cct-row-chevron { color: var(--cct-text-3, #85829b); font-size: 20px; }

/* A selectable option in a list (checked one carries aria-pressed="true"). */
.cct-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--cct-line, #26263a);
    background: var(--cct-raised, #1b1b28);
    color: var(--cct-text, #f4f3fa);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cct-option[aria-pressed="true"] { border: 2px solid var(--cct-violet-600, #7c3aed); padding: 13px; }

/* ── Segmented control ──────────────────────────────────────────────────── */
.cct-seg {
    display: flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--cct-bg, #0b0b12);
    border: 1px solid var(--cct-line, #26263a);
}

.cct-seg > button {
    flex: 1;
    min-height: 38px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--cct-text-2, #a6a3bc);
    font: 500 14px var(--cct-font, 'Outfit', system-ui, sans-serif);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cct-seg > button[aria-pressed="true"] { background: var(--cct-violet-tint, #241a3d); color: var(--cct-text, #f4f3fa); }

/* ── Pills (quick picks, filters) ───────────────────────────────────────── */
.cct-pill {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--cct-line, #26263a);
    background: transparent;
    color: var(--cct-text-2, #a6a3bc);
    font: 500 14px var(--cct-font, 'Outfit', system-ui, sans-serif);
    cursor: pointer;
}

.cct-pill[aria-pressed="true"] { border-color: var(--cct-violet-600, #7c3aed); background: var(--cct-violet-tint, #241a3d); color: var(--cct-text, #f4f3fa); }

/* ── Two-handle range ───────────────────────────────────────────────────── */
.cct-dual {
    --cct-dual-start: 0%;
    --cct-dual-end: 100%;
    position: relative;
    height: 64px;
    border-radius: 12px;
    background: var(--cct-bg, #0b0b12);
    border: 1px solid var(--cct-line, #26263a);
    overflow: hidden;
}

.cct-dual-window {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--cct-dual-start);
    right: calc(100% - var(--cct-dual-end));
    box-sizing: border-box;
    border: 2px solid var(--cct-violet-400, #a78bfa);
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.22);
    pointer-events: none;
}

.cct-dual-handle {
    position: absolute;
    top: 50%;
    width: 10px;
    height: 36px;
    margin: -18px 0 0 -5px;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.cct-dual-handle[data-for="start"] { left: var(--cct-dual-start); }
.cct-dual-handle[data-for="end"] { left: var(--cct-dual-end); }

.cct-dual-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.cct-dual-input::-webkit-slider-runnable-track { background: transparent; height: 100%; }
.cct-dual-input::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; appearance: none; width: 24px; height: 64px; background: transparent; border: none; cursor: ew-resize; }
.cct-dual-input::-moz-range-track { background: transparent; }
.cct-dual-input::-moz-range-thumb { pointer-events: auto; width: 24px; height: 64px; background: transparent; border: none; cursor: ew-resize; }
.cct-dual-input:focus-visible { outline: none; }
.cct-dual:focus-within { border-color: var(--cct-violet-400, #a78bfa); }

/* ── Round choices (Keep / No / Edit) ───────────────────────────────────── */
.cct-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 88px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cct-text, #f4f3fa);
    font: inherit;
    cursor: pointer;
}

.cct-choice-round {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 999px;
    font-size: 1.5rem;
    transition: transform 0.12s ease;
}

.cct-choice:active .cct-choice-round { transform: scale(0.92); }
.cct-choice:focus-visible { outline: none; }
.cct-choice:focus-visible .cct-choice-round { outline: 2px solid var(--cct-violet-400, #a78bfa); outline-offset: 3px; }

/* ── Confirmation line (what the last action did, with Undo) ────────────── */
.cct-ack {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    color: var(--cct-text-2, #a6a3bc);
    font-size: 0.875rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.cct-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--cct-text, #f4f3fa);
    color: var(--cct-bg, #0b0b12);
    font: 500 14px var(--cct-font, 'Outfit', system-ui, sans-serif);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, 18px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.24s ease;
}

.cct-toast.is-visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.cct-toast[data-tone="error"]::before,
.cct-toast[data-tone="warning"]::before { content: ""; flex: 0 0 8px; width: 8px; height: 8px; border-radius: 999px; }
.cct-toast[data-tone="error"]::before { background: var(--cct-danger, #f87171); }
.cct-toast[data-tone="warning"]::before { background: var(--cct-warn, #fbbf24); }

.cct-toast-action {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: none;
    background: var(--cct-bg, #0b0b12);
    color: var(--cct-text, #f4f3fa);
    font: 600 14px var(--cct-font, 'Outfit', system-ui, sans-serif);
    cursor: pointer;
}

/* ── Minutes pill in the nav ────────────────────────────────────────────── */
.cct-minutes {
    --cct-minutes-left: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--cct-line, #26263a);
    color: var(--cct-text-2, #a6a3bc);
    text-decoration: none;
    font-size: 14px;
}

.cct-minutes:hover { border-color: #3a3a55; }
.cct-minutes-head { display: flex; justify-content: space-between; gap: 8px; }
.cct-minutes-add { color: var(--cct-violet-400, #a78bfa); }

/* A collapsed sidebar keeps just the number. */
.sidebar.collapsed .cct-minutes { align-items: center; padding: 10px 6px; }
.sidebar.collapsed .cct-minutes-head { justify-content: center; }
.sidebar.collapsed .cct-minutes-unit,
.sidebar.collapsed .cct-minutes-add { display: none; }

.cct-minutes-meter {
    height: 4px;
    border-radius: 999px;
    background: var(--cct-line, #26263a);
    overflow: hidden;
}

.cct-minutes-meter > span {
    display: block;
    height: 100%;
    width: calc(var(--cct-minutes-left) * 100%);
    border-radius: 999px;
    background: var(--cct-violet-400, #a78bfa);
}

.cct-minutes-meter.is-live > span { transition: width 0.3s ease; }
.cct-minutes-meter.is-unknown > span { opacity: 0; }

/* ── Sidebar account card: who you're working as, then minutes ─────────── */
.cct-acct { position: relative; }
.cct-acct-card {
    border: 1px solid var(--cct-line, #26263a);
    border-radius: 10px;
    overflow: hidden;
}
.cct-acct-card .cct-minutes { border: 0; border-radius: 0; }
.cct-acct-card .cct-minutes:hover { background: rgba(255, 255, 255, 0.02); }
.cct-acct-who {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--cct-line, #26263a);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.cct-acct-who:hover { background: rgba(255, 255, 255, 0.03); }
.cct-acct-who:focus-visible { outline: 2px solid var(--cct-violet-400, #a78bfa); outline-offset: -2px; }
.cct-acct-av {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2b2145;
    color: var(--cct-violet-300, #c4b5fd);
    font-size: 12px;
    font-weight: 700;
}
.cct-acct-av.is-team { background: #3b2a12; color: #fcd9a5; }
.cct-acct-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cct-acct-name,
.cct-acct-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cct-acct-name { font-size: 14px; font-weight: 600; color: var(--cct-text, #f4f3fa); }
.cct-acct-sub { font-size: 12px; color: var(--cct-text-3, #85829b); }
.cct-acct-chev { flex: none; width: 16px; height: 16px; color: var(--cct-text-3, #85829b); }
.cct-acct-who[aria-expanded="true"] .cct-acct-chev { transform: rotate(180deg); }
.cct-acct-note {
    display: block;
    padding: 8px 12px 0;
    font-size: 12px;
    line-height: 1.35;
    color: #fcd9a5;
}
.cct-acct-status { margin: 6px 2px 0; min-height: 0; font-size: 12px; line-height: 1.35; color: var(--cct-violet-300, #c4b5fd); }
.cct-acct-status:empty { display: none; }
.cct-acct-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 50;
    padding: 6px;
    border: 1px solid var(--cct-line, #26263a);
    border-radius: 10px;
    background: #1a1a26;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.cct-acct-menu[hidden] { display: none; }
.cct-acct-group {
    padding: 8px 10px 4px;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cct-text-3, #85829b);
}
.cct-acct-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--cct-text, #f4f3fa);
    font: inherit;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.cct-acct-item:hover,
.cct-acct-item:focus-visible { background: #24223a; outline: none; }
.cct-acct-item:disabled { opacity: 0.6; cursor: progress; }
.cct-acct-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cct-acct-item-text > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cct-acct-item-text small { font-size: 12px; color: var(--cct-text-3, #85829b); }
.cct-acct-tick { color: var(--cct-violet-400, #a78bfa); }
.cct-acct-link { color: var(--cct-violet-400, #a78bfa); }
.cct-acct-link .cct-acct-item-text > span { color: var(--cct-violet-400, #a78bfa); }
.cct-acct-sep { height: 1px; margin: 6px 4px; background: var(--cct-line, #26263a); }

/* A collapsed sidebar keeps just the minutes. */
.sidebar.collapsed .cct-acct-who,
.sidebar.collapsed .cct-acct-note,
.sidebar.collapsed .cct-acct-menu,
.sidebar.collapsed .cct-acct-status { display: none; }

/* ── Phone tab bar ──────────────────────────────────────────────────────── */
.cct-tabbar { display: none; }

@media (max-width: 768px) {
    .cct-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        display: flex;
        justify-content: space-around;
        padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--cct-line, #26263a);
        background: rgba(19, 19, 28, 0.96);
        backdrop-filter: blur(12px);
    }

    .cct-tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        min-width: 64px;
        min-height: 48px;
        justify-content: center;
        color: var(--cct-text-3, #85829b);
        text-decoration: none;
        font: 500 12px var(--cct-font, 'Outfit', system-ui, sans-serif);
    }

    .cct-tabbar a svg { width: 20px; height: 20px; }
    .cct-tabbar a[aria-current="page"] { color: var(--cct-violet-300, #c4b5fd); }
}

@media (prefers-reduced-motion: reduce) {
    .cct-enter, .cct-sheet, .cct-sheet-backdrop { animation: none; }
    .cct-slide-track, .cct-toast, .cct-minutes-meter > span { transition: none; }
}

/* ── Page switch: two sibling pages shown as one place (Feed: Community / Yours) ── */
.cct-switch {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--cct-bg, #0b0b12);
    border: 1px solid var(--cct-line, #26263a);
}

.cct-switch a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 8px;
    color: var(--cct-text-2, #a6a3bc);
    font: 500 14px var(--cct-font, 'Outfit', system-ui, sans-serif);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cct-switch a:hover { color: var(--cct-text, #f4f3fa); }
.cct-switch a[aria-current="page"] { background: var(--cct-violet-tint, #241a3d); color: var(--cct-text, #f4f3fa); }
