/* School Portal — main stylesheet (loaded on every page) */
:root {
    --primary: #1e5f74;
    --primary-dark: #133845;
    --primary-light: #e8f4f8;
    --accent: #6366f1;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ── */
.app-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(79, 70, 229, 0.06), transparent 18%),
        var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.app-shell--no-sidebar {
    grid-template-columns: 1fr;
}

.app-shell--no-sidebar .content-panel {
    width: 100%;
}

/* Sidebar (kept for when re-enabled) */
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    background: linear-gradient(180deg, #0f172a, #111827);
    color: #e2e8f0;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
.brand-icon {
    width: 48px; height: 48px; display: grid; place-items: center;
    border-radius: 12px; background: linear-gradient(135deg, #2563eb, #7c3aed); font-weight: 700;
}
.brand-label { margin: 0; font-size: 0.78rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.08em; }
.sidebar-brand h3 { margin: 0; font-size: 0.96rem; color: #f8fafc; }
.sidebar-menu { display: flex; flex-direction: column; gap: 10px; }
.sidebar-group summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: 12px; font-weight: 600; color: #e2e8f0; background: rgba(255,255,255,0.05);
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-links { display: flex; flex-direction: column; gap: 4px; padding: 8px 6px 0; }
.sidebar-links a, .sidebar-footer a, .sidebar-footer button {
    color: #cbd5e1; text-decoration: none; padding: 10px 12px; border-radius: 10px;
}
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 6px 0; }
.sidebar-footer button { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }

/* Content panel */
.content-panel {
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    min-width: 0;
    width: 100%;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.topbar-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.topbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.topbar-logo:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.topbar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.topbar-logo-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}

.topbar-logout {
    margin: 0;
}

.page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--muted);
}

.page-breadcrumb-home {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.page-breadcrumb-home:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.page-breadcrumb-sep {
    color: #cbd5e1;
}

.page-breadcrumb-parent {
    color: var(--muted);
}

.page-breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

.page-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.topbar-left h2 { margin: 0; font-size: 1rem; color: var(--text); }
.topbar-label { margin: 0 0 4px; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }

.session-pill {
    display: flex; align-items: center; gap: 8px;
    background: #eef2ff; color: #3730a3; border-radius: 999px;
    padding: 8px 14px; font-size: 0.9rem; white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: #475569; font-size: 0.95rem; }

.user-block {
    display: flex; flex-direction: column; align-items: flex-end;
    padding: 8px 14px; border-radius: 999px; background: #f8fafc; color: var(--text);
}
.user-block small { color: var(--muted); font-size: 0.78rem; }

/* Main content */
.main-content {
    padding: 24px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 { margin: 0; font-size: 1.8rem; color: var(--text); }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.stat-card .value { font-size: 1.85rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-card .label { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

/* Dashboard icon navigation */
.dashboard-menu {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px 22px 6px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.dash-section { margin-bottom: 24px; }
.dash-section:last-child { margin-bottom: 8px; }

.dash-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 14px;
    text-transform: uppercase;
}

.dash-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 14px;
}

.dash-icon-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    text-align: center;
    color: var(--text);
    min-height: 118px;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.dash-icon-tile:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 8px 20px rgba(30, 95, 116, 0.12);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.dash-icon-tile.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: inset 0 0 0 1px rgba(30, 95, 116, 0.2);
}

.dash-icon-circle {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #e0f2fe 0%, #eef2ff 100%);
    transition: transform 0.15s, background 0.15s;
}

.dash-icon-tile:hover .dash-icon-circle {
    background: linear-gradient(135deg, #bae6fd 0%, #c7d2fe 100%);
    transform: scale(1.06);
}

.dash-icon-tile i {
    font-size: 1.45rem;
    color: var(--primary);
    line-height: 1;
}

.dash-icon-label {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.25;
    color: #334155;
}

/* Cards & tables */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.card h1, .card h2, .card h3 { margin-bottom: 12px; color: var(--text); }
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; font-weight: 600; color: var(--muted); }
.card th { background: transparent; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85rem; }
tr:hover td { background: #fafafa; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 0.9rem; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}
.form-control:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-row-inline {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 12px;
}
.form-row-inline .form-group { margin-bottom: 0; flex: 1 1 0; min-width: 0; }
.form-row-inline .form-group--actions { flex: 0 0 auto; white-space: nowrap; }

/* Alerts & badges */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; 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; }

/* Login */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.login-card {
    background: #fff; padding: 32px; border-radius: 12px;
    width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.login-card h1 { text-align: center; margin-bottom: 8px; color: var(--primary); }
.login-card p.subtitle { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 0.9rem; }

/* Attendance colors */
.attendance-present { color: var(--success); }
.attendance-absent { color: var(--danger); }
.attendance-leave { color: var(--warning); }
.attendance-late { color: #2563eb; }

/* Utilities */
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }

.pagination { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .topbar-right { width: 100%; justify-content: space-between; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .dash-icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-row-inline { flex-wrap: wrap; }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .card { border: none; box-shadow: none; }
}

/* Reports & certificates panels */
.doc-student-banner h2 { margin: 0 0 4px; font-size: 1.35rem; }

.doc-panels { display: flex; flex-direction: column; gap: 20px; }

.doc-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.doc-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 1.05rem;
    color: var(--text);
}

.doc-panel-title i { color: var(--primary); font-size: 1.2rem; }

.doc-subtitle {
    margin: 18px 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.doc-subtitle:first-of-type { margin-top: 0; }

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.doc-grid--compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.doc-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 18px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    min-height: 120px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.doc-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(30, 95, 116, 0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.doc-tile--disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f8fafc;
}

.doc-tile--form { align-items: stretch; min-height: auto; }

.doc-tile-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #e0f2fe, #eef2ff);
}

.doc-tile-icon i { font-size: 1.35rem; color: var(--primary); }

.doc-tile-label { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }

.doc-tile-hint { font-size: 0.75rem; color: var(--muted); }

.doc-inline-form { width: 100%; margin-top: 8px; text-align: left; }
.doc-inline-form .form-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.doc-empty { margin: 0; font-size: 0.9rem; }

.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }

.doc-type-overview { padding-left: 20px; color: var(--muted); line-height: 1.7; }

.form-group--actions { align-self: flex-end; }

.card-title {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: var(--text);
}

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th,
.detail-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.detail-table th {
    width: 16%;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }

.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.export-menu { position: relative; }
.export-menu-trigger {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.export-menu-trigger::-webkit-details-marker { display: none; }
.export-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    padding: 6px;
    z-index: 20;
}
.export-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}
.export-menu-item:hover {
    background: #f3f4f6;
    text-decoration: none;
    color: var(--text);
}

.placeholder-chip {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.8rem;
}

.whatsapp-guide {
    border-left: 4px solid #25d366;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 48%);
}
.whatsapp-guide-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.whatsapp-guide-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.whatsapp-guide-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.whatsapp-guide-step h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}
.whatsapp-guide-step ul {
    margin: 0;
    padding-left: 1.15rem;
    line-height: 1.65;
    color: var(--muted, #64748b);
}
.whatsapp-guide-step ul li {
    margin-bottom: 2px;
}
.whatsapp-guide-step code {
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

@media (max-width: 640px) {
    .doc-grid, .doc-grid--compact { grid-template-columns: 1fr; }
}
