/* ========== VARIABLES ========== */
:root {
    --primary: #e4691f;
    --primary-hover: #c6570f;
    --primary-light: #fce4d2;
    --accent-blue: #1e4c9b;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #f59e0b;
    --dark: #081329;
    --dark-2: #13224a;
    --gray: #64748b;
    --gray-light: #f1f5f9;
    --gray-border: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --sidebar-width: 250px;
}

/* ========== RESET ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-light);
    color: var(--dark);
    line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ========== PAGES ========== */
.page { display: none; }
.page.active { display: flex; min-height: 100vh; }

/* ========== LOGIN ========== */
#login-page {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at top, #0f1f42 0%, var(--dark) 60%);
}
.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(6px);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { width: 110px; height: auto; margin-bottom: 0.5rem; }
.login-header h1 { font-size: 2.1rem; font-weight: 700; color: var(--primary); letter-spacing: 0.5px; }
.login-header p { color: #94a3c9; margin-top: 0.25rem; }
.login-card .form-group label { color: #cbd5e1; }
.login-card .form-group input {
    background: rgba(255,255,255,0.95); border: 1px solid rgba(255,255,255,0.15);
}
.login-card .btn-link { color: #94a3c9; }
.login-card .btn-link:hover { color: var(--primary); }
.twofa-info { color: #94a3c9; margin-bottom: 1rem; font-size: 0.9rem; }
.twofa-methods { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.twofa-method-btn {
    flex: 1; padding: 0.5rem; border: 2px solid rgba(255,255,255,0.15);
    background: transparent; color: var(--white); cursor: pointer; border-radius: var(--radius);
    font-size: 0.85rem; transition: all 0.2s;
}
.twofa-method-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(228,105,31,0.12); }
.dev-code {
    background: #fef3c7; border: 1px solid var(--warning); color: #78350f;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    margin-bottom: 1rem; font-size: 0.85rem;
}

/* ========== FORMS ========== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--dark-2); }
.form-group input,
.form-group select,
.form-group textarea,
.form-control {
    width: 100%; padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-border); border-radius: var(--radius);
    font-size: 0.95rem; transition: border 0.2s;
    background: var(--white);
}
.form-group input:focus,
.form-group select:focus,
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
    padding: 0.55rem 1.2rem; border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-border); color: var(--dark); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-outline { background: transparent; border: 1px solid var(--gray-border); }
.btn-link { background: none; color: var(--gray); }
.btn-link:hover { color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ========== BADGE ========== */
.badge {
    display: inline-block; padding: 0.15rem 0.6rem;
    border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.badge-active { background: #dcfce7; color: var(--success); }
.badge-inactive { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge { background: var(--primary-light); color: var(--primary); }

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width); height: 100vh;
    background: var(--dark); color: var(--white);
    display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0; z-index: 100;
    transition: transform 0.3s;
    overflow-y: auto;
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 1rem; border-bottom: 1px solid var(--dark-2);
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; }
.sidebar-logo { width: 32px; height: 32px; object-fit: contain; }
.sidebar-header h2 { font-size: 1.3rem; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--white); font-size: 1.5rem; cursor: pointer; }
.sidebar-menu { padding: 0.5rem 0; flex: 1; }
.menu-item {
    display: flex; align-items: center; gap: 0.8rem;
    padding: 0.8rem 1.2rem; color: #94a3b8;
    transition: all 0.2s; font-size: 0.95rem;
}
.menu-item:hover { background: var(--dark-2); color: var(--white); }
.menu-item.active { background: var(--primary); color: var(--white); }
.menu-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column;
}

/* ========== TOPBAR ========== */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.8rem 1.5rem;
    background: var(--white); border-bottom: 1px solid var(--gray-border);
    box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50;
}
.topbar-info { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.menu-btn { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--dark); }

/* ========== SECTIONS ========== */
.section { display: none; padding: 1.5rem; }
.section.active { display: block; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.section-header h2 { font-size: 1.4rem; }

/* ========== TABLES ========== */
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse;
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.data-table thead { background: var(--dark); color: var(--white); }
.data-table th {
    padding: 0.75rem 1rem; text-align: left;
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table td {
    padding: 0.65rem 1rem; border-bottom: 1px solid var(--gray-border);
    font-size: 0.9rem;
}
.data-table tbody tr:hover { background: var(--gray-light); }
.data-table .actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* ========== MODAL ========== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    justify-content: center; align-items: center; padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white); border-radius: var(--radius);
    width: 100%; max-width: 550px;
    box-shadow: var(--shadow-lg); animation: modalIn 0.2s;
}
.modal-sm { max-width: 400px; }
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--gray-border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray); }
.modal-body { padding: 1.5rem; max-height: 60vh; overflow-y: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    padding: 1rem 1.5rem; border-top: 1px solid var(--gray-border);
}

/* ========== TOAST ========== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.8rem 1.2rem; border-radius: var(--radius);
    color: var(--white); font-size: 0.9rem; min-width: 280px;
    box-shadow: var(--shadow-lg); animation: toastIn 0.3s;
    display: flex; align-items: center; justify-content: space-between;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-close { background: none; border: none; color: var(--white); font-size: 1.2rem; cursor: pointer; margin-left: 1rem; }

/* ========== GALLERY ========== */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.gallery-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.gallery-card img { width: 100%; height: 160px; object-fit: cover; display: block; }
.gallery-card-body { padding: 0.75rem; }
.gallery-card-title { font-weight: 600; margin-bottom: 0.25rem; }
.gallery-card-meta { font-size: 0.8rem; color: var(--gray); margin-bottom: 0.5rem; }

/* ========== REPORTS ========== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.stat-tile-label { font-size: 0.8rem; color: var(--gray); margin-bottom: 0.4rem; }
.stat-tile-value { font-size: 2rem; font-weight: 600; color: var(--dark); }
.report-panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.report-panel-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--dark); }
.bar-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.bar-row-label { width: 160px; flex-shrink: 0; font-size: 0.85rem; color: var(--dark-2); text-align: right; }
.bar-row-track { flex: 1; background: var(--gray-light); border-radius: 4px; height: 20px; position: relative; }
.bar-row-fill { background: var(--primary); height: 20px; max-height: 20px; border-radius: 0 4px 4px 0; }
.bar-row-value { width: 40px; flex-shrink: 0; font-size: 0.85rem; color: var(--dark); font-weight: 600; }
.report-empty { color: var(--gray); font-size: 0.9rem; }

/* ========== PERMISSIONS ========== */
.permissions-layout { background: var(--white); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.permissions-hint { color: var(--gray); margin-bottom: 1rem; font-size: 0.9rem; }
.permissions-grid { margin-top: 1rem; }
.perm-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 0.8rem; border: 1px solid var(--gray-border);
    border-radius: var(--radius); margin-bottom: 0.5rem; transition: background 0.2s;
}
.perm-item:hover { background: var(--gray-light); }
.perm-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.perm-item label { cursor: pointer; flex: 1; }
.perm-item .perm-url { color: var(--gray); font-size: 0.8rem; }

/* ========== LOGS FILTERS ========== */
.logs-filters {
    display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end;
    margin-bottom: 1.5rem; background: var(--white);
    padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow);
}
.logs-filters .form-group { flex: 1; min-width: 150px; margin-bottom: 0; }

/* ========== PAGINATION ========== */
.pagination {
    display: flex; justify-content: center; gap: 0.3rem;
    margin-top: 1rem; flex-wrap: wrap;
}
.pagination button {
    padding: 0.4rem 0.8rem; border: 1px solid var(--gray-border);
    background: var(--white); border-radius: var(--radius);
    cursor: pointer; font-size: 0.85rem;
}
.pagination button:hover { background: var(--gray-light); }
.pagination button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== LOADING ========== */
.loading {
    text-align: center; padding: 2rem; color: var(--gray);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .menu-btn { display: block; }
    .topbar-info span:first-child { display: none; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .data-table th, .data-table td { padding: 0.5rem; font-size: 0.8rem; }
    .logs-filters { flex-direction: column; }
    .modal { max-width: 95%; }
}
