/* ============================================================================
 * Console de Operadora - Monitoramento de Ramais em Tempo Real
 * ============================================================================ */

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #161f33;
    --bg-card-hover: #1c2740;
    --border-color: #26334d;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Cores de Status (Console de Operadora) */
    --status-free: #10b981;
    --status-free-bg: rgba(16, 185, 129, 0.12);
    --status-free-border: rgba(16, 185, 129, 0.45);

    --status-ringing: #f59e0b;
    --status-ringing-bg: rgba(245, 158, 11, 0.15);
    --status-ringing-border: rgba(245, 158, 11, 0.65);

    --status-busy: #ef4444;
    --status-busy-bg: rgba(239, 68, 68, 0.14);
    --status-busy-border: rgba(239, 68, 68, 0.55);

    --status-offline: #64748b;
    --status-offline-bg: rgba(100, 116, 139, 0.12);
    --status-offline-border: rgba(100, 116, 139, 0.35);

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ============================================================================
 * TOPBAR / HEADER DO CONSOLE
 * ============================================================================ */
.topbar {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 1rem 1.75rem;
}

.topbar-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
    color: #fff;
}

.brand-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--status-free);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-free);
    box-shadow: 0 0 8px var(--status-free);
    animation: pulseDot 2s infinite;
}

.badge-mode {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge-mode.mock {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border-color: rgba(168, 85, 247, 0.4);
}

/* ============================================================================
 * CONTADORES DE STATUS (KPI PILLS)
 * ============================================================================ */
.status-Counters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.counter-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.counter-pill:hover,
.counter-pill.active {
    transform: translateY(-1px);
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.counter-pill .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.counter-pill.free .dot { background: var(--status-free); box-shadow: 0 0 8px var(--status-free); }
.counter-pill.ringing .dot { background: var(--status-ringing); box-shadow: 0 0 8px var(--status-ringing); }
.counter-pill.busy .dot { background: var(--status-busy); box-shadow: 0 0 8px var(--status-busy); }
.counter-pill.offline .dot { background: var(--status-offline); }

.counter-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ============================================================================
 * BARRA DE FERRAMENTAS (BUSCA + BOTÃO ADICIONAR)
 * ============================================================================ */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 1.75rem 3rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 460px;
}

.search-box svg {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.68rem 0.95rem 0.68rem 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
    background: #ef4444;
    color: #fff;
}

/* ============================================================================
 * GRADE DE CARDS DE RAMAIS (ESTILO CONSOLE DE OPERADORA)
 * ============================================================================ */
.extensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.1rem;
}

.ext-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--status-offline);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.85rem;
    position: relative;
    transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-height: 178px;
}

.ext-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

/* Variações visuais por Status */
.ext-card.status-free {
    border-top-color: var(--status-free);
    border-color: var(--status-free-border);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--bg-card) 45%);
}

.ext-card.status-ringing {
    border-top-color: var(--status-ringing);
    border-color: var(--status-ringing-border);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, var(--bg-card) 55%);
    animation: ringingCardPulse 1.1s infinite ease-in-out;
}

.ext-card.status-busy {
    border-top-color: var(--status-busy);
    border-color: var(--status-busy-border);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.12) 0%, var(--bg-card) 55%);
}

.ext-card.status-offline {
    border-top-color: var(--status-offline);
    opacity: 0.8;
}

/* Cabeçalho do Card */
.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
}

.ext-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ext-number-badge {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1.05rem;
    font-weight: 800;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    flex-shrink: 0;
}

.status-free .ext-number-badge {
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.12);
}

.status-ringing .ext-number-badge {
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.18);
}

.status-busy .ext-number-badge {
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.18);
}

.ext-info {
    min-width: 0;
}

.ext-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ext-sector {
    font-size: 0.76rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tag de Status */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.25rem 0.62rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.status-badge .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-free .status-badge {
    background: var(--status-free-bg);
    color: #34d399;
    border: 1px solid var(--status-free-border);
}
.status-free .status-dot { background: var(--status-free); }

.status-ringing .status-badge {
    background: var(--status-ringing-bg);
    color: #fbbf24;
    border: 1px solid var(--status-ringing-border);
}
.status-ringing .status-dot {
    background: var(--status-ringing);
    animation: pulseDot 0.7s infinite;
}

.status-busy .status-badge {
    background: var(--status-busy-bg);
    color: #f87171;
    border: 1px solid var(--status-busy-border);
}
.status-busy .status-dot { background: var(--status-busy); }

.status-offline .status-badge {
    background: var(--status-offline-bg);
    color: #94a3b8;
    border: 1px solid var(--status-offline-border);
}
.status-offline .status-dot { background: var(--status-offline); }

/* Corpo do Card (Detalhes de Chamada em Tempo Real) */
.card-call-box {
    background: rgba(11, 15, 25, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.8rem;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.call-peer-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.call-peer-label {
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.call-peer-value {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-timer {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.92rem;
    font-weight: 700;
    color: #f87171;
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.idle-placeholder {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

/* Rodapé de Ações do Card (Editar, Excluir, Simulador) */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-quick-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sim-btn {
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.68rem;
    padding: 0.2rem 0.42rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.sim-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.card-crud-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.icon-btn.delete:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
}

/* ============================================================================
 * MODAL CRUD (ADICIONAR / EDITAR RAMAL)
 * ============================================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 15, 0.75);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 460px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.modal-backdrop.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.68rem 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 1.4rem;
}

/* ============================================================================
 * TOAST NOTIFICATIONS & EMPTY STATE
 * ============================================================================ */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
}

.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.toast.error {
    border-left-color: var(--status-busy);
}

/* ============================================================================
 * ANIMAÇÕES
 * ============================================================================ */
@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.25); }
}

@keyframes ringingCardPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.08); }
}

@media (max-width: 768px) {
    .topbar { padding: 0.85rem 1rem; }
    .container { padding: 1rem; }
    .extensions-grid { grid-template-columns: 1fr; }
}

