@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-glass: #ffffff;
    --bg-hover: #f1f5f9;
    --border-color: #cbd5e1;
    --border-glow: #94a3b8;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent: #1e40af;
    --accent-light: #2563eb;
    --accent-gold: #d97706;
    --accent-glow: rgba(37, 99, 235, 0.12);
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --info: #0284c7;
    --gradient-1: linear-gradient(135deg, #1e40af 0%, #1d4ed8 50%, #2563eb 100%);
    --gradient-2: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 4px 16px rgba(30, 64, 175, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* College Logo Styling */
.college-logo-img {
    height: 58px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
    border-radius: var(--radius-sm);
    transition: transform 0.3s ease;
    background: #ffffff;
    padding: 3px;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.college-logo-img:hover {
    transform: scale(1.05);
}

/* Header - Deep Royal Navy Blue Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #0f172a;
    border-bottom: 3px solid #1e40af;
    padding: 16px 32px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Main Title & Subtitle in Bright White Color */
.header-title h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff !important;
    letter-spacing: -0.01em;
}

.header-title p {
    font-size: 0.85rem;
    color: #ffffff !important;
    font-weight: 500;
    opacity: 0.95;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search Box */
.search-container {
    position: relative;
}

.search-container svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.search-input {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    padding: 10px 16px 10px 42px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    width: 320px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: #94a3b8;
}

.search-input:focus {
    border-color: #3b82f6;
    background: #0f172a;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Professional Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: #1e40af;
    color: white;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35);
}

.btn-success {
    background: #059669;
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.btn-outline {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    border-color: #1e40af;
    color: #1e40af;
    background: #f1f5f9;
}

.btn-danger {
    background: #dc2626;
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Stats Bar */
.stats-bar {
    max-width: 1600px;
    margin: 24px auto;
    padding: 0 32px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    position: relative;
    z-index: 1;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.total {
    background: #eff6ff;
    color: #1e40af;
}

.stat-icon.present {
    background: #ecfdf5;
    color: #059669;
}

.stat-icon.absent {
    background: #fef2f2;
    color: #dc2626;
}

.stat-icon.unwilling {
    background: #fffbeb;
    color: #d97706;
}

.stat-icon.unmarked {
    background: #f1f5f9;
    color: #475569;
}

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    color: #0f172a;
}

.stat-info p {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 32px 40px;
    position: relative;
    z-index: 1;
}

/* Table Container */
.table-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.table-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-title .badge {
    background: #eff6ff;
    color: #1e40af;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid #bfdbfe;
}

.table-actions {
    display: flex;
    gap: 10px;
}

/* Table Styling */
.table-scroll {
    overflow-x: auto;
    max-height: 68vh;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: #ffffff;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

thead th {
    background: #f1f5f9;
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
}

thead th:first-child {
    padding-left: 24px;
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.present-row {
    background: #f0fdf4;
}

tbody tr.absent-row {
    background: #fef2f2;
}

tbody tr.unwilling-row {
    background: #fffbeb;
}

tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    white-space: nowrap;
    color: #1e293b;
}

tbody td:first-child {
    padding-left: 24px;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 4px 10px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.8rem;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.name-cell {
    font-weight: 600;
    color: #0f172a;
}

.community-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.community-badge.oc { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.community-badge.bc { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }
.community-badge.bcm { background: #ecfeff; color: #0891b2; border: 1px solid #a5f3fc; }
.community-badge.mbc { background: #faf5ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.community-badge.sc { background: #fdf2f8; color: #be185d; border: 1px solid #fbcfe8; }
.community-badge.sca { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }
.community-badge.st { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* Part 3 Mark Editable */
.part3-cell {
    position: relative;
}

.part3-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 700;
    color: #0f172a;
    min-width: 80px;
}

.part3-value:hover {
    border-color: #1e40af;
    background: #eff6ff;
}

.part3-value .edit-icon {
    opacity: 0;
    transition: opacity 0.2s;
    color: #1e40af;
    font-size: 12px;
}

.part3-value:hover .edit-icon {
    opacity: 1;
}

.part3-input {
    width: 90px;
    padding: 6px 12px;
    border: 2px solid #1e40af;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: #0f172a;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.2);
}



/* Attendance Toggle Buttons */
.attendance-toggle {
    display: flex;
    gap: 6px;
}

.toggle-btn {
    padding: 6px 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #ffffff;
    color: #64748b;
}

.toggle-btn.present-btn:hover,
.toggle-btn.present-btn.active {
    background: #059669;
    border-color: #059669;
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.toggle-btn.absent-btn:hover,
.toggle-btn.absent-btn.active {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.toggle-btn.unwilling-btn:hover,
.toggle-btn.unwilling-btn.active {
    background: #d97706;
    border-color: #d97706;
    color: white;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}

/* Modal View */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
}

.modal-header .total-badge {
    background: #ecfdf5;
    color: #059669;
    padding: 4px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid #a7f3d0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}

.modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 28px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    min-width: 280px;
}

.toast.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
}

.toast.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.toast.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: #64748b;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: #334155;
}

/* Print Hidden Area */
#printArea {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 8mm 6mm 10mm 6mm;
        @bottom-right {
            content: "Page " counter(page) " of " counter(pages);
            font-family: 'Times New Roman', Times, serif;
            font-size: 10pt;
            font-weight: bold;
        }
        @bottom-left {
            content: "M.Sc CS Admission 2026-2027";
            font-family: 'Times New Roman', Times, serif;
            font-size: 9pt;
        }
    }

    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        min-width: 950px !important;
        box-shadow: none !important;
        font-family: 'Times New Roman', Times, serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Hide Web App Interface Components */
    header, .header, .stats-bar, .main-content, .matrix-card, .table-container, .modal, .modal-overlay, .toast-container, button, .btn {
        display: none !important;
    }

    /* Show Print Content Only */
    #printArea {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 100% !important;
        min-width: 950px !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    #printArea table {
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    #printArea table th,
    #printArea table td {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
    }

    #printArea tr {
        page-break-inside: avoid !important;
        page-break-after: auto;
    }

    #printArea thead {
        display: table-header-group !important;
    }
}

/* Quota Status Card */
.quota-status-card .quota-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.quota-status-card .quota-table th,
.quota-status-card .quota-table td {
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    text-align: center;
}

.quota-status-card .quota-table th {
    background: var(--bg-glass);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.quota-status-card .quota-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.quota-status-card .quota-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.75rem;
}


/* ============================================================
   ROLE-BASED ACCESS CONTROL — Scholar Mode
   ============================================================ */

/* Admin-only: hidden when scholar is logged in (via auth.js adding .role-scholar to body) */
body.role-scholar .admin-only {
    display: none !important;
}

/* Scholar-only: shown only when scholar is logged in */
body.role-admin .scholar-only {
    display: none !important;
}

/* Scholar: Disable Part 3 mark click */
body.role-scholar .part3-value {
    cursor: default !important;
    pointer-events: none !important;
}
body.role-scholar .edit-icon {
    display: none !important;
}

/* Scholar: hide special quota column cells (dynamic rows) */
body.role-scholar .special-quota-cell {
    display: none !important;
}

/* Scholar: Save Attendance button — flex display when shown */
body.role-scholar .scholar-only.btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
}

/* ============================================================
   RESPONSIVE DESIGN — Mobile & Tablet Support
   ============================================================ */

@media (max-width: 1024px) {
    .header {
        padding: 16px 20px;
    }
    .header-title h1 {
        font-size: 1.15rem;
    }
    .header-title p {
        font-size: 0.78rem;
    }
}

@media (max-width: 768px) {
    /* Layout padding */
    .main-content {
        padding: 0 16px 30px;
    }

    /* Header collapse */
    .header {
        padding: 14px 16px;
    }
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .header-left {
        gap: 12px;
    }
    .college-logo-img {
        height: 48px;
    }
    
    /* Header actions vertical stack */
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }
    .search-container {
        width: 100%;
        max-width: none;
    }
    .search-input {
        width: 100% !important;
    }
    .header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Stats Bar Grid adjustment */
    .stats-bar {
        padding: 0 16px;
        margin: 16px auto;
        gap: 10px;
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .stat-card {
        padding: 12px 14px;
        gap: 10px;
    }
    .stat-icon {
        width: 38px;
        height: 38px;
    }
    .stat-icon svg {
        width: 16px !important;
        height: 16px !important;
    }
    .stat-info h3 {
        font-size: 1.25rem;
    }
    .stat-info p {
        font-size: 0.65rem;
    }

    /* Table Toolbar */
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 14px 16px;
    }
    .table-title {
        font-size: 0.95rem;
    }
    .table-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }
    .table-actions .btn {
        width: 100% !important;
        justify-content: center;
        margin: 0 !important;
        padding: 10px 14px !important;
        font-size: 0.8rem !important;
    }

    /* Quota selection columns wrap */
    .quota-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 10px !important;
    }
}

@media (max-width: 480px) {
    /* Stats Bar stacked on portrait mobile */
    .stats-bar {
        grid-template-columns: 1fr !important;
    }
    .header-title h1 {
        font-size: 1rem;
        text-align: center;
    }
    .header-title p {
        font-size: 0.72rem;
        text-align: center;
    }
    .header-left {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* Custom Logout Button Injected via JS */
.logout-btn-header {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 32px;
    padding: 7px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #f87171;
    border: 1px solid #f87171;
    border-radius: 6px;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    z-index: 105;
    transition: all 0.2s ease;
}

.logout-btn-header:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.header-left {
    margin-left: 110px; /* Make space for logout on desktop */
}

@media (max-width: 1024px) {
    .logout-btn-header {
        left: 20px;
    }
    .header-left {
        margin-left: 100px;
    }
}

@media (max-width: 768px) {
    .logout-btn-header {
        top: 14px;
        left: 16px;
        right: auto;
        transform: none;
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    .header-left {
        margin-left: 0;
        margin-top: 36px; /* Shift down to avoid overlap with logout on mobile */
    }
}

