/* ==========================================================================
   VoIP Desk - Central do Supervisor
   Design System Unificado (Padrão VoIP Desk - Admin & Agente)
   ========================================================================== */

:root {
    font-family: Arial, Helvetica, sans-serif;
    color-scheme: light;
    --bg: #f8fafd;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e8f0fe;
    --text: #202124;
    --muted: #5f6368;
    --line: #e4e8ed;
    --hover: #f0f3f7;
    --accent: #0b57d0;
    --accent-soft: #d3e3fd;
    --bubble: #e7f3eb;
    --shadow: 0 1px 3px rgba(31, 31, 31, 0.08);
    --green: #188038;
    --green-soft: #e6f4ea;
    --orange: #a15c00;
    --orange-soft: #fff4de;
    --red: #b3261e;
    --red-soft: #fce8e6;
    --purple: #67508e;
    --purple-soft: #e9e2fa;
    --cyan: #0284c7;
    --cyan-soft: #e0f2fe;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111418;
    --surface: #1b1f24;
    --surface-2: #252b31;
    --surface-3: #283b57;
    --text: #e8eaed;
    --muted: #a9b0b8;
    --line: #333941;
    --hover: #2a3037;
    --accent: #a8c7fa;
    --accent-soft: #29446d;
    --bubble: #203d32;
    --shadow: 0 4px 15px #000000;
    --green: #81c995;
    --green-soft: #183e29;
    --orange: #ffd18b;
    --orange-soft: #42351f;
    --red: #f2b8b5;
    --red-soft: #4c2a29;
    --purple: #d0bcff;
    --purple-soft: #4a4458;
    --cyan: #38bdf8;
    --cyan-soft: #082f49;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    font-family: Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.logo-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 22px;
    margin: 0 auto 14px;
}

.login-logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.login-logo p {
    color: var(--muted);
    font-size: 13px;
}

.input-group {
    position: relative;
    margin-bottom: 14px;
}

.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.15s, background-color 0.15s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

.error-msg {
    color: var(--red);
    font-size: 12px;
    text-align: center;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--red-soft);
    border-radius: 8px;
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    padding: 8px 16px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    transition: 0.15s ease;
}

.btn:hover {
    background: var(--hover);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-primary:hover {
    filter: brightness(0.92);
}

.btn-block {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
}

.btn-sm {
    min-height: 32px;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 16px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    flex: none;
    transition: 0.15s;
}

.icon-btn:hover {
    background: var(--hover);
    color: var(--text);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    line-height: 1.35;
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--muted);
    background: var(--surface-2);
    white-space: nowrap;
    font-weight: 500;
}

.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--surface-3); color: var(--accent); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--surface-2); color: var(--muted); }

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    letter-spacing: -0.4px;
    color: var(--text);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #ffffff;
    flex: none;
}

.brand-mark svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand strong {
    font-size: 16px;
    font-weight: 600;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 14px;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--red-soft);
    color: var(--red);
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    animation: livePulse 1.6s infinite;
}

@keyframes livePulse {
    0% { transform: scale(0.9); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(0.9); opacity: 1; }
}

.clock {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    flex: none;
}

/* ==========================================================================
   SUMMARY KPI CARDS
   ========================================================================== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 12px;
    padding: 20px 24px 16px;
}

.summary-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 14px;
    background: var(--surface);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.15s ease;
    min-width: 0;
}

.summary-card:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}

.summary-card .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 14px;
    flex: none;
}

.summary-card .card-info {
    min-width: 0;
    flex: 1;
}

.summary-card .card-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.15;
    color: var(--text);
}

.summary-card .card-label {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Cores dos ícones dos KPIs */
.card-calls .card-icon { background: var(--surface-3); color: var(--accent); }
.card-answered .card-icon { background: var(--green-soft); color: var(--green); }
.card-abandoned .card-icon { background: var(--red-soft); color: var(--red); }
.card-waiting .card-icon { background: var(--orange-soft); color: var(--orange); }
.card-active .card-icon { background: var(--surface-3); color: var(--accent); }
.card-sla .card-icon { background: var(--green-soft); color: var(--green); }
.card-avgwait .card-icon { background: var(--purple-soft); color: var(--purple); }
.card-avgtalk .card-icon { background: var(--cyan-soft); color: var(--cyan); }

