/* SmartLab Modern Full-Fit Viewport Stylesheet */

:root {
    --primary-color: #1e3c72;
    --primary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --secondary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    --card-radius: 10px;
    --header-height: 54px;
    --footer-height: 40px;
}

/* 1. Global Viewport Fit Architecture (Both Horizontally & Vertically) */
html, body {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Lock window scrollbar to fit entire app in screen */
    background-color: #f4f6f9;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333333;
}

body {
    display: flex;
    flex-direction: column;
}

/* 2. Top Interactive Header */
.navbar-smartlab {
    flex: 0 0 var(--header-height);
    height: var(--header-height);
    background: var(--primary-gradient);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    padding: 0;
    z-index: 1030;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    font-size: 1.15rem;
}

.navbar-smartlab .nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 10px !important;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.navbar-smartlab .nav-link:hover,
.navbar-smartlab .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
}

.navbar-smartlab .dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 6px 0;
    font-size: 0.88rem;
}

.navbar-smartlab .dropdown-item {
    padding: 7px 16px;
}

.navbar-smartlab .dropdown-item:hover {
    background-color: #f0f4f9;
}

.user-nav-name {
    max-width: 160px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        background: #172d54;
        padding: 14px 18px;
        border-radius: 8px;
        margin-top: 8px;
        max-height: calc(100vh - 75px);
        overflow-y: auto;
        box-shadow: 0 10px 25px rgba(0,0,0,0.35);
    }
    .user-nav-name {
        max-width: 200px;
    }
}

/* 3. Main Content App Container (Auto-Fitting Vertical Height & Full Width) */
.app-container {
    flex: 1 1 auto;
    height: calc(100vh - var(--header-height) - var(--footer-height));
    max-height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 16px;
    padding-bottom: 20px;
    width: 100%;
}

.container-custom {
    width: 100%;
    max-width: 100%;
    padding-left: 20px;
    padding-right: 20px;
}

@media (min-width: 1600px) {
    .container-custom {
        padding-left: 32px;
        padding-right: 32px;
    }
}

@media (max-width: 768px) {
    .container-custom {
        padding-left: 12px;
        padding-right: 12px;
    }
    .app-container {
        padding-top: 12px;
    }
}

/* 4. Fit-Screen Cards & Sticky Tables */
.card-custom {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    background: #ffffff;
    margin-bottom: 1rem;
}

.card-header-custom {
    background-color: #ffffff;
    border-bottom: 1px solid #edf2f7;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

/* Table container that locks height and allows internal vertical scroll */
.table-responsive,
.table-responsive-fit {
    max-height: calc(100vh - 270px);
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

.table-responsive thead th,
.table-responsive-fit thead th,
.table-hover thead th,
.table thead th {
    position: sticky;
    top: 0;
    background-color: #f8fafc !important;
    z-index: 5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* 5. Stat Cards */
.stat-card {
    border-radius: 12px;
    border: none;
    overflow: hidden;
    color: white;
    padding: 16px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.stat-card .stat-icon {
    position: absolute;
    right: 12px;
    bottom: 10px;
    font-size: 3rem;
    opacity: 0.22;
}

.stat-card.stat-primary { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); }
.stat-card.stat-success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-card.stat-warning { background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%); }
.stat-card.stat-danger  { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); }
.stat-card.stat-info    { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

/* 6. Kiosk Live Scanner Fit-to-Screen */
.kiosk-scanner-container {
    background: #111827;
    border-radius: 14px;
    padding: 18px;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.scanner-viewport {
    background: #000000;
    border: 2px dashed #3b82f6;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    height: 220px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-laser-line {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 3px;
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
    animation: scanAnim 2s infinite ease-in-out;
}

@keyframes scanAnim {
    0% { top: 15%; opacity: 0.8; }
    50% { top: 85%; opacity: 1; }
    100% { top: 15%; opacity: 0.8; }
}

.scan-result-card {
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scan-result-card.scan-success {
    border: 2px solid #10b981;
    background: #f0fdf4;
    animation: pulseSuccess 0.5s ease;
}

.scan-result-card.scan-error {
    border: 2px solid #ef4444;
    background: #fef2f2;
    animation: shakeError 0.4s ease;
}

@keyframes pulseSuccess {
    0% { transform: scale(0.96); opacity: 0.8; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* 7. Modal Viewport Fit Rules */
.modal-dialog {
    max-height: 90vh;
}

.modal-dialog .modal-content {
    border-radius: 12px;
    overflow: hidden;
    border: none;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.modal-dialog .modal-body {
    max-height: calc(85vh - 120px);
    overflow-y: auto;
}

/* 8. Modern Sleek Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 9. Badge & Print Styling */
.badge-role {
    font-size: 0.72rem;
    padding: 3px 7px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

@media print {
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
    }
    .app-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .no-print, .navbar-smartlab, .footer-smartlab {
        display: none !important;
    }
    .id-card-print {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* 10. Student ID Card Component */
.student-id-card {
    width: 320px;
    height: 480px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    display: inline-block;
    margin: 10px;
    text-align: center;
    position: relative;
}

.student-id-card .id-header {
    background: var(--primary-gradient);
    color: white;
    padding: 16px 12px;
}

.student-id-card .id-avatar {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    border: 4px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    margin-top: -35px;
    background: #e2e8f0;
    object-fit: cover;
}

.student-id-card .id-barcode-box {
    background: #f8fafc;
    padding: 10px;
    border-top: 1px dashed #cbd5e1;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

/* 11. Docked Fit Footer */
.footer-smartlab {
    flex: 0 0 var(--footer-height);
    height: var(--footer-height);
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 8px 0;
    color: #6b7280;
    font-size: 0.82rem;
    z-index: 1020;
    display: flex;
    align-items: center;
}
