/* ===== Aprendix - Estilos globales ===== */
:root {
    --primary: #F97316;
    --primary-dark: #EA6200;
    --primary-light: #FFF7ED;
    --secondary: #16A34A;
    --secondary-light: #DCFCE7;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --dark: #1A1A2E;
    --dark2: #16213E;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --sidebar-w: 260px;
    --header-h: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--gray-50); color: var(--gray-900); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1A1A2E 0%, #16213E 60%, #0F3460 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}
.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h1 { font-size: 22px; font-weight: 900; letter-spacing: -.5px; color: #fff; }
.sidebar-logo span { color: var(--primary); }
.sidebar-logo small { display: block; font-size: 10px; color: rgba(255,255,255,.45); margin-top: 2px; font-style: italic; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; font-weight: 600; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: 1px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,.65);
    border-radius: 8px;
    margin: 1px 8px;
    font-weight: 500;
    transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(249,115,22,.35); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.4); text-transform: capitalize; }
.btn-logout {
    display: block; margin-top: 10px;
    padding: 8px 16px; border-radius: 8px;
    background: rgba(255,255,255,.07); color: rgba(255,255,255,.6);
    font-size: 13px; text-align: center; transition: all .15s;
}
.btn-logout:hover { background: var(--danger); color: #fff; text-decoration: none; }

/* ===== Main content ===== */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.topbar {
    height: var(--header-h); background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.topbar-breadcrumb { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.content { padding: 28px; flex: 1; }

/* ===== Cards ===== */
.card {
    background: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.card-header {
    padding: 18px 20px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border-radius: var(--radius);
    padding: 20px; border: 1px solid var(--gray-200);
    box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
    border: none; cursor: pointer; transition: all .15s; line-height: 1.4;
    white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); text-decoration: none; color: var(--gray-700); }
.btn-success { background: var(--secondary); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; text-decoration: none; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; text-decoration: none; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 10px 14px; text-align: left;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--gray-500);
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
td { padding: 12px 14px; color: var(--gray-700); vertical-align: middle; }
.td-actions { display: flex; gap: 6px; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-gray    { background: var(--gray-100); color: var(--gray-500); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--gray-300); font-size: 14px;
    transition: border-color .15s, box-shadow .15s; outline: none;
    background: #fff; color: var(--gray-900);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
select.form-control { cursor: pointer; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.95) translateY(-10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray-500); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Alerts / Flash ===== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; margin-bottom: 18px; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ===== Filters bar ===== */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filters .form-group { margin-bottom: 0; }
.filters .form-control { min-width: 160px; }

/* ===== Login ===== */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #F5F5F5;
    position: relative; overflow: hidden;
}
/* Franja naranja superior */
.login-page::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, var(--primary) 0%, #FBBF24 100%);
}
/* Decoración geométrica fondo */
.login-page::after {
    content: ''; position: absolute;
    width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(249,115,22,.08) 0%, transparent 65%);
    bottom: -200px; right: -150px;
    pointer-events: none;
}
.login-bg-circle {
    position: absolute; width: 400px; height: 400px; border-radius: 50%;
    background: radial-gradient(circle, rgba(22,163,74,.07) 0%, transparent 65%);
    top: -100px; left: -100px; pointer-events: none;
}
.login-box {
    background: #fff; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,.10); position: relative; z-index: 1;
    border: 1px solid var(--gray-200);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 36px; font-weight: 900; color: #111827; letter-spacing: -1px; }
.login-logo h1 span { color: var(--primary); }
.login-logo .tagline { color: var(--gray-500); font-size: 13px; margin-top: 4px; font-style: italic; }
.login-logo .logo-icon { font-size: 28px; margin-bottom: 8px; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 500;
    border: 1px solid var(--gray-200); color: var(--gray-700); background: #fff;
}
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .35; }
.empty-state p { font-size: 14px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {

    /* --- Layout --- */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 300;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 299;
    }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }

    /* --- Topbar --- */
    .topbar { padding: 0 16px; }
    .topbar-title { font-size: 16px; }
    .topbar-breadcrumb { display: none; }
    .topbar-user-label { display: none; }
    .hamburger {
        display: flex !important;
        align-items: center; justify-content: center;
        width: 40px; height: 40px;
        background: none; border: none; cursor: pointer;
        color: var(--gray-700); border-radius: 8px;
        flex-shrink: 0;
    }
    .hamburger:hover { background: var(--gray-100); }

    /* --- Content padding --- */
    .content { padding: 16px; }

    /* --- Stats --- */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }

    /* --- Forms --- */
    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }

    /* --- Modals --- */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        overflow-y: auto;
        animation: modalInMobile .25s ease;
    }
    @keyframes modalInMobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px 20px; }
    .modal-footer { padding: 12px 16px; }

    /* --- Tables: convertir a cards en mobile --- */
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards tbody tr {
        display: block;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 12px 14px;
        background: #fff;
        box-shadow: var(--shadow);
    }
    .table-mobile-cards tbody tr:last-child { border-bottom: 1px solid var(--gray-200); }
    .table-mobile-cards td {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 5px 0;
        border: none;
        font-size: 13px;
    }
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        color: var(--gray-500);
        text-transform: uppercase;
        letter-spacing: .4px;
        min-width: 90px;
        flex-shrink: 0;
    }
    .table-mobile-cards td.td-full {
        flex-direction: column;
        align-items: flex-start;
    }
    .table-mobile-cards td.td-full::before { min-width: unset; }
    .table-mobile-cards .td-actions {
        justify-content: flex-end;
        margin-top: 6px;
        padding-top: 8px;
        border-top: 1px solid var(--gray-100);
        width: 100%;
    }
    .table-mobile-cards .td-actions::before { display: none; }

    /* Botones de acción más grandes en mobile */
    .btn-sm { padding: 8px 12px; font-size: 13px; }
    .td-actions .btn-sm { min-width: 36px; min-height: 36px; justify-content: center; }

    /* --- Botones de filtro --- */
    .mobile-scroll-x {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .mobile-scroll-x .btn { white-space: nowrap; }

    /* --- Calendario --- */
    .calendario-acciones {
        flex-direction: column;
        align-items: stretch !important;
    }
    .calendario-acciones form,
    .calendario-acciones .btn { width: 100%; justify-content: center; }

    /* --- Page header (titulo + botón agregar) --- */
    .page-top {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    .page-top .btn { justify-content: center; }

    /* --- Login --- */
    .login-box { padding: 32px 22px; border-radius: 16px; margin: 16px; }

    /* --- Recordatorios cards --- */
    .rec-card-actions { flex-wrap: wrap; }

    /* --- Calendario: card de clase --- */
    .clase-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    .clase-card-hora { min-width: unset !important; }
    .clase-card-sep  { width: 100% !important; height: 2px !important; }
    .clase-card-acciones {
        width: 100%;
        flex-wrap: wrap;
    }
    .clase-card-acciones form,
    .clase-card-acciones .btn { flex: 1; min-width: 0; justify-content: center; }

    /* --- Dashboard stats 2 columns --- */
    .stats-grid { grid-template-columns: 1fr 1fr; }

    /* --- Balance: modal radio buttons --- */
    .metodo-pago-opts { flex-direction: column; }
}
