:root {
    --bg-base: #0a0e14;
    --bg-surface: #141b26;
    --bg-surface-hover: #1c2533;
    --bg-card: rgba(20, 27, 38, 0.7);
    --bg-input: #0d121a;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    
    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.1);
    --color-warning: #f59e0b;
    
    --sidebar-width: 250px;
    --topbar-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- VARIANTES DE TEMA --- */
body.theme-ocean {
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --color-primary: #0ea5e9;
    --color-primary-hover: #38bdf8;
}

body.theme-emerald {
    --bg-base: #064e3b;
    --bg-surface: #065f46;
    --bg-surface-hover: #047857;
    --color-primary: #10b981;
    --color-primary-hover: #34d399;
}

body.theme-midnight {
    --bg-base: #000000;
    --bg-surface: #111111;
    --bg-surface-hover: #222222;
    --color-primary: #ffffff;
    --color-primary-hover: #cccccc;
    --text-primary: #ffffff;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: auto;
    height: auto;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.brand-icon img {
    max-width: 140px;
    max-height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.4)) brightness(1.2);
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    display: block;
}

.brand-version {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 5px;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background: var(--bg-surface-hover);
    color: white;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--color-primary-hover);
    border-left: 3px solid var(--color-primary);
}

.logout-btn {
    margin-top: auto;
    color: var(--color-danger);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0; /* Impede que o conteúdo estique a flexbox */
}

.main-content.full-width {
    margin-left: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: rgba(10, 14, 20, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 10px;
    margin-left: -10px;
}

.page-title {
    font-weight: 700;
}

.topbar-time {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Page Content */
.page-content {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 992px) {
    .page-content { padding: 20px; }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.card-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    border-color: white;
    color: white;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* Flash Messages */
.flash-container {
    padding: 16px 32px 0;
}

.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); }

/* Custom */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.status-dot.online {
    background: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.status-dot.offline {
    background: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

/* Modais e Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 95%;
    max-width: 600px;
    max-height: 90vh; /* Não ultrapassa 90% da altura da tela */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s ease;
    overflow: hidden; /* O scroll será no body */
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body { 
    padding: 24px;
    overflow-y: auto; /* Scroll interno se o conteúdo for longo */
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(0,0,0,0.1);
}

/* Forms no Modal */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.folder-selector-group { display: flex; gap: 10px; }
.folder-browser-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.browser-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.browser-item:hover { background: var(--bg-surface-hover); }

.hidden { display: none !important; }

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .page-title {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .topbar-time {
        display: none;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .modal {
        width: 95%;
        margin: 10px;
    }
    
    .form-row-dual {
        flex-direction: column;
        gap: 0;
    }
}

/* Overlay para fechar menu ao clicar fora no mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    display: none;
}
.sidebar-overlay.active {
    display: block;
}
