/* ============================================================
   CONVIVE - Sistema de Convivencia Escolar
   Estilos modernos y responsive
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --navy-900: #0a1f3d;
    --navy-800: #0f2b52;
    --navy-700: #143768;
    --navy: #003E71;
    --navy-50: #F5F7FA;
    --navy-100: #E8ECF1;
    --ink-soft: #6B7280;
    --ink-faint: #9CA3AF;
    --line: #E5E7EB;
    --line-strong: #C9CFD7;
    --paper: #F9FAFB;
    --gold: #f6b000;
    --gold-dark: #d4a000;
    --red: #DC2626;
    --green: #16A34A;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(0,27,51,0.06);
    --shadow-md: 0 4px 12px rgba(0,27,51,0.1);
    --shadow-lg: 0 8px 24px rgba(0,27,51,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: 0.2s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--paper);
    color: var(--navy-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===========================================
   SIDEBAR
   =========================================== */
.sidebar {
    width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1050;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

.sidebar-header {
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--white);
}

.sidebar-logo img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    line-height: 1.2;
}

.sidebar-logo-title {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: -0.01em;
}

.sidebar-logo-sub {
    font-size: 10.5px;
    opacity: 0.7;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 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.15); border-radius: 4px; }

.nav-section {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    padding: 16px 18px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 2px 10px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: calc(100% - 20px);
    text-align: left;
}

.nav-item i {
    width: 20px;
    font-size: 15px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.nav-item.active {
    background: var(--gold);
    color: var(--navy-900);
    font-weight: 700;
}

.nav-item.active i { color: var(--navy-900); }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 14px 16px;
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy-900);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11px; opacity: 0.7; }
.user-colegio { font-size: 8px; opacity: 0.5; margin-top: 1px; }

.sidebar-footer .nav-item {
    padding: 7px 12px;
    margin: 2px 0;
    width: 100%;
    font-size: 13px;
}

/* ===========================================
   MAIN CONTENT
   =========================================== */
.main-wrapper {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.95);
}

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--navy-900);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.hamburger:hover { background: var(--navy-50); }

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ===========================================
   COMPONENTES REUTILIZABLES
   =========================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--navy-900);
    margin: 0;
}

.page-subtitle {
    font-size: 14px;
    color: var(--ink-soft);
    margin-top: 2px;
}

.card {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--navy-900);
    margin: 0;
}

.card-body { padding: 16px 20px; }

.card-body-no-padding { padding: 0; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label {
    font-size: 11px;
    color: var(--ink-faint);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--navy-900);
    margin: 4px 0 0;
    line-height: 1.1;
}

.stat-value.gold { color: var(--gold); }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

.form-group { margin-bottom: 14px; }

.field-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    color: #545C66;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 5px;
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--white);
}

.field-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(246, 176, 0, 0.12);
}

.field-input:disabled {
    background-color: var(--paper);
    color: var(--ink-soft);
    cursor: not-allowed;
}

select.field-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

textarea.field-input { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--line);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    background: var(--white);
    color: var(--navy-900);
    font-family: var(--font-family);
    line-height: 1.4;
}

.btn:hover {
    background: var(--navy-50);
    border-color: var(--line-strong);
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.btn-primary:hover {
    background: var(--navy-700);
    border-color: var(--navy-700);
}

.btn-gold {
    background: var(--gold);
    color: var(--navy-900);
    border-color: var(--gold);
}

.btn-gold:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
}

.btn-danger {
    background: var(--red);
    color: var(--white);
    border-color: var(--red);
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11.5px;
    font-weight: 700;
    color: #545C66;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--line);
    background: var(--navy-50);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--navy-50); }

.table a {
    color: var(--navy);
    text-decoration: none;
    font-weight: 600;
}

.table a:hover { text-decoration: underline; }

/* Pill / Badge */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    gap: 4px;
}

.pill-open { background: #D1FAE5; color: #065F46; }
.pill-closed { background: #E5E7EB; color: #374151; }
.pill-alert { background: #FEE2E2; color: #991B1B; }
.pill-navy { background: #DBEAFE; color: #1E40AF; }
.pill-gold { background: #FEF3C7; color: #92400E; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-faint);
}

.empty-state i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* Alert / Message */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-danger { background: #FBEAE7; color: #B23A2E; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-info { background: #DBEAFE; color: #1E40AF; }
.alert-warning { background: #FEF3C7; color: #92400E; }

/* Hint */
.hint {
    font-size: 12px;
    color: var(--ink-faint);
    margin-top: 4px;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-faint);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all var(--transition);
    font-family: var(--font-family);
}

.tab-btn:hover { color: var(--navy-900); }

.tab-btn.active {
    color: var(--navy-900);
    border-bottom-color: var(--gold);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Loading */
.loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.loading.active { display: block; }

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--line);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Filters row */
.filters-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-row .field-input {
    min-width: 160px;
    flex: 1;
}

/* ===========================================
   RESPONSIVE
   =========================================== */

/* Tablets */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .main-content { padding: 20px; }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .hamburger { display: block; }
    
    .main-wrapper { margin-left: 0; }
    
    .main-content { padding: 16px; }
    
    .topbar { padding: 0 16px; }
    
    .page-title { font-size: 20px; }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 24px; }
    
    .form-grid,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
    
    .card-header { padding: 14px 16px; }
    .card-body { padding: 14px 16px; }
    
    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 12.5px;
    }
    
    .filters-row .field-input { min-width: 120px; }
}

/* Small mobile */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .page-header {
        flex-direction: column;
    }
    
    .btn-lg {
        width: 100%;
        justify-content: center;
    }
    
    .main-content { padding: 12px; }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}