:root {
    --color-primary: #f2600c;
    --color-danger: #ef4444;
    --color-success: #15803d;

    --status-available: #22c55e;
    --status-in-call: #eab308;
    --status-after-call: #3b82f6;
    --status-do-not-disturb: #a855f7;
    --status-unavailable: #ef4444;
    --status-offline: #64748b;

    /* Résolution de référence sur laquelle toute la mise en page est conçue.
       app.js calcule un facteur d'échelle (voir fitStage()) pour que ce
       rendu soit reproduit à l'identique - juste agrandi ou réduit - quelle
       que soit la taille réelle de la fenêtre/écran (PC, TV, tablette...). */
    --stage-width: 1920px;
    --stage-height: 1080px;
}

html, body {
    height: 100%;
    background: #eef1f5;
}

body {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    overflow: hidden;
}

/* Occupe tout le viewport et centre la scène mise à l'échelle,
   quelle que soit la taille ou le ratio d'aspect de la fenêtre. */
.app-stage {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-wrapper {
    position: relative;
    width: var(--stage-width);
    height: var(--stage-height);
    flex: none;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: .75rem;
    box-sizing: border-box;
    /* transform: scale(...) appliqué dynamiquement par app.js (fitStage) */
}

/* ---------- Header ---------- */
.app-header { display: none; }
/*
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.app-title {
    color: var(--color-primary);
    font-weight: 700;
    font-size: 2rem;
    margin: 0;
}

.app-loading {
    animation: spin 1s linear infinite;
    color: #94a3b8;
}

.app-clock {
    font-size: 2.1rem;
    font-weight: 500;
    color: #1e293b;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
*/
/* ---------- Main layout ---------- */

.app-main {
    flex: 1;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr 1.4fr;
    grid-template-rows: 1.8fr 1fr;
    grid-template-areas:
        "stats stats agents"
        "pending pending agents";
    min-height: 0;
}

.availability-alert-area {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 2;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.availability-alert {
    color: var(--color-danger);
    font-size: 3rem;
    line-height: 1;
}

.availability-alert i {
    display: inline-block;
    animation: availability-pulse 1.2s ease-in-out infinite;
}

@keyframes availability-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: .6;
    }
}

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

.card {
    background: #fff;
    border: none;
    border-radius: .5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    padding: .5rem;
}

/* ---------- Stats ---------- */

.stats-area {
    grid-area: stats;
    display: grid;
    grid-template-rows: 1.1fr .8fr .8fr;
    gap: 1rem;
    min-height: 0;
}

.stats-primary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stats-row {
    display: grid;
    gap: 1rem;
}

.stats-row > .card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-secondary {
    grid-template-columns: repeat(2, 1fr);
}

.stats-tertiary {
    grid-template-columns: repeat(5, 1fr);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    text-align: center;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: #0f172a;
}

.stat-icon {
    font-size: 4rem;
    line-height: 1;
}

.stat-value {
    font-size: 4rem;
    font-weight: 600;
    line-height: 1;
}

.stat-unit {
    font-size: 2rem;
    font-weight: 500;
}

.stat-label {
    font-weight: 700;
    font-size: 1.3rem;
}

.stat-legend {
    font-size: .9rem;
    color: #64748b;
}

.stat.stat-danger .stat-top { color: var(--color-danger); }
.stat.stat-success .stat-top { color: var(--color-success); }

.stats-primary .stat-top { color: var(--color-primary); }
.stats-primary .stat-icon,
.stats-primary .stat-value { font-size: 4rem; }
.stats-primary .stat-label { font-size: 1.5rem; }
.stats-primary .stat.stat-danger .stat-top { color: var(--color-danger); }
.stats-primary .stat.stat-success .stat-top { color: var(--color-success); }

.stats-secondary .stat-top { color: var(--color-danger); }
.stats-secondary .stat.stat-success .stat-top { color: var(--color-success); }

/* ---------- Agents ---------- */

.agents-area {
    grid-area: agents;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.agents-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    align-content: start;
    gap: .5rem;
    /* Laisse de la place en bas pour ne pas masquer durablement un agent
       sous la légende flottante au premier affichage / en haut de liste. */
    padding-bottom: 3.5rem;
}

.agent-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .4rem .6rem;
    background: #f1f5f9;
    border-radius: .5rem;
}

.agent-card-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.agent-card-left span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
}

.status-dot {
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    border-radius: 50%;
}

.status-available { background: var(--status-available); }
.status-in_call { background: var(--status-in-call); }
.status-after_call_work { background: var(--status-after-call); }
.status-do_not_disturb { background: var(--status-do-not-disturb); }
.status-unavailable { background: var(--status-unavailable); }
.status-offline { background: var(--status-offline); }

.agent-badge {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .95rem;
    font-weight: 600;
    color: #fff;
    padding: .2rem .6rem;
    border-radius: .375rem;
    white-space: nowrap;
}

.agent-badge.ringing {
    background: var(--status-available);
}

.agent-badge.ringing i {
    animation: ring 1s infinite ease-in-out;
}

.agent-badge.paused {
    background: var(--status-offline);
}

@keyframes ring {
    0%, 100% { transform: rotate(0deg); }
    10%, 50% { transform: rotate(-20deg); }
    20%, 60% { transform: rotate(20deg); }
}

.agents-legend {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem 0 0;
    /* Dégradé pour fondre la liste d'agents sous la légende plutôt qu'une
       coupure nette, tout en gardant la légende elle-même bien lisible. */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, #fff 35%);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #e2e8f0;
    padding: .3rem 1rem;
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 500;
}

.legend-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
}

/* ---------- Pending calls ---------- */

.pending-area {
    grid-area: pending;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pending-title {
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: .5rem;
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.pending-call {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    background: #f1f5f9;
    border-radius: .5rem;
    font-size: 1.4rem;
}

.pending-call-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
}

.pending-call-left i {
    color: var(--status-available);
    animation: ring 1s infinite ease-in-out;
    font-size: 1.3rem;
}

.pending-call-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.2rem;
}

.pending-intro {
    background: #94a3b8;
    color: #fff;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 1rem;
    padding: .25rem .7rem;
    border-radius: .375rem;
}

.pending-timer-icon {
    animation: spin 1s ease-in-out infinite;
}

.timer-ok { color: #64748b; }
.timer-warning { color: #eab308; }
.timer-high { color: #f97316; }
.timer-critical { color: #ef4444; }

.pending-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #64748b;
    font-weight: 600;
    font-size: 1.3rem;
}

.pending-empty i {
    font-size: 5rem;
}

/* ---------- Scrollbars ---------- */

.agents-list::-webkit-scrollbar,
.pending-area::-webkit-scrollbar {
    width: 8px;
}

.agents-list::-webkit-scrollbar-thumb,
.pending-area::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}
