/* CallbackManager: hand-written CSS (decision 37). Colours and spacing in variables. */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --line: #e3e6eb;
    --accent: #1f6feb;
    --danger: #d92d20;
    --radius: 8px;
    --space: 1rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b2029;
        --text: #e6e9ef;
        --muted: #9aa3b2;
        --line: #2c333f;
        --accent: #6ea8fe;
        --danger: #f97066;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

/* Top bar (sketch 001): logo, tenant, ERG selector */
.navbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space);
    padding: 0.75rem calc(var(--space) * 1.5);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
}

.tenant {
    color: var(--muted);
}

/* A dropdown made of plain HTML: <details> opens and closes without JavaScript */
.menu {
    position: relative;
}

.menu summary {
    cursor: pointer;
    list-style: none;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.menu summary::after {
    content: " ▾";
    color: var(--muted);
}

.menu ul {
    position: absolute;
    z-index: 1;
    min-width: 100%;
    margin: 0.25rem 0 0;
    padding: 0.25rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.menu a {
    display: block;
    padding: 0.35rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.menu a:hover,
.menu a.current {
    background: var(--bg);
}

main {
    max-width: 90rem;
    margin: 0 auto;
    padding: var(--space);
}

/* Who is logged in, and "Esci", at the right end of the top bar */
.user {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    color: var(--muted);
}

.user-icon {
    fill: currentColor;
}

.logout {
    margin: 0;
}

/* The login page: one small card in the middle */
.login {
    display: flex;
    justify-content: center;
    padding-top: 10vh;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(22rem, 100%);
    padding: calc(var(--space) * 1.5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.login-form h1 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.login-form input {
    font: inherit;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}

.login-form .action {
    margin: 0.75rem 0 0;
    align-self: flex-start;
}

.login-form .alert {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--danger);
    background: var(--bg);
}

/* The ERG page (sketch 001): calls on the left, wallboard and queue in the middle, added agents on the right */
.board {
    display: grid;
    gap: var(--space);
    grid-template-columns: minmax(14rem, 1fr) minmax(0, 2fr) minmax(14rem, 1fr);
    grid-template-areas:
        "updated updated updated"
        "calls wallboard agents"
        "calls queue     agents";
    align-items: start;
}

.calls { grid-area: calls; }
.wallboard { grid-area: wallboard; }
.queue { grid-area: queue; }
.agents { grid-area: agents; }
.updated { grid-area: updated; }

/* Narrow screens: one column, most urgent first */
@media (max-width: 60rem) {
    .board {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "updated" "queue" "calls" "agents" "wallboard";
    }
}

.card {
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.card p {
    margin: 0;
}

.card.free {
    border-left: 3px solid var(--accent);
}

/* Buttons: "action" for adding, "link" for secondary actions (remove, close) */
button {
    font: inherit;
    cursor: pointer;
}

.action {
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent);
}

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    text-decoration: underline;
    font-size: 0.85rem;
}

/* The panel to add agents: floating on the right, hidden while empty */
.picker:empty {
    display: none;
}

.picker {
    position: fixed;
    top: 4.5rem;
    right: var(--space);
    z-index: 2;
    width: min(26rem, calc(100vw - 2 * var(--space)));
    max-height: calc(100vh - 6rem);
    overflow: auto;
    padding: var(--space);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.35);
}

.candidates {
    margin: 0 0 var(--space);
    padding: 0;
    list-style: none;
}

.candidates li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--line);
}

.candidates li.free {
    border-left: 3px solid var(--accent);
    padding-left: 0.5rem;
}

.candidates .action {
    margin: 0;
}

.card .detail {
    color: var(--muted);
    font-size: 0.9rem;
}

.notice {
    padding: var(--space);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space);
}

h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.count {
    display: inline-block;
    min-width: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--surface);
    font-size: 0.85rem;
    text-align: center;
}

/* Wallboard tiles: one big number each */
.tiles {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.tile {
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
}

.tile p {
    margin: 0;
}

.tile-value {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tile-label {
    font-weight: 600;
}

.tile-hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.tile.alert {
    border-color: var(--accent);
    border-width: 2px;
}

/* Update time: the dot flashes each time HTMX swaps the board in (the animation restarts with it) */
.updated {
    justify-self: end;
}

.pulse {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s ease-out;
}

@keyframes pulse {
    from { opacity: 1; transform: scale(1.4); }
    to { opacity: 0.35; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pulse { animation: none; }
}

.updated,
.empty {
    color: var(--muted);
    margin: 0 0 var(--space);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
}

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

/* A request whose callback is ringing now */
tr.calling td {
    font-weight: 600;
    color: var(--accent);
}
