/* admin.css */
:root {
    --teal-primary: #0F9E7A;
    --teal-light: #E1F5EE;
    --teal-hover: #0D8A6A;
    --bg-page: #F8F8F8;
    --bg-sidebar: #FAFAFA;
    --bg-card: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --text-tertiary: #AAAAAA;
    --border-color: #EBEBEB;
    --neutral-bg: #F1EFE8;
    --neutral-color: #5F5E5A;
    --danger-soft: #FEF2F2;
    --danger-color: #C0392B;
    
    --font-inter: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-inter);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-weight: 400;
}

/* Typography Resets */
h1, h2, h3, h4, h5, h6 { font-weight: 500; color: var(--text-primary); margin-bottom: 0; }
a { text-decoration: none; color: inherit; }

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

/* Sidebar */
.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 0.5px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.sidebar-header {
    padding: 0 20px;
    margin-bottom: 24px;
}

.school-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-box {
    width: 32px;
    height: 32px;
    background-color: var(--teal-light);
    color: var(--teal-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
}

.school-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-profile {
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--teal-light);
    color: var(--teal-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 13px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 15px; /* de 13 a 15 */
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 13px; /* de 11 a 13 */
    color: var(--text-secondary);
}

/* Navigation */
.nav-section {
    margin-bottom: 24px;
}

.nav-label {
    padding: 0 20px;
    font-size: 11.5px; /* de 10 a 11.5 */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    font-weight: 500;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    padding: 0 12px;
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14.5px; /* de 13 a 14.5 */
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.nav-link i {
    font-size: 18px; /* de 16 a 18 */
}

.nav-link:hover {
    background-color: rgba(0,0,0,0.02);
}

.nav-link.active {
    background-color: var(--teal-light);
    color: var(--teal-primary);
    font-weight: 500;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px 12px 0 12px;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--danger-color);
    background-color: transparent;
    font-size: 14.5px; /* de 13 a 14.5 */
    font-weight: 500;
    border: none;
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.logout-btn i {
    font-size: 18px; /* de 16 a 18 */
}

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

/* Main Area */
.admin-main {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    font-size: 15px; /* de 13 a 15 */
    color: var(--text-secondary);
}

/* Animated Badge */
.status-badge {
    background-color: var(--teal-light);
    color: var(--teal-primary);
    font-size: 12px; /* de 11 a 12 */
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot-pulse {
    width: 6px;
    height: 6px;
    background-color: var(--teal-primary);
    border-radius: 50%;
    position: relative;
}

.dot-pulse::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background-color: var(--teal-primary);
    border-radius: 50%;
    animation: pulse 2s infinite ease-out;
    opacity: 0.5;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* Cards Grid */
.grid-section {
    margin-bottom: 56px;
}

.section-label {
    font-size: 12.5px; /* de 11 a 12.5 */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    font-weight: 500;
}

.card-admin {
    background-color: #F4FBF9; /* Fondo verde muy claro */
    border: 1px solid rgba(15, 158, 122, 0.15);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
}

.card-admin:hover {
    box-shadow: 0 4px 20px rgba(15, 158, 122, 0.08);
    transform: translateY(-2px);
}

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    background-color: var(--teal-primary);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(15, 158, 122, 0.35); /* Sombra difuminada como en la imagen */
}

.card-icon i {
    font-size: 24px;
}

/* Primary vs Secondary Card Elements (ahora todas usan el mismo estilo vibrante para el ícono) */
.card-icon.primary, .card-icon.secondary { 
    background-color: var(--teal-primary); 
    color: #ffffff; 
}

.card-title {
    font-size: 16px; /* de 14 a 16 */
    font-weight: 500;
    margin-bottom: 6px; /* Ajuste ligero */
    color: var(--text-primary);
}

.card-desc {
    font-size: 14px; /* de 12 a 14 */
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
}

.card-desc a {
    word-break: break-all;
    overflow-wrap: break-word;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.card-metric {
    font-size: 12.5px; /* de 11 a 12.5 */
    color: var(--text-secondary);
}

.card-metric strong {
    font-weight: 500;
    color: var(--text-primary);
}

.btn-admin {
    font-size: 13.5px; /* de 12 a 13.5 */
    border-radius: 6px;
    padding: 7px 14px; /* un poquito mas grande */
    font-weight: 500;
    border: none;
    transition: all 0.15s ease;
    cursor: pointer;
    text-align: center;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.btn-admin.primary {
    background-color: var(--teal-primary);
    color: #fff;
}

.btn-admin.secondary {
    background-color: var(--neutral-bg);
    color: var(--neutral-color);
}

.btn-admin:hover {
    opacity: 0.9;
}

/* Tablas Administrativas */
.table-admin {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.table-admin th {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-admin td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-admin tbody tr:last-child td {
    border-bottom: none;
}

.table-admin tbody tr:hover {
    background-color: rgba(15, 158, 122, 0.02);
}

/* Formularios Administrativos */
.form-admin-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.form-admin-control:focus {
    border-color: var(--teal-primary);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(15, 158, 122, 0.15);
}

.form-admin-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ================= MOBILE TOPBAR ================= */
.mobile-topbar {
    display: none; /* Oculto en desktop */
    position: sticky;
    top: 0;
    z-index: 1001;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Sidebar Close Button (solo visible en móvil) */
.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1009;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ================= RESPONSIVE MOBILE (<= 768px) ================= */
@media (max-width: 768px) {
    /* Mostrar topbar */
    .mobile-topbar {
        display: flex;
    }

    /* Sidebar como panel lateral */
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1010;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        border-right: 1px solid var(--border-color);
    }

    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.15);
    }

    /* Mostrar botón de cerrar en sidebar */
    .sidebar-close {
        display: flex;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Main ocupa todo el ancho */
    .admin-main {
        padding: 16px;
        width: 100%;
    }

    /* Page header más compacto */
    .page-header {
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 18px;
        flex-wrap: wrap;
    }

    /* Cards grid responsivo */
    .row .col-md-4,
    .row .col-md-6 {
        margin-bottom: 12px;
    }

    .card-admin {
        padding: 16px;
    }

    .card-desc {
        font-size: 13px;
    }

    /* Tablas con scroll horizontal */
    .table-responsive,
    .table-admin-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .table-admin {
        min-width: 600px;
    }

    .table-admin th,
    .table-admin td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Formularios */
    .form-admin-control {
        font-size: 16px; /* Evitar zoom en iOS */
    }

    /* Grid section spacing */
    .grid-section {
        margin-bottom: 32px;
    }

    /* Botones más tocables */
    .btn-admin {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* ================= RESPONSIVE TABLET (769px - 991px) ================= */
@media (min-width: 769px) and (max-width: 991px) {
    .admin-sidebar {
        width: 200px;
    }

    .admin-main {
        padding: 20px;
    }
}

/* ================= CUSTOM FILE PICKER ================= */
.file-picker {
    position: relative;
    display: block;
    width: 100%;
}

.file-picker-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.file-picker-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background-color: #fff;
    border: 1.5px dashed rgba(15, 158, 122, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin: 0; /* reset label margin */
    user-select: none;
}

.file-picker-btn i {
    flex-shrink: 0;
    font-size: 18px;
    color: var(--teal-primary);
}

.file-picker-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.file-picker-btn:hover,
.file-picker-input:hover + .file-picker-btn {
    border-color: var(--teal-primary);
    background-color: var(--teal-light);
    color: var(--teal-primary);
}