/* ==========================================================================
   MAIN GRID & PANELS
   ========================================================================== */
.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 18px;
    padding: 0 24px 24px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.select-sm {
    padding: 5px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
}

.count-badge {
    padding: 2px 8px;
    background: var(--surface-3);
    color: var(--accent);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

/* ==========================================================================
   FILAS DE ATENDIMENTO (QUEUE MONITOR)
   ========================================================================== */
.queue-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}

.queue-monitor-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    transition: 0.15s ease;
}

.queue-monitor-card:hover {
    border-color: var(--accent);
}

.qm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.qm-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.qm-badge {
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

.qm-badge.active {
    background: var(--green-soft);
    color: var(--green);
}

.qm-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    text-align: center;
}

.qm-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qm-stat-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.qm-stat-value.waiting { color: var(--orange); }
.qm-stat-value.talking { color: var(--accent); }
.qm-stat-value.available { color: var(--green); }
.qm-stat-value.sla { color: var(--purple); font-size: 15px; }

.qm-stat-label {
    font-size: 9px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.qm-progress {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
    margin-top: 12px;
    overflow: hidden;
}

.qm-progress-bar {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ==========================================================================
   AGENT CARDS & ACTIONS (CORREÇÃO DE OVERFLOW / QUEBRA VISUAL)
   ========================================================================== */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    padding: 16px;
    max-height: 440px;
    overflow-y: auto;
}

.agent-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.agent-card:hover {
    border-color: var(--accent);
}

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.agent-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.agent-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.agent-ext {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    margin-top: 1px;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

.agent-status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.agent-status-dot.busy { background: var(--red); box-shadow: 0 0 6px var(--red); }
.agent-status-dot.break { background: var(--orange); }
.agent-status-dot.offline { background: var(--muted); }

.agent-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    margin: 8px 0 10px;
}

.agent-dept {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--muted);
    font-weight: 500;
}

/* Ações de Espião (Grid de 3 colunas perfeitamente encaixadas) */
.agent-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: auto;
}

.btn-spy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
    text-align: center;
    white-space: nowrap;
}

.btn-spy:hover {
    filter: brightness(0.92);
}

.btn-spy:active {
    transform: scale(0.97);
}

.btn-spy i {
    font-size: 10px;
    flex: none;
}

.btn-listen {
    background: var(--green-soft);
    color: var(--green);
    border-color: rgba(24, 128, 56, 0.2);
}

.btn-whisper {
    background: var(--orange-soft);
    color: var(--orange);
    border-color: rgba(161, 92, 0, 0.2);
}

.btn-barge {
    background: var(--red-soft);
    color: var(--red);
    border-color: rgba(179, 38, 30, 0.2);
}

/* ==========================================================================
   LIVE CALLS & WAITING LIST
   ========================================================================== */
.calls-list {
    padding: 14px;
    max-height: 400px;
    overflow-y: auto;
}

.call-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    margin-bottom: 8px;
    transition: 0.15s;
}

.call-item:hover {
    border-color: var(--accent);
}

.call-info {
    flex: 1;
    min-width: 0;
}

.call-info-main {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.call-info-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-duration {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    margin: 0 12px;
}

.call-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.waiting-list {
    padding: 14px;
    max-height: 280px;
    overflow-y: auto;
}

.waiting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    margin-bottom: 8px;
}

.waiting-caller {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.waiting-queue {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.waiting-time {
    font-size: 13px;
    font-weight: 700;
    color: var(--orange);
    font-variant-numeric: tabular-nums;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 13px;
}

.empty-state i {
    font-size: 26px;
    margin-bottom: 8px;
    display: block;
    opacity: 0.4;
}

/* ==========================================================================
   CHARTS CONTAINER
   ========================================================================== */
.chart-container {
    padding: 16px;
    height: 250px;
    position: relative;
}

.chart-container canvas {
    max-height: 220px;
    width: 100% !important;
}

/* ==========================================================================
   SCROLLBAR & RESPONSIVIDADE
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

@media (max-width: 1400px) {
    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1100px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 16px;
        height: auto;
        padding-top: 12px;
        padding-bottom: 12px;
        flex-wrap: wrap;
        gap: 12px;
    }
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        padding: 14px 16px 12px;
    }
    .main-grid {
        padding: 0 16px 16px;
    }
    .queue-grid {
        grid-template-columns: 1fr;
    }
}
