/* public/css/style.css - SISCA Institutional Design */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --primary: #1a5276;
    --primary-dark: #154360;
    --primary-light: #2e86c1;
    --secondary: #27ae60;
    --secondary-dark: #1e8449;
    --accent: #f39c12;
    --accent-dark: #d68910;
    --danger: #c0392b;
    --danger-light: #e74c3c;
    --warning: #f39c12;
    --info: #2980b9;
    --purple: #8e44ad;
    --white: #ffffff;
    --light: #f4f6f9;
    --light2: #eaf0fb;
    --border: #d5e0ed;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --shadow: 0 2px 12px rgba(26,82,118,0.10);
    --shadow-lg: 0 8px 32px rgba(26,82,118,0.18);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 260px;
    /* Asistencia colors */
    --presente: #27ae60;
    --ausente: #c0392b;
    --retardo: #f39c12;
    --uniforme-ok: #2980b9;
    --uniforme-no: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--light);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    color: white;
    z-index: 1000;
    display: flex; flex-direction: column;
    transition: transform .3s ease;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    text-align: center;
}
.sidebar-brand .app-logo {
    width: 52px; height: 52px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px;
    font-size: 24px;
}
.sidebar-brand h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 22px; font-weight: 700;
    letter-spacing: 2px; color: white;
}
.sidebar-brand p { font-size: 10px; opacity: 0.7; letter-spacing: 0.5px; }

.sidebar-user {
    padding: 14px 18px;
    background: rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: white;
    flex-shrink: 0;
}
.user-info .name { font-size: 13px; font-weight: 700; }
.user-info .role { font-size: 10px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-section {
    padding: 8px 18px 4px;
    font-size: 9px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 18px;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    font-size: 13px; font-weight: 600;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: white;
    border-left-color: var(--accent);
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
}

/* ===== TOPBAR ===== */
.topbar {
    position: fixed; top: 0;
    left: var(--sidebar-w); right: 0;
    height: 56px;
    background: white;
    border-bottom: 2px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    gap: 12px;
}
.topbar-title { font-size: 17px; font-weight: 800; color: var(--primary); flex: 1; }
.topbar-title span { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.btn-menu { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--primary); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    padding-top: 56px;
    min-height: 100vh;
}
.page-content { padding: 24px; }

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 2px solid var(--light);
    display: flex; align-items: center; gap: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}
.card-header h3 { font-size: 15px; font-weight: 700; flex: 1; }
.card-header .icon { font-size: 18px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--light); }

/* STATS CARDS */
.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    border-left: 4px solid var(--primary);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.green { border-left-color: var(--secondary); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.orange { border-left-color: var(--accent); }
.stat-card.blue { border-left-color: var(--info); }
.stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: white; flex-shrink: 0;
}
.stat-card .stat-icon { background: var(--primary); }
.stat-card.green .stat-icon { background: var(--secondary); }
.stat-card.red .stat-icon { background: var(--danger); }
.stat-card.orange .stat-icon { background: var(--accent); }
.stat-card.blue .stat-icon { background: var(--info); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--primary);
    color: white;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: var(--light2); }
tbody td { padding: 9px 12px; vertical-align: middle; }
tbody tr:nth-child(even) { background: #f8fbff; }
tbody tr:nth-child(even):hover { background: var(--light2); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 13px; font-weight: 700;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--secondary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--accent); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 6px 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px; font-weight: 700;
    color: var(--primary); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    transition: border-color .2s, box-shadow .2s;
    background: white;
    color: var(--text);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,134,193,0.15);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.form-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== MODALS ===== */
.modal-overlay {
    display: none; position: fixed;
    inset: 0; background: rgba(0,0,0,0.55);
    z-index: 2000; justify-content: center; align-items: center;
    backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
    animation: modalIn .25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(-20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-lg { max-width: 900px; }
.modal-header {
    padding: 16px 20px;
    border-bottom: 2px solid var(--border);
    display: flex; align-items: center; gap: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white; border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h4 { flex: 1; font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: white; font-size: 22px; cursor: pointer; opacity: 0.8; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== ATTENDANCE TABLE ===== */
.attendance-header {
    background: var(--light2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
}
.attendance-meta { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.attendance-meta .badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px; font-weight: 700;
}
.badge-primary { background: var(--primary); color: white; }
.badge-success { background: var(--secondary); color: white; }
.badge-warning { background: var(--accent); color: white; }
.badge-info { background: var(--info); color: white; }
.badge-danger { background: var(--danger); color: white; }
.badge-light { background: var(--border); color: var(--text); }

/* Asistencia cell buttons */
.asist-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none; cursor: pointer;
    font-size: 15px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .2s;
    outline: none;
}
.asist-btn.presente { background: var(--presente); color: white; }
.asist-btn.ausente { background: var(--ausente); color: white; }
.asist-btn.retardo { background: var(--retardo); color: white; }
.asist-btn:hover { transform: scale(1.15); box-shadow: 0 3px 10px rgba(0,0,0,0.2); }

.unif-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none; cursor: pointer;
    font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .2s;
}
.unif-btn.si { background: var(--uniforme-ok); color: white; }
.unif-btn.no { background: var(--uniforme-no); color: white; }

/* Student photo */
.student-photo {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--light);
}
.student-photo-placeholder {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
    border: 2px solid var(--border);
}

/* Summary bar */
.asist-summary {
    display: flex; gap: 16px; flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--light);
    border-top: 2px solid var(--border);
    font-size: 13px; font-weight: 700;
}
.asist-summary .item { display: flex; align-items: center; gap: 6px; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 600;
}
.alert-success { background: #d5f5e3; color: #1e8449; border-left: 4px solid var(--secondary); }
.alert-danger { background: #fde8e8; color: var(--danger); border-left: 4px solid var(--danger); }
.alert-warning { background: #fef9e7; color: var(--accent-dark); border-left: 4px solid var(--accent); }
.alert-info { background: #d6eaf8; color: var(--info); border-left: 4px solid var(--info); }
#toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    min-width: 260px; max-width: 380px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
    border-left: 4px solid var(--secondary);
    animation: toastIn .3s ease;
    font-size: 13px; font-weight: 600;
}
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--accent); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    padding: 44px 40px;
    width: 100%; max-width: 420px;
    position: relative;
}
.login-logo {
    text-align: center; margin-bottom: 28px;
}
.login-logo .logo-circle {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
    font-size: 30px; color: white;
    box-shadow: 0 8px 24px rgba(26,82,118,0.35);
}
.login-logo h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 28px; font-weight: 700; color: var(--primary);
    letter-spacing: 3px;
}
.login-logo p { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }

/* ===== MONITORING ===== */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.monitor-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}
.monitor-card-header { padding: 12px 16px; font-weight: 700; font-size: 13px; color: white; }
.monitor-card-body { padding: 12px 16px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-260px); width: 260px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { left: 0; }
    .btn-menu { display: block; }
    .overlay-mobile {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.4); z-index: 999;
    }
    .overlay-mobile.active { display: block; }
    .form-row { flex-direction: column; }
    .page-content { padding: 14px; }
    .attendance-meta { gap: 10px; }
}

/* ===== UTILITIES ===== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--secondary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--accent); }
.fw-bold { font-weight: 700; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
@media(max-width:900px){ .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media(max-width:600px){ .grid-4,.grid-3,.grid-2 { grid-template-columns: 1fr; } }

/* Breadcrumb */
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--primary-light); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); }

/* Search box */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }

/* IMPORT/EXPORT */
.import-zone {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px; text-align: center;
    cursor: pointer; transition: all .2s;
    color: var(--text-muted);
}
.import-zone:hover, .import-zone.dragover { border-color: var(--primary-light); background: var(--light2); color: var(--primary); }
.import-zone .icon { font-size: 40px; display: block; margin-bottom: 10px; }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--light); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* Spinner */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Photo upload */
.photo-preview {
    width: 100px; height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    cursor: pointer;
    transition: border-color .2s;
}
.photo-preview:hover { border-color: var(--primary-light); }
