/* ==========================================================
   College Management System - Stylesheet
   ========================================================== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f4f5fa;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --radius: 10px;
}

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

body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { text-decoration: none; color: inherit; }

/* ---------- Login Page ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.login-brand { text-align: center; margin-bottom: 25px; }
.login-brand .icon { font-size: 42px; display: block; }
.login-brand h1 { font-size: 18px; margin-top: 10px; }
.login-brand p { color: var(--text-muted); font-size: 13px; margin-top: 5px; }

.login-hint { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 15px; }
.login-hint a { color: var(--primary); font-weight: 600; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 15px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

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

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 16px 0 16px 0;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    padding: 0 20px 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 6px;
}

.sidebar nav { display: flex; flex-direction: column; }

.sidebar nav > a {
    padding: 11px 20px;
    font-size: 13.5px;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
    transition: 0.2s;
}

.sidebar nav > a:hover, .sidebar nav > a.active {
    background: rgba(255,255,255,0.08);
    border-left-color: #fff;
    color: #fff;
}

.sidebar nav > a.logout { margin-top: 10px; color: #fca5a5; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; }

.nav-group-title {
    padding: 11px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #a5b4fc;
    cursor: default;
}

.nav-group-items {
    display: none;
    flex-direction: column;
}

.nav-group.open .nav-group-items { display: flex; }

.nav-group-items a {
    padding: 8px 20px 8px 38px;
    font-size: 13px;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
}

.nav-group-items a:hover, .nav-group-items a.active {
    background: rgba(255,255,255,0.08);
    border-left-color: #fff;
    color: #fff;
}

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--card-bg);
    padding: 14px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.toggle-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }

.admin-info { font-size: 14px; color: var(--text-muted); }

.page-body { padding: 25px; }

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

.page-title { font-size: 24px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.form-section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; color: var(--primary); }
.form-section-title:first-child { margin-top: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 5px; margin-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-link {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: #eef2ff;
    flex-shrink: 0;
}
.stat-icon.books { background: #e0e7ff; }
.stat-icon.members { background: #dcfce7; }
.stat-icon.issued { background: #fef3c7; }
.stat-icon.overdue { background: #fee2e2; }
.stat-icon.success-icon { background: #dcfce7; }
.stat-icon.danger-icon { background: #fee2e2; }

.stat-info h3 { font-size: 20px; }
.stat-info p { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Card / Table ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 25px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header.filters { gap: 12px; flex-wrap: wrap; }
.card-body-pad { padding: 20px; }

.card-header input[type="text"], .card-header input[type="date"], .card-header select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    min-width: 200px;
}

.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th, .data-table td {
    padding: 12px 18px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th { color: var(--text-muted); font-weight: 600; background: #fafafa; }
.data-table tbody tr:hover { background: #f9fafb; }

.text-center { text-align: center !important; color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-block { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
}
.btn-icon:hover { background: #f3f4f6; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 15px; flex: 1; }
.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row .form-group { min-width: 200px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal.show { display: flex; }

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 520px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-close { cursor: pointer; font-size: 22px; color: var(--text-muted); }

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(10px);
    transition: 0.3s;
    z-index: 999;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ---------- ID Card ---------- */
.id-card {
    width: 340px;
    border: 2px solid var(--primary);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.id-card-header {
    background: var(--primary);
    color: #fff;
    text-align: center;
    padding: 12px;
}
.id-card-header h4 { font-size: 14px; }
.id-card-header p { font-size: 10px; opacity: 0.9; margin-top: 2px; }
.id-card-body { display: flex; gap: 14px; padding: 16px; align-items: flex-start; }
.id-card-photo {
    width: 80px; height: 90px;
    background: #eef2ff;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.id-card-info h3 { font-size: 15px; margin-bottom: 6px; }
.id-card-info p { font-size: 11.5px; margin-bottom: 3px; color: var(--text); }
.id-card-footer { text-align: center; background: #f4f5fa; padding: 8px; font-size: 10px; color: var(--text-muted); }

/* ---------- Marksheet ---------- */
.marksheet { max-width: 650px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 25px; }
.marksheet-header { text-align: center; margin-bottom: 18px; border-bottom: 2px solid var(--primary); padding-bottom: 12px; }
.marksheet-header h3 { font-size: 18px; }
.marksheet-header p { font-size: 12px; color: var(--text-muted); }
.marksheet-header h4 { margin-top: 8px; font-size: 14px; letter-spacing: 1px; }
.marksheet-info p { font-size: 13px; margin-bottom: 5px; }
.marksheet-info { margin-bottom: 15px; }
.marksheet-summary { margin-top: 15px; display: flex; gap: 25px; flex-wrap: wrap; }
.marksheet-summary p { font-size: 14px; }

/* ---------- Fee Collection hints ---------- */
.due-hint {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 15px;
}
.due-hint a { color: var(--primary); font-weight: 600; }

.field-hint { display: block; margin-top: 4px; font-size: 12px; }
.hint-error { color: var(--danger); font-weight: 600; }
.hint-ok { color: var(--success); font-weight: 600; }

/* ---------- Student Fee Profile ---------- */
.profile-header {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 20px;
}
.profile-photo {
    width: 90px; height: 90px;
    border-radius: 50%;
    background: #eef2ff;
    display: flex; align-items: center; justify-content: center;
    font-size: 38px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.profile-details h3 { font-size: 19px; margin-bottom: 6px; }
.profile-details p { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.profile-details p strong { color: var(--text); }

.fee-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    padding: 0 20px 20px;
}
.fee-summary-box {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}
.fee-summary-box h4 { font-size: 20px; }
.fee-summary-box p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.fee-summary-box.due h4 { color: var(--danger); }
.fee-summary-box.paid h4 { color: var(--success); }

/* ---------- Receipt ---------- */
.receipt {
    max-width: 550px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 25px;
    margin: 0 auto;
}
.receipt-header { text-align: center; border-bottom: 2px solid var(--primary); padding-bottom: 12px; margin-bottom: 15px; }
.receipt-header h3 { font-size: 18px; }
.receipt-header p { font-size: 12px; color: var(--text-muted); }
.receipt-header h4 { margin-top: 8px; font-size: 14px; letter-spacing: 1px; color: var(--primary); }
.receipt-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.receipt-row strong { color: var(--text); }
.receipt-total { display: flex; justify-content: space-between; padding: 12px 0; font-size: 16px; font-weight: 700; margin-top: 10px; border-top: 2px solid var(--text); }
.receipt-footer { text-align: center; margin-top: 20px; font-size: 11px; color: var(--text-muted); }

@media print {
    .sidebar, .topbar, .no-print, .page-title, .page-subtitle, .card:not(.printable) { display: none !important; }
    .page-body { padding: 0; }
    body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 50; transition: 0.3s; }
    .sidebar.open { left: 0; }
    .toggle-btn { display: block; }
    .form-row { flex-direction: column; gap: 0; }
}
