/* ==========================================================================
   RC SYSTEM - DESIGN SYSTEM (Visual Original + Funcionalidade Nova)
   ========================================================================== */

@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');

:root {
    /* -- PALETA INSTITUCIONAL (ORIGINAL) -- */
    --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 & GERAL
   ========================================================================== */
* { 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;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* 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; }

/* Wrapper Principal */
.main-content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg-body);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Ajuste quando Sidebar Fechada */
body.sidebar-closed .main-content {
    margin-left: var(--sidebar-w-collapsed);
    width: calc(100% - var(--sidebar-w-collapsed));
}

/* ==========================================================================
   2. SIDEBAR (VISUAL ORIGINAL + LÓGICA NOVA)
   ========================================================================== */

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    /* Degradê Original */
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow-x: hidden;
}

/* --- Estado Recolhido (.collapsed) --- */
.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
}

.sidebar.collapsed .menu-text, 
.sidebar.collapsed .menu-category, 
.sidebar.collapsed .brand-wrapper,
.sidebar.collapsed .user-info,
.sidebar.collapsed .fa-chevron-up {
    display: none !important;
    opacity: 0;
}

.sidebar.collapsed .menu-link { justify-content: center; padding: 0; }
.sidebar.collapsed .menu-link i { margin-right: 0; font-size: 1.2rem; }

/* Ícone da marca quando fechado */
.sidebar.collapsed .brand-icon-only { 
    display: block; font-size: 1.5rem; margin: 0 auto; color: var(--color-accent); 
}
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }

/* Botão de Toggle quando fechado */
.sidebar.collapsed #toggleSidebar { 
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); 
}

/* --- Elementos Internos --- */

/* Header */
.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); /* Borda transparente original */
    flex-shrink: 0;
}

.brand-wrapper { font-size: 1.1rem; font-weight: 700; color: white; letter-spacing: 0.5px; }
.brand-wrapper span { color: var(--color-gold); margin-left: 8px; } /* Texto Dourado */
.brand-icon-only { display: none; }

#toggleSidebar {
    background: none; border: none; color: #94a3b8; font-size: 1.1rem; padding: 5px; transition: 0.2s;
}
#toggleSidebar:hover { color: white; }

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

/* Labels */
.menu-category, .nav-label {
    font-size: 0.7rem; text-transform: uppercase; color: var(--color-gold); /* Dourado original */
    margin: 20px 0 5px 15px; letter-spacing: 1px; font-weight: 600;
    white-space: nowrap;
}

/* Links */
.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;
}

/* Hover: Fundo Transparente Branco */
.menu-link:hover { 
    background: rgba(255,255,255,0.08); 
    color: white; 
}
.menu-link:hover i { color: var(--color-accent); }

/* Active: Gradiente Azul + Borda Azul */
.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); }

/* Ícones */
.menu-link i { 
    min-width: 40px; text-align: center; font-size: 1.1rem; transition: 0.2s; 
}

/* Footer / Perfil */
.sidebar-footer {
    padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); 
    background: rgba(0,0,0,0.2); /* Fundo escurecido original */
}
.user-profile-mini { display: flex; align-items: center; gap: 10px; cursor: pointer; }

/* ==========================================================================
   3. OUTROS COMPONENTES DO SISTEMA
   ========================================================================== */

/* 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); }

/* Cards */
.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); }

/* 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); }

.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; cursor: pointer;
}
.btn-sm:hover { border-color: #cbd5e1; background: #f8fafc; color: var(--color-primary); }

/* Switch Toggle (Preservado) */
.toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; cursor: pointer; user-select: none; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.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); }

/* Tabelas */
.table-container { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.list-table, .data-table, .mini-table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 0.9rem; }
.list-table th, .data-table th, .mini-table th {
    background: #f8fafc; color: var(--color-text-body); padding: 12px 15px; text-align: left;
    font-weight: 600; border-bottom: 1px solid var(--color-border); text-transform: uppercase; font-size: 0.75rem;
}
.list-table td, .data-table td, .mini-table td { padding: 12px 15px; border-bottom: 1px solid #f1f5f9; color: var(--color-text-main); }
.list-table tr:hover td { background: #fcfcfc; }

/* Badges de Tipo (Para Settings) */
.badge-type { padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; text-transform: uppercase; }
.type-ipv4 { background: #dbeafe; color: #1e40af; }
.type-ipv6 { background: #fce7f3; color: #9d174d; }
.type-url { background: #d1fae5; color: #065f46; }

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

/* Responsividade */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .sidebar.mobile-open { transform: translateX(0); }
    #toggleSidebar { display: none; }
}