/*
NEXUS v4 — R2 Telecomunicações
Menu: Produção ETA | Sub-menus: Produção Online, Timing, Pendências, Supervisores, B2B
Filtros compartilhados: Geral / BA / TT
*/

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

:root {
    --sidebar-bg: #1F2326;
    --sidebar-footer: #181b1e;
    --sidebar-border: rgba(255,255,255,0.05);
    --sidebar-w: 256px;
    --sidebar-w-collapsed: 80px;
    --r2-active: #940910;
    --r2-hover: #7a060c;
    --r2-yellow: #F6B700;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --text-dark: #404040;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: rgba(255,255,255,0.5);
    --c-ok: #16a34a;
    --c-danger: #dc2626;
    --c-warn: #ea580c;
    --c-info: #2563eb;
    --c-purple: #7c3aed;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-active: 0 4px 12px rgba(148,9,16,0.2);
    --radius: 10px;
    --radius-sm: 8px;
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); min-height: 100vh; -webkit-font-smoothing: antialiased; display: flex; }

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-w); height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column;
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transition: width 0.3s ease;
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; color: #fff; cursor: pointer;
    padding: 4px; border-radius: 50%; display: none; z-index: 10;
}
.sidebar-close:hover { background: rgba(255,255,255,0.1); }
.sidebar-close svg { width: 20px; height: 20px; }

.sidebar-collapse-btn {
    position: absolute; top: 24px; right: -14px;
    width: 28px; height: 28px;
    background: var(--r2-active); color: #fff;
    border: none; border-radius: 50%; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(148,9,16,0.3); z-index: 210;
    transition: background 0.15s;
}
.sidebar-collapse-btn:hover { background: var(--r2-hover); }
.sidebar-collapse-btn svg { width: 16px; height: 16px; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-wrap {
    background: #fff; padding: 6px; border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo { height: 28px; width: auto; }
.sidebar-brand-text { overflow: hidden; white-space: nowrap; }
.sidebar-title { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.3px; line-height: 1.1; }
.sidebar-subtitle { font-size: 9px; color: var(--text-sidebar); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 3px; }
.sidebar.collapsed .sidebar-brand-text { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 24px 8px 20px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: rgba(255,255,255,0.45);
    font-family: var(--font); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; text-align: left; width: 100%; white-space: nowrap;
}
.sidebar-item svg { width: 20px; height: 20px; stroke-width: 1.8; flex-shrink: 0; }
.sidebar-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-item.active { background: var(--r2-active); color: #fff; font-weight: 700; box-shadow: var(--shadow-active); }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-item span { display: none; }

.sidebar-footer {
    padding: 16px; border-top: 1px solid var(--sidebar-border); background: var(--sidebar-footer);
}
.sidebar-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-sidebar); margin-bottom: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4CAF50; animation: pulse 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s; }
.sidebar-user:hover { background: rgba(255,255,255,0.05); }
.sidebar-user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--r2-active);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px; color: #fff;
    border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.1); flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 700; color: #fff; }
.sidebar-user-role { font-size: 10px; font-weight: 700; color: var(--r2-yellow); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-status span { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sidebar.collapsed .sidebar-user { padding: 0; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; }
.sidebar-overlay.visible { display: block; }

/* ====== MOBILE TOPBAR ====== */
.topbar-mobile {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    height: 56px; background: var(--r2-active);
    align-items: center; padding: 0 16px; z-index: 100;
    box-shadow: 0 2px 8px rgba(148,9,16,0.3);
}
.hamburger { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }
.hamburger svg { width: 24px; height: 24px; }
.topbar-title { flex: 1; margin-left: 12px; font-size: 17px; font-weight: 800; color: #fff; }
.topbar-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: rgba(255,255,255,0.75); }

/* ====== MAIN ====== */
.main-wrapper {
    margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.main-wrapper.shifted { margin-left: var(--sidebar-w-collapsed); }

/* Page header */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 24px 32px 0;
}
.page-title { font-size: 24px; font-weight: 800; color: var(--text-dark); letter-spacing: -0.3px; }
.page-date {
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    background: #fff; padding: 6px 14px; border-radius: 20px;
    border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,0.04); white-space: nowrap;
}

/* Sub-tabs */
.sub-tabs {
    display: flex; gap: 0; padding: 16px 32px 0;
    border-bottom: 2px solid var(--border);
}
.sub-tab {
    padding: 10px 22px; border: none; background: none;
    color: var(--text-muted); font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.sub-tab:hover { color: var(--text-secondary); }
.sub-tab.active { color: var(--r2-active); border-bottom-color: var(--r2-active); font-weight: 700; }

/* Filters bar */
.filters-bar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 32px; background: #fff;
    border-bottom: 1px solid var(--border);
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-right: 4px; }
.filter-btn {
    padding: 6px 16px; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; color: var(--text-secondary);
    font-family: var(--font); font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--r2-active); color: var(--r2-active); }
.filter-btn.active {
    background: var(--r2-active); color: #fff;
    border-color: var(--r2-active);
    box-shadow: 0 2px 6px rgba(148,9,16,0.25);
}

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

.panel-body { padding: 24px 32px 32px; max-width: 1100px; }

/* ====== METRIC CARDS ====== */
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.metric-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 18px;
    border: 1px solid var(--border); box-shadow: var(--shadow);
    transition: box-shadow 0.2s; border-left: 4px solid transparent;
}
.metric-card:hover { box-shadow: var(--shadow-lg); }
.metric-card[data-color="green"] { border-left-color: var(--c-ok); }
.metric-card[data-color="red"] { border-left-color: var(--c-danger); }
.metric-card[data-color="yellow"] { border-left-color: var(--c-warn); }
.metric-card[data-color="blue"] { border-left-color: var(--c-info); }
.metric-card[data-color="bordo"] { border-left-color: var(--r2-active); }

.metric-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.metric-value { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; font-family: var(--mono); }
.metric-value.green { color: var(--c-ok); }
.metric-value.red { color: var(--c-danger); }
.metric-value.yellow { color: var(--c-warn); }
.metric-value.blue { color: var(--c-info); }
.metric-value.purple { color: var(--c-purple); }
.metric-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ====== HIGHLIGHT CARD ====== */
.highlight-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 20px;
    margin-bottom: 20px; border: 1px solid var(--border); box-shadow: var(--shadow);
    border-left: 4px solid var(--r2-active);
}
.highlight-card .card-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 12px; }
.progress-bar { width: 100%; height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease-out; }
.progress-fill.green { background: var(--c-ok); }

/* ====== TABLES ====== */
.data-table { width: 100%; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow); }
.data-table .table-header { display: grid; padding: 11px 18px; font-size: 10px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.5px; background: var(--r2-active); }
.data-table .table-row { display: grid; padding: 11px 18px; font-size: 13px; border-bottom: 1px solid #f1f5f9; align-items: center; transition: background 0.1s; }
.data-table .table-row:last-child { border-bottom: none; }
.data-table .table-row:nth-child(even) { background: #f8fafc; }
.data-table .table-row:hover { background: #f1f5f9; }

.table-filial .table-header, .table-filial .table-row { grid-template-columns: 1.5fr repeat(4, 1fr); gap: 6px; text-align: right; }
.table-filial .table-header>:first-child, .table-filial .table-row>:first-child { text-align: left; }
.table-supervisor .table-header, .table-supervisor .table-row { grid-template-columns: 2fr repeat(3, 1fr); gap: 6px; text-align: right; }
.table-supervisor .table-header>:first-child, .table-supervisor .table-row>:first-child { text-align: left; }
.table-pendencias .table-header, .table-pendencias .table-row { grid-template-columns: 2fr 1fr 1fr; gap: 6px; text-align: right; }
.table-pendencias .table-header>:first-child, .table-pendencias .table-row>:first-child { text-align: left; }

.val-green { color: var(--c-ok); font-weight: 700; }
.val-red { color: var(--c-danger); font-weight: 700; }
.val-yellow { color: var(--c-warn); font-weight: 700; }
.val-blue { color: var(--c-info); font-weight: 700; }
.val-bold { font-weight: 700; color: var(--text-primary); }

/* ====== TIMING BAR ====== */
.timing-bar { display: flex; width: 100%; height: 36px; border-radius: 8px; overflow: hidden; margin: 8px 0; }
.timing-bar > div { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; transition: width 0.6s ease-out; min-width: 0; }
.timing-antes { background: var(--c-info); }
.timing-no-prazo { background: var(--c-ok); }
.timing-risco { background: var(--r2-yellow); color: #000 !important; }
.timing-fora { background: var(--c-danger); }
.timing-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.timing-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.timing-legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ====== MISC ====== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.loading::before { content: ''; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--r2-active); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-dark); margin-bottom: 12px; }
.last-update { text-align: center; font-size: 11px; color: var(--text-muted); padding: 20px 32px; }

/* ====== RESPONSIVE ====== */
@media (min-width: 769px) { .sidebar-collapse-btn { display: flex; } }

@media (max-width: 768px) {
    .sidebar { position: fixed; transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .topbar-mobile { display: flex; }
    .main-wrapper { margin-left: 0 !important; padding-top: 56px; }
    .page-header { padding: 16px 16px 0; flex-direction: column; align-items: flex-start; gap: 8px; }
    .sub-tabs { padding: 12px 16px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sub-tabs::-webkit-scrollbar { display: none; }
    .filters-bar { padding: 12px 16px; flex-wrap: wrap; }
    .panel-body { padding: 16px; }
    .page-title { font-size: 20px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .last-update { padding: 16px; }
    .metric-value { font-size: 24px; }
}

@media (min-width: 769px) and (max-width: 1100px) { .metrics-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1101px) { .metrics-grid { grid-template-columns: repeat(4, 1fr); } }
