/* ==========================================================================
   RC SYSTEM - DESIGN SYSTEM & UI THEME (v8.0 Enterprise)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap'); /* Para código */

:root {
    /* -- PALETA INSTITUCIONAL -- */
    --color-primary: #0a2342;       /* Navy Deep */
    --color-primary-dark: #041224;
    --color-accent: #00a8e8;        /* Cyan Tech */
    --color-accent-hover: #0092ca;
    --color-gold: #d4af37;          /* Gold Premium */

    /* -- NEUTROS -- */
    --color-bg-body: #f1f5f9;
    --color-bg-card: #ffffff;
    --color-text-main: #1e293b;
    --color-text-body: #475569;
    --color-border: #e2e8f0;
    --color-input-bg: #ffffff;

    /* -- STATUS -- */
    --color-success: #10b981; --bg-success: #d1fae5;
    --color-warning: #f59e0b; --bg-warning: #fef3c7;
    --color-error: #ef4444;   --bg-error: #fee2e2;

    /* -- DIMENSÕES -- */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 70px;
    --header-h: 64px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* ==========================================================================
   1. RESET & ESTRUTURA GLOBAL
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; outline: none; }

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-body);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Scroll gerenciado internamente */
}

/* Scrollbar Bonita */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

a { text-decoration: none; color: inherit; transition: 0.2s; cursor: pointer; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }

/* LAYOUT PRINCIPAL (FLEXBOX) */
.dashboard-wrapper { display: flex; width: 100%; height: 100%; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    background: var(--color-bg-body);
    position: relative;
}


/* ==========================================================================
   2. SIDEBAR & TOPBAR
   ========================================================================== */

/* Sidebar Container */
.sidebar {
    width: var(--sidebar-w-collapsed);
    height: 100%;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    display: flex; flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    flex-shrink: 0;
    color: white;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    white-space: nowrap;
}

/* Expansão (Hover ou Pinned) */
.sidebar:hover, .sidebar.is-pinned, .sidebar.is-expanded { width: var(--sidebar-w); }

/* Header Sidebar */
.sidebar-header {
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand-wrapper { opacity: 0; transition: 0.2s; font-weight: 700; letter-spacing: 0.5px; font-size: 1.1rem; }
.brand-wrapper span { color: var(--color-gold); }
.brand-icon-only { font-size: 1.5rem; color: var(--color-accent); position: absolute; left: 22px; transition: 0.2s; }

.pin-btn { color: #94a3b8; font-size: 0.9rem; opacity: 0; transition: 0.2s; background: none; border: none; }
.pin-btn:hover { color: white; }
.sidebar.is-pinned .pin-btn { color: var(--color-accent); transform: rotate(45deg); }

/* Exibe elementos quando expandido */
.sidebar:hover .brand-wrapper, .sidebar.is-pinned .brand-wrapper, .sidebar.is-expanded .brand-wrapper { opacity: 1; }
.sidebar:hover .brand-icon-only, .sidebar.is-pinned .brand-icon-only, .sidebar.is-expanded .brand-icon-only { opacity: 0; }
.sidebar:hover .pin-btn, .sidebar.is-pinned .pin-btn, .sidebar.is-expanded .pin-btn { opacity: 1; }

/* Menu */
.sidebar-menu { flex: 1; overflow-y: auto; padding: 1rem 0; overflow-x: hidden; }

.menu-category {
    font-size: 0.7rem; text-transform: uppercase; color: var(--color-gold);
    margin: 20px 0 5px 15px; opacity: 0; transition: 0.2s; letter-spacing: 1px; font-weight: 600;
}
.sidebar:hover .menu-category, .sidebar.is-pinned .menu-category, .sidebar.is-expanded .menu-category { opacity: 1; }

.menu-link {
    display: flex; align-items: center; padding: 0 14px; height: 46px;
    color: #cbd5e1; text-decoration: none; margin-bottom: 2px; transition: all 0.2s;
    position: relative; border-left: 3px solid transparent;
}
.menu-link i { min-width: 40px; text-align: center; font-size: 1.1rem; transition: 0.2s; }
.menu-text { opacity: 0; transition: 0.2s; font-weight: 500; margin-left: 5px; }

.sidebar:hover .menu-text, .sidebar.is-pinned .menu-text, .sidebar.is-expanded .menu-text { opacity: 1; }

.menu-link:hover { background: rgba(255,255,255,0.08); color: white; }
.menu-link:hover i { color: var(--color-accent); }

.menu-link.active { background: linear-gradient(90deg, rgba(0,168,232,0.15) 0%, transparent 100%); color: white; border-left-color: var(--color-accent); }
.menu-link.active i { color: var(--color-accent); }

.menu-link.master-item.active { border-left-color: var(--color-gold); background: linear-gradient(90deg, rgba(212,175,55,0.15) 0%, transparent 100%); }
.menu-link.master-item.active i { color: var(--color-gold); }

/* Footer (User) */
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); }
.user-profile-mini { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
.user-avatar-container { 
    width: 40px; height: 40px; background: rgba(255,255,255,0.1); border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; font-weight: bold; 
    border: 2px solid var(--color-accent); color: white; flex-shrink: 0;
}
.user-info { overflow: hidden; opacity: 0; transition: 0.2s; }
.sidebar:hover .user-info, .sidebar.is-pinned .user-info, .sidebar.is-expanded .user-info { opacity: 1; }
.user-name { font-size: 0.85rem; font-weight: 600; display: block; }
.user-role { font-size: 0.7rem; color: #94a3b8; }

/* Dropup Menu */
.user-dropup-menu {
    position: absolute; bottom: 110%; left: 10px; width: 200px;
    background: white; border-radius: var(--radius); box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    padding: 0.5rem 0; visibility: hidden; opacity: 0; transform: translateY(10px);
    transition: 0.2s; z-index: 100; color: var(--color-text-main); border: 1px solid var(--color-border);
}
.user-profile-mini:hover .user-dropup-menu, .user-dropup-menu.active { visibility: visible; opacity: 1; transform: translateY(0); }
.user-dropup-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--color-text-body); font-size: 0.9rem; }
.user-dropup-item:hover { background: #f8fafc; color: var(--color-accent); }
.user-dropup-divider { height: 1px; background: var(--color-border); margin: 5px 0; }

/* Topbar */
.topbar {
    height: var(--header-h); background: white; border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem;
    flex-shrink: 0; z-index: 40;
}
.topbar h3 { font-size: 1.1rem; font-weight: 600; color: var(--color-primary); }

/* ==========================================================================
   3. UI COMPONENTS (CARDS, INPUTS, BUTTONS)
   ========================================================================== */

.card {
    background: var(--color-bg-card); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm); position: relative;
}
.card h3 { color: var(--color-primary); font-size: 1.1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }

/* Inputs */
.form-label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--color-text-body); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input {
    width: 100%; padding: 0.6rem 0.8rem; font-size: 0.9rem;
    border: 1px solid var(--color-border); border-radius: var(--radius);
    background: #fff; color: var(--color-text-main); transition: 0.2s;
    font-family: inherit;
}
.form-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15); }
textarea.form-input { resize: vertical; line-height: 1.6; }

/* Botões */
.btn-primary {
    background: var(--color-accent); color: white; border: none;
    padding: 0.6rem 1.2rem; border-radius: var(--radius); font-weight: 600; font-size: 0.9rem;
    display: inline-flex; align-items: center; gap: 8px; transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0, 168, 232, 0.3);
}
.btn-primary:hover { background: var(--color-accent-hover); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0, 168, 232, 0.4); }

.btn-sm {
    padding: 0.4rem 0.8rem; font-size: 0.8rem; border-radius: 4px;
    border: 1px solid var(--color-border); background: white; color: var(--color-text-body);
    display: inline-flex; align-items: center; gap: 5px; transition: 0.2s; text-decoration: none;
}
.btn-sm:hover { border-color: #cbd5e1; background: #f8fafc; color: var(--color-primary); }

.btn-bio { /* Botão Grande de Ação */
    width: 100%; padding: 0.8rem; border: 1px solid var(--color-border);
    background: white; border-radius: var(--radius); font-weight: 600; color: var(--color-text-body);
    display: flex; align-items: center; justify-content: center; gap: 10px; transition: 0.2s;
}
.btn-bio:hover { border-color: var(--color-accent); color: var(--color-accent); background: #f0f9ff; }

/* Switch Checkbox */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--color-accent); }
input:checked + .slider:before { transform: translateX(18px); }

/* ==========================================================================
   4. TABELAS E LISTAS
   ========================================================================== */

.table-container {
    width: 100%; overflow-x: auto;
    background: white; border: 1px solid var(--color-border); border-radius: var(--radius);
}
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table thead th {
    background: #f8fafc; color: var(--color-text-main); padding: 0.8rem 1rem;
    text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border); font-weight: 700;
    position: sticky; top: 0; z-index: 10; /* Header Fixo */
}
.data-table td {
    padding: 0.8rem 1rem; border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem; color: var(--color-text-body); vertical-align: middle;
}
.data-table tr:hover td { background: #fcfcfc; }

/* ==========================================================================
   5. WORKSPACES (TR-069, Presets, Provisions, VPs)
   Layout fixo com scroll interno para tabelas grandes
   ========================================================================== */

/* Classes unificadas para todos os módulos */
.vp-workspace, .preset-workspace, .prov-workspace, .cpe-workspace {
    display: flex; flex-direction: column;
    height: calc(100vh - 130px); /* Altura da tela menos header/padding */
    gap: 1rem;
}

/* Barra de Ferramentas Fixa */
.vp-toolbar, .preset-toolbar, .prov-toolbar, .cpe-toolbar {
    flex-shrink: 0; background: white; padding: 1rem; 
    border-radius: var(--radius); border: 1px solid var(--color-border);
}

/* Wrapper da Tabela que ocupa o espaço restante */
.vp-table-wrapper, .preset-table-wrapper, .prov-table-wrapper, .cpe-table-wrapper {
    flex-grow: 1; background: white; 
    border-radius: var(--radius); border: 1px solid var(--color-border); 
    display: flex; flex-direction: column; overflow: hidden; position: relative;
}

/* Área que rola efetivamente */
.vp-scroll-area, .preset-scroll-area, .prov-scroll-area, .cpe-scroll-area {
    flex-grow: 1; overflow: auto;
}

/* Rodapé fixo da tabela */
.vp-footer, .preset-footer, .prov-footer, .cpe-footer {
    flex-shrink: 0; border-top: 1px solid var(--color-border); 
    padding: 0.8rem 1.5rem; background: #fff;
}

/* Formulários com Scroll (Quando o form é muito longo) */
.form-scroll-area {
    height: calc(100vh - 140px);
    overflow-y: auto; overflow-x: hidden;
    padding-right: 10px; padding-bottom: 2rem;
}

/* ==========================================================================
   6. ELEMENTOS ESPECÍFICOS (Abas, Diagnóstico, Diff)
   ========================================================================== */

/* Abas */
.tabs { display: flex; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; gap: 20px; overflow-x: auto; }
.tab-btn {
    padding: 10px 5px; font-weight: 500; color: #94a3b8; cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.2s; font-size: 0.95rem;
    white-space: nowrap; display: flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-accent); font-weight: 600; }
.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }

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

/* Diagnóstico Visual (CPE) */
.lan-status-container { display: flex; gap: 10px; justify-content: center; background: #f8fafc; padding: 15px; border-radius: 8px; }
.lan-port { 
    width: 50px; height: 40px; background: #fff; border: 2px solid #cbd5e0; 
    border-radius: 4px; position: relative; display: flex; align-items: center; 
    justify-content: center; font-size: 0.75rem; font-weight: bold; color: #94a3b8; 
}
.lan-port.active-100 { border-color: #f59e0b; color: #b45309; background: #fffbeb; }
.lan-port.active-1000 { border-color: #10b981; color: #047857; background: #ecfdf5; }
.lan-led { width: 8px; height: 4px; background: #cbd5e0; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); border-radius: 2px; }
.lan-port.active-100 .lan-led { background: #f59e0b; box-shadow: 0 0 5px #f59e0b; }
.lan-port.active-1000 .lan-led { background: #10b981; box-shadow: 0 0 5px #10b981; }

/* Diff Viewer (Git Style) */
.git-diff-table { 
    width: 100%; border-collapse: collapse; font-family: 'Fira Code', monospace; 
    font-size: 0.85rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; 
}
.git-diff-table td { padding: 2px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; white-space: pre-wrap; }
.diff-del { background-color: #ffebe9; color: #24292e; }
.diff-add { background-color: #e6ffed; color: #24292e; }
.diff-empty { background-color: #f6f8fa; opacity: 0.5; }
.diff-marker { display: inline-block; width: 15px; color: #999; user-select: none; }

/* Login Específico */
.login-container { display: flex; height: 100vh; width: 100%; overflow: hidden; }
.brand-side { flex: 1; background: var(--color-primary); display: flex; align-items: center; justify-content: center; color: white; }
.login-side { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--color-bg-body); overflow-y: auto; }

/* Grid Helpers */
.grid-gap { display: grid; gap: 1.5rem; width: 100%; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Responsividade */
@media (max-width: 768px) {
    .brand-side { display: none; }
    .sidebar { position: fixed; left: -100%; }
    .sidebar.mobile-open { left: 0; }
    .content-body { padding: 1rem; }
    .form-scroll-area { height: calc(100vh - 120px); }
}
/* --- CORREÇÃO DE FORMULÁRIOS E SWITCHES --- */

/* Container para alinhar Switch + Texto perfeitamente */
.toggle-row {
    display: flex;
    align-items: center; /* Centraliza verticalmente */
    gap: 12px;           /* Espaço entre o switch e o texto */
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-row span {
    font-size: 0.9rem;
    color: var(--color-text-main);
    font-weight: 500;
}

/* Ajuste fino no Switch para ele não quebrar layout */
.switch {
    flex-shrink: 0; /* Impede que o switch seja esmagado */
}

/* Melhoria nos Botões dentro de Cards */
.card button {
    margin-top: 5px; /* Garante um respiro mínimo */
}

.form-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--color-border);
    text-align: right;
}

/* Labels de seção dentro do card */
.section-label {
    font-size: 0.85rem;
    color: var(--color-accent);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: block;
    letter-spacing: 0.5px;
}
/* Ações na Tabela CPE */
.action-grid { display: flex; gap: 5px; justify-content: flex-end; }
.btn-icon-action {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--color-border); border-radius: 6px; color: #64748b; transition: 0.2s;
    background: white;
}
.btn-icon-action:hover { transform: translateY(-2px); }

/* Cores específicas por função */
.act-wifi:hover { border-color: #0ea5e9; color: #0ea5e9; background: #f0f9ff; }
.act-wan:hover { border-color: #8b5cf6; color: #8b5cf6; background: #f5f3ff; }
.act-lan:hover { border-color: #f59e0b; color: #f59e0b; background: #fffbeb; }
.act-tool:hover { border-color: #10b981; color: #10b981; background: #ecfdf5; }