/* ==========================================================================
   NKVV DIGITAL LIBRARY CORE PRODUCTION STYLESHEET
   ========================================================================== */

:root {
    --bg-dark-primary: #0f172a;
    --bg-dark-secondary: #1e293b;
    --bg-card-light: #ffffff;
    --accent-student: #1e40af;
    --accent-staff: #065f46;
    --accent-admin: #991b1b;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --gold: #d97706;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-dark-primary);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   1. UNIFIED AUTHENTICATION MATRIX STYLING (Fixes Screenshot Layout Issues)
   ========================================================================== */

.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.auth-card {
    background: var(--bg-card-light);
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.4s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header img {
    object-fit: contain;
    margin-bottom: 12px;
}

.auth-header h2 {
    color: #1e293b;
    font-size: 1.8rem;
    font-weight: 700;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Auth Navigation Tabs Grid Layout */
.auth-tabs-navigation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: var(--bg-card-light);
    color: #1e293b;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Input Form Controls */
.auth-sub-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: fadeIn 0.3s ease-in-out;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.5px;
}

.input-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1rem;
}

.input-field-wrapper input,
.input-group input,
.styled-select-menu {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
    color: #1e293b;
    background: #f8fafc;
}

.input-field-wrapper input {
    padding-left: 40px;
}

.input-field-wrapper input:focus,
.input-group input:focus,
.styled-select-menu:focus {
    border-color: #64748b;
    background: #ffffff;
}

.input-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Action Buttons per Role Matrix */
.btn-unlock {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: filter 0.2s ease, transform 0.1s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-unlock:active {
    transform: scale(0.99);
}

.student-accent-btn { background-color: var(--accent-student); }
.staff-accent-btn { background-color: var(--accent-staff); }
.admin-accent-btn { background-color: var(--accent-admin); }

.btn-unlock:hover {
    filter: brightness(1.15);
}

.auth-toggle-hint {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.auth-toggle-hint span {
    color: var(--accent-student);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
}

.otp-alert-badge {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    color: var(--accent-admin);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ==========================================================================
   2. DASHBOARD FRAMEWORK LAYOUT (Sidebar + Main Content Viewport)
   ========================================================================== */

.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

aside.side-navigation-panel {
    background-color: var(--bg-dark-secondary);
    border-right: 1px solid #334155;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    width: 260px;
    height: 100vh;
}

.sidebar-brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
}

.sidebar-brand-block h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-links-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 30px;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
    background: #334155;
    color: #ffffff;
}

.sidebar-footer-profile {
    border-top: 1px solid #334155;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-meta-display h4 {
    color: #ffffff;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    display: inline-block;
    font-size: 0.75rem;
    background: #475569;
    color: #f8fafc;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.btn-logout-sidebar {
    background: #334155;
    color: #f1f5f9;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-logout-sidebar:hover {
    background: #ef4444;
}

/* Viewport Scroll Setup */
main.dashboard-viewport-contents {
    margin-left: 260px;
    padding: 40px;
    background-color: #f8fafc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ==========================================================================
   3. UPPER HEADER METRICS & FILTERS
   ========================================================================== */

.dashboard-top-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.search-bar-box {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar-box input {
    width: 100%;
    padding: 14px 14px 14px 46px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    background: #ffffff;
}

.metrics-row-wrapper {
    display: flex;
    gap: 15px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.metric-card i { font-size: 1.5rem; }
.reader-blue-icon { color: var(--accent-student); }
.books-gold-icon { color: var(--gold); }

.metric-info span {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
    display: block;
}

.metric-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ==========================================================================
   4. READING ENGINE AND SYSTEM CARDS
   ========================================================================== */

.staff-incentive-alert {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.incentive-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.incentive-left i { font-size: 1.8rem; }
.text-gold-icon { color: var(--gold); }

.incentive-left h4 { color: #064e3b; font-size: 1.05rem; }
.incentive-left p { color: #047857; font-size: 0.88rem; }

.btn-incentive-action {
    background: var(--accent-staff);
    color: #ffffff;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Book Catalog Grid Shelves Layout */
.catalog-category-shelf {
    margin-bottom: 35px;
}

.shelf-title {
    font-size: 1.3rem;
    color: #1e293b;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-student);
    padding-left: 10px;
}

.books-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 25px;
}

.book-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.book-cover-wrap {
    width: 100%;
    height: 220px;
    background: #f1f5f9;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.book-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-details h4 {
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-details p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.btn-read-book {
    width: 100%;
    background: #f1f5f9;
    border: none;
    color: #1e293b;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.book-card:hover .btn-read-book {
    background: var(--accent-student);
    color: #ffffff;
}

/* ==========================================================================
   5. DATA TABLES (Leaderboards & Admin Audit Ledgers)
   ========================================================================== */

.viewport-data-view {
    animation: fadeIn 0.3s ease-in-out;
}

.leaderboard-panel-layout, .admin-panel-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.leaderboard-header-branding, .admin-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 25px;
}

.leaderboard-header-branding i, .admin-card-header i { font-size: 2rem; }
.award-gold-icon { color: var(--gold); }

.styled-leaderboard-table, .admin-audit-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin-top: 15px;
}

.styled-leaderboard-table th, .admin-audit-table th {
    background: #f8fafc;
    padding: 14px 16px;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 2px solid #e2e8f0;
}

.styled-leaderboard-table td, .admin-audit-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    color: #334155;
}

.styled-leaderboard-table tr:hover, .admin-audit-table tr:hover {
    background: #f8fafc;
}

/* Admin Specific Panel Grid Styles */
.admin-dashboard-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.form-input-grid-triple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.form-input-grid-double {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.admin-input-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    display: block;
    margin-bottom: 6px;
}

.admin-input-group input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: #f8fafc;
}

.btn-publish-book {
    background: var(--accent-staff);
    color: #ffffff;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.admin-card-header-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.audit-filter-badges {
    display: flex;
    gap: 8px;
}

.filter-badge {
    background: #f1f5f9;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.filter-badge.active {
    background: #1e293b;
    color: #ffffff;
}

.audit-search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.audit-search-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.audit-search-wrapper input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
}

.audit-table-viewport-scroller {
    max-height: 400px;
    overflow-y: auto;
}

/* ==========================================================================
   6. PDF STREAMING PREVIEW MODAL
   ========================================================================== */

.reader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 25px;
}

.reader-container-card {
    background: #ffffff;
    width: 100%;
    max-width: 1100px;
    height: 90vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.reader-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-red-icon { color: #ef4444; font-size: 1.4rem; }

.close-reader-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.close-reader-btn:hover { color: #ef4444; }

.reader-body-viewport {
    flex-grow: 1;
    background: #475569;
}

.reader-body-viewport iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   7. FOOTER AND ANIMATION DECORATIONS
   ========================================================================== */

.portal-footer {
    margin-top: auto;
    padding-top: 30px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.credit-tag { margin-top: 4px; }
.heart-icon { color: #ef4444; }
.portal-footer a { color: var(--accent-student); text-decoration: none; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Fallback Shield */
@media(max-width: 768px) {
    .dashboard-layout { grid-template-columns: 1fr; }
    aside.side-navigation-panel { display: none; }
    main.dashboard-viewport-contents { margin-left: 0; padding: 20px; }
    .form-input-grid-triple, .form-input-grid-double, .input-row-grid { grid-template-columns: 1fr; }
}

/* ==========================================
   PDF.JS READER IMPROVEMENTS
========================================== */

#pdfCanvas {
    max-width: 100%;
    height: auto;
    background: white;
    box-shadow: 0 10px 25px rgba(0,0,0,.15);
    border-radius: 8px;
}

.reader-header-bar button {
    margin-left: 8px;
}

#pageInfo {
    color: #64748b;
    font-size: .9rem;
}

/* ==========================================
   TOAST
========================================== */

#globalToast {
    min-width: 250px;
    box-shadow: 0 10px 25px rgba(0,0,0,.25);
    animation: slideUp .25s ease;
}

@keyframes slideUp {

    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   GLOBAL LOADER
========================================== */

#globalLoader {

    backdrop-filter: blur(4px);

    color: #0f172a;

    font-weight: 700;

    flex-direction: column;

    gap: 15px;
}

#globalLoader::before {

    content: "";

    width: 50px;

    height: 50px;

    border-radius: 50%;

    border: 5px solid #e2e8f0;

    border-top-color: #2563eb;

    animation: spin .8s linear infinite;
}

@keyframes spin {

    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   EMPTY STATES
========================================== */

.empty-state {

    text-align: center;

    padding: 50px 20px;

    color: #64748b;
}

.empty-state i {

    font-size: 50px;

    margin-bottom: 15px;

    opacity: .4;
}

/* ==========================================
   BOOK CARD ENHANCEMENTS
========================================== */

.book-card {

    overflow: hidden;
}

.book-card img {

    transition: transform .3s ease;
}

.book-card:hover img {

    transform: scale(1.05);
}

.book-details {

    min-height: 70px;
}

.book-details h4 {

    line-height: 1.3;
}

/* ==========================================
   ADMIN STATS GRID
========================================== */

.analytics-grid {

    display: grid;

    grid-template-columns:
    repeat(auto-fit,minmax(220px,1fr));

    gap: 20px;
}

.analytics-card {

    background: white;

    padding: 25px;

    border-radius: 14px;

    border: 1px solid #e2e8f0;

    box-shadow: 0 4px 15px rgba(0,0,0,.04);
}

.analytics-card h3 {

    font-size: .85rem;

    color: #64748b;

    margin-bottom: 10px;
}

.analytics-card span {

    font-size: 2rem;

    font-weight: 700;

    color: #0f172a;
}

/* ==========================================
   SEARCH IMPROVEMENTS
========================================== */

.search-bar-box input:focus {

    border-color: #2563eb;

    box-shadow:
    0 0 0 3px rgba(37,99,235,.15);
}

/* ==========================================
   TABLE RESPONSIVE
========================================== */

.audit-table-viewport-scroller {

    overflow-x: auto;
}

.admin-audit-table {

    min-width: 700px;
}

/* ==========================================
   MOBILE MENU
========================================== */

.mobile-menu-btn {

    display: none;
}

/* ==========================================
   MOBILE RESPONSIVE
========================================== */

@media (max-width: 1024px) {

    .dashboard-top-stats-bar {

        flex-direction: column;

        align-items: stretch;
    }

    .metrics-row-wrapper {

        width: 100%;

        flex-wrap: wrap;
    }

    .metric-card {

        flex: 1;
    }
}

@media (max-width: 768px) {

    .auth-card {

        padding: 25px 20px;
    }

    .books-grid-layout {

        grid-template-columns:
        repeat(auto-fill,minmax(140px,1fr));

        gap: 15px;
    }

    .book-cover-wrap {

        height: 190px;
    }

    .reader-header-bar {

        flex-direction: column;

        gap: 15px;

        align-items: flex-start;
    }

    .reader-header-bar button {

        margin-top: 5px;
    }

    .portal-footer {

        flex-direction: column;

        gap: 10px;

        text-align: center;
    }
}

@media (max-width: 480px) {

    .auth-tabs-navigation {

        grid-template-columns: 1fr;
    }

    .metric-card {

        width: 100%;
    }

    .books-grid-layout {

        grid-template-columns:
        repeat(2,1fr);
    }

    .book-cover-wrap {

        height: 160px;
    }

    .shelf-title {

        font-size: 1.1rem;
    }
}

/* ==========================================
   CUSTOM SCROLLBAR
========================================== */

::-webkit-scrollbar {

    width: 10px;
}

::-webkit-scrollbar-track {

    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {

    background: #94a3b8;

    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {

    background: #64748b;
}