/* ============================================================
   GESTOR — Estilos principales
   ============================================================ */

/* Variables */
:root {
    --sidebar-w: 260px;
    --sidebar-bg: #1a2332;
    --sidebar-brand-bg: #141c28;
    --sidebar-text: #8a97aa;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(67, 97, 238, 0.15);
    --sidebar-active-text: #4361ee;
    --sidebar-active-border: #4361ee;
    --topbar-h: 64px;
    --topbar-bg: #ffffff;
    --accent: #4361ee;
    --accent-dark: #3451c7;
    --body-bg: #f0f2f7;
    --card-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
    --card-radius: 12px;
    --border-color: #e8ebf0;
    --text-muted: #8a97aa;
    --transition: 0.28s ease;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--body-bg);
    color: #2d3748;
    font-size: 14px;
    line-height: 1.6;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: var(--topbar-h);
    background: var(--sidebar-brand-bg);
    text-decoration: none;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 1px;
}

.sidebar-brand-sub {
    font-size: 10px;
    color: var(--sidebar-text);
    display: block;
    line-height: 1;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(138, 151, 170, 0.5);
    padding: 8px 24px 4px;
    margin-top: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin: 2px 0;
    position: relative;
}

.sidebar-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
    border-left-color: rgba(67, 97, 238, 0.4);
}

.sidebar-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
}

.sidebar-link .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-link .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--sidebar-text);
}

/* ── Overlay mobile ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ── Main Wrapper ── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.main-wrapper.expanded {
    margin-left: 0;
}

/* ── Top Navbar ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 1030;
    box-shadow: 0 1px 8px rgba(0,0,0,0.04);
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #5a6575;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 18px;
}

.btn-toggle-sidebar:hover {
    background: var(--body-bg);
    color: var(--accent);
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5a6575;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
}

.topbar-icon-btn:hover {
    background: #fff;
    color: var(--accent);
    border-color: var(--accent);
    color: var(--accent);
}

.topbar-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #fff;
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.topbar-user:hover { background: var(--body-bg); }

.topbar-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--accent), #7b5cf0);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.topbar-user-info { line-height: 1.3; }
.topbar-user-name { font-size: 13px; font-weight: 600; color: #2d3748; }
.topbar-user-role { font-size: 11px; color: var(--text-muted); }

/* ── Content area ── */
.content-area {
    flex: 1;
    padding: 28px 28px 40px;
}

/* ── Page header ── */
.page-header {
    margin-bottom: 24px;
}

.page-header-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a2332;
    margin: 0 0 4px;
}

.page-header-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* ── Cards ── */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
}

.card-body { padding: 20px; }

/* ── Stat cards ── */
.stat-card {
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    background: #fff;
    box-shadow: var(--card-shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eef2ff; color: #4361ee; }
.stat-icon.green  { background: #e6f9f0; color: #28a745; }
.stat-icon.orange { background: #fff4e6; color: #fd7e14; }
.stat-icon.red    { background: #fff0f0; color: #e53e3e; }
.stat-icon.purple { background: #f3e8ff; color: #7b5cf0; }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 700; color: #1a2332; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-trend { font-size: 12px; margin-top: 4px; font-weight: 600; }
.stat-trend.up   { color: #28a745; }
.stat-trend.down { color: #e53e3e; }

/* ── Buttons ── */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-accent:hover {
    background: var(--accent-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
}

/* ── Tables ── */
.table {
    font-size: 13px;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    color: #5a6575;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
    color: #2d3748;
}

.table tbody tr:hover td { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active   { background: #e6f9f0; color: #28a745; }
.badge-inactive { background: #fff0f0; color: #e53e3e; }
.badge-warning  { background: #fff4e6; color: #fd7e14; }
.badge-info     { background: #eef2ff; color: #4361ee; }

/* ── Forms ── */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    padding: 9px 12px;
    color: #2d3748;
    transition: all 0.2s;
    background: #fff;
}

.form-control::placeholder,
.form-select::placeholder {
    color: #b0bac8;
    opacity: 1;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
    outline: none;
}

.input-group-text {
    background: #f8fafc;
    border-color: var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Modal ── */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
    background: linear-gradient(135deg, var(--accent), #7b5cf0);
    color: #fff;
    border-radius: 16px 16px 0 0;
    padding: 20px 24px;
    border: none;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 16px;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
}

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2332 0%, #2d3a52 50%, #1a2332 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.3);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--accent) 0%, #7b5cf0 100%);
    padding: 36px 32px;
    text-align: center;
    color: #fff;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    backdrop-filter: blur(10px);
}

.login-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 0 0 4px;
}

.login-subtitle {
    font-size: 13px;
    opacity: 0.8;
    margin: 0;
}

.login-body { padding: 36px 32px; }

.login-form .form-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4a5568;
}

.login-form .form-control {
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 10px;
}

.btn-login {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--accent), #7b5cf0);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.5px;
}

.btn-login:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(67, 97, 238, 0.4);
}

.login-footer {
    padding: 16px 32px;
    text-align: center;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Notification dropdown ── */
.notif-dropdown {
    width: 340px;
    padding: 0;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    overflow: hidden;
}

.notif-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    background: #fff;
}

.notif-list { max-height: 320px; overflow-y: auto; background: #fff; }

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.15s;
    cursor: pointer;
}

.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eef2ff; }
.notif-item.unread:hover { background: #e8eeff; }

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: 13px; color: #2d3748; line-height: 1.4; }
.notif-text strong { font-weight: 600; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.notif-footer {
    padding: 10px 18px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: #fafbfc;
}

.notif-footer a {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

/* ── DataTables custom ── */
div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    font-size: 13px;
    margin-left: 6px;
}

div.dataTables_wrapper div.dataTables_length select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 5px 8px;
    font-size: 13px;
}

div.dataTables_wrapper div.dataTables_info {
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 12px;
}

div.dataTables_wrapper div.dataTables_paginate {
    padding-top: 8px;
}

.dataTables_wrapper .pagination .page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    font-size: 13px;
    color: var(--accent);
    border-color: var(--border-color);
}

.dataTables_wrapper .pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* ── Spinner loader ── */
.page-loader {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.spinner-ring {
    width: 44px;
    height: 44px;
    border: 4px solid #e8ebf0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.g-toast {
    background: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border-left: 4px solid var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    max-width: 320px;
    animation: slideIn 0.3s ease;
}

.g-toast.success { border-left-color: #28a745; }
.g-toast.error   { border-left-color: #e53e3e; }
.g-toast.warning { border-left-color: #fd7e14; }
.g-toast-icon    { font-size: 16px; flex-shrink: 0; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Avatar initials ── */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4361ee, #7b5cf0);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
    display: block;
}

.empty-state h6 { font-size: 15px; color: #4a5568; margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .main-wrapper.expanded {
        margin-left: 0;
    }

    .content-area {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
}

/* ── Utilities ── */
.text-accent { color: var(--accent); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.gap-8  { gap: 8px; }

.actions-cell { white-space: nowrap; display: flex; gap: 4px; }

.table-responsive { border-radius: var(--card-radius); overflow: hidden; }
