/* ============================================================
   NAD — Network Analytics Dashboard | RC7Networks
   app.css — Estilos globais e componentes compartilhados
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
    --primary-dark:    #0f172a;
    --secondary-dark:  #1e293b;
    --accent-blue:     #3b82f6;
    --accent-orange:   #f97316;
    --accent-red:      #ef4444;
    --accent-green:    #10b981;
    --accent-yellow:   #eab308;
    --accent-purple:   #8b5cf6;
    --text-primary:    #f8fafc;
    --text-secondary:  #cbd5e1;
    --border-subtle:   rgba(71, 85, 105, 0.3);
    --card-bg:         rgba(30, 41, 59, 0.8);
    --card-bg-deep:    rgba(15, 23, 42, 0.9);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Syne', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0f1f;
    color: var(--text-primary);
}

/* ── Cards ──────────────────────────────────────────────────── */
.dashboard-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-card:hover {
    border-color: rgba(59, 130, 246, 0.45);
    box-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.5);
}

.metric-card,
.alerta-card,
.recente-card,
.exato-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, var(--card-bg-deep) 100%);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before,
.alerta-card::before,
.recente-card::before,
.exato-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
}

.metric-card:hover,
.alerta-card:hover,
.recente-card:hover,
.exato-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.45);
}

.metric-card.ativo,
.alerta-card.ativo,
.recente-card.ativo,
.exato-card.ativo {
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 22px rgba(59, 130, 246, 0.35);
}

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}

.btn-blue {
    background: #2563eb;
    color: #fff;
}
.btn-blue:hover {
    background: #1d4ed8;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-gray {
    background: #374151;
    color: #e2e8f0;
}
.btn-gray:hover {
    background: #4b5563;
    color: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #1d4ed8 100%);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background: rgba(71, 85, 105, 0.35);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 500;
    border: 1px solid rgba(71, 85, 105, 0.4);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(71, 85, 105, 0.55);
    color: var(--text-primary);
}

/* ── Selects / Inputs ───────────────────────────────────────── */
.filter-select {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 10px;
    transition: border-color 0.2s ease;
    appearance: auto;
}

.filter-select:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success  { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning  { background: rgba(245, 158, 11, 0.2);  color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger   { background: rgba(239, 68, 68, 0.2);   color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info     { background: rgba(59, 130, 246, 0.2);  color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-neutral  { background: rgba(71, 85, 105, 0.2);   color: #94a3b8; border: 1px solid rgba(71, 85, 105, 0.3); }
.badge-purple   { background: rgba(139, 92, 246, 0.2);  color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }

/* Badges de desconexão */
.badge-alerta { background: rgba(249, 115, 22, 0.2);  color: #fb923c; padding: 3px 10px; border-radius: 12px; font-size: 0.8rem; }
.badge-recente { background: rgba(234, 179, 8, 0.2);   color: #fbbf24; padding: 3px 10px; border-radius: 12px; font-size: 0.8rem; }
.badge-exato  { background: rgba(96, 165, 250, 0.2);  color: #93c5fd; padding: 3px 10px; border-radius: 12px; font-size: 0.8rem; }

/* ── Linhas de tabela ───────────────────────────────────────── */
.cliente-row {
    background: rgba(30, 41, 59, 0.7);
    border-left: 4px solid transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cliente-row:hover {
    background: rgba(30, 41, 59, 0.9);
    transform: translateX(4px);
}

.cliente-row.alerta  { border-left-color: #f97316; }
.cliente-row.recente { border-left-color: #eab308; }
.cliente-row.exato   { border-left-color: #60a5fa; }

/* ── Loader ─────────────────────────────────────────────────── */
.loader-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 12px;
}

.loader {
    border: 3px solid rgba(59, 130, 246, 0.25);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    width: 44px;
    height: 44px;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}

.loader-sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 16px;
    max-width: 800px;
    width: 92%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.7);
}

.modal-content.modal-lg { max-width: 1200px; }

/* ── Mapa ───────────────────────────────────────────────────── */
.map-container {
    height: 400px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

/* ── Status dots ────────────────────────────────────────────── */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
}

.status-active   { background: var(--accent-green); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.status-inactive { background: #6b7280; }
.status-warning  { background: var(--accent-yellow); box-shadow: 0 0 8px rgba(234, 179, 8, 0.5); animation: pulse-dot 1.5s infinite; }
.status-danger   { background: var(--accent-red); box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); animation: pulse-dot 1.5s infinite; }

/* ── Logo ───────────────────────────────────────────────────── */
.logo-img {
    max-height: 50px;
    max-width: 160px;
    object-fit: contain;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
.scrollbar-custom {
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.4) rgba(30, 41, 59, 0.3);
}

.scrollbar-custom::-webkit-scrollbar { width: 6px; }
.scrollbar-custom::-webkit-scrollbar-track { background: rgba(30, 41, 59, 0.3); border-radius: 3px; }
.scrollbar-custom::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.4); border-radius: 3px; }

/* ── Indicador SSE ──────────────────────────────────────────── */
.sse-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
}

.sse-status.connected    { background: rgba(16,185,129,0.15); color: #10b981; }
.sse-status.connecting   { background: rgba(234,179,8,0.15);  color: #eab308; }
.sse-status.disconnected { background: rgba(239,68,68,0.15);  color: #ef4444; }

.sse-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.sse-status.connected  .sse-dot { animation: pulse-dot 2s infinite; }
.sse-status.connecting .sse-dot { animation: spin-dot 1s linear infinite; }

/* ── Animações ──────────────────────────────────────────────── */
.fade-in {
    animation: fadeIn 0.45s ease-in both;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes spin-dot {
    to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.animate-slide-in { animation: slideIn 0.3s ease-out; }

/* ── Toast de alerta ────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 50000;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    max-width: 22rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.toast-success { background: rgba(15, 23, 42, 0.97); border: 1px solid rgba(16,185,129,0.5); }
.toast-error   { background: rgba(15, 23, 42, 0.97); border: 1px solid rgba(239,68,68,0.5); }
.toast-warning { background: rgba(15, 23, 42, 0.97); border: 1px solid rgba(234,179,8,0.5); }
.toast-info    { background: rgba(15, 23, 42, 0.97); border: 1px solid rgba(59,130,246,0.5); }

/* ── Card (pages financeiro / técnicos / estoque / OS) ──────── */
.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
    font-weight: 600;
    color: #f1f5f9;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

/* ── Abas ───────────────────────────────────────────────────── */
.tab { padding: 8px 16px; border-radius: 8px; font-weight: 500; transition: background 0.2s, color 0.2s; cursor: pointer; }
.tab-active   { background: var(--accent-blue); color: #fff; }
.tab-inactive { color: #94a3b8; }
.tab-inactive:hover { background: #2d3a4f; color: #fff; }

/* ── Input de filtro (pages específicas) ────────────────────── */
.filter-input {
    background: var(--primary-dark);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    transition: border-color 0.2s;
}
.filter-input:focus { outline: none; border-color: var(--accent-blue); }

/* ── Barra de progresso ─────────────────────────────────────── */
.progress-bar { height: 4px; background: #334155; border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent-blue); transition: width 0.3s ease; }

/* ── Filtro de status (pílulas) ─────────────────────────────── */
.status-filtro {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.875rem;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.status-filtro.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.status-filtro:hover  { background: #2d3a4f; color: #fff; }

/* ── Período card ───────────────────────────────────────────── */
.periodo-card {
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    border-left: 4px solid transparent;
}
.periodo-card:hover  { transform: translateY(-2px); border-left-color: var(--accent-blue); }
.periodo-card.active { border-left-color: var(--accent-blue); background: #2d3a4f; }

/* ── Tabela padrão ──────────────────────────────────────────── */
.nad-table { width: 100%; border-collapse: collapse; }
.nad-table th {
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid #334155;
    user-select: none;
}
.nad-table th:hover { background: #2d3a4f; color: #fff; }
.nad-table td { padding: 12px 16px; border-bottom: 1px solid #334155; color: #e2e8f0; font-size: 0.875rem; }
.nad-table tr:hover td { background: #2d3a4f; }

/* ── Utilidades ─────────────────────────────────────────────── */
.text-mono { font-family: 'IBM Plex Mono', monospace; }
.truncate-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
