:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-border: #334155;
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #94a3b8;
    --sidebar-active: #3b82f6;
    --topbar-height: 64px;
    --body-bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
    --transition: 0.22s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--body-bg);
}

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

/* ── App shell ── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 72px;
}

.sidebar-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.app-shell.sidebar-collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

.sidebar-brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    color: var(--sidebar-text-muted);
}

.sidebar-toggle {
    margin: 12px 16px 4px;
    padding: 8px 12px;
    background: var(--sidebar-bg-hover);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 32px);
    transition: background var(--transition);
}

.sidebar-toggle:hover {
    background: #334155;
}

.sidebar-toggle .toggle-label {
    white-space: nowrap;
    transition: opacity var(--transition);
}

.app-shell.sidebar-collapsed .sidebar-toggle .toggle-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    padding: 12px 12px 6px;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.app-shell.sidebar-collapsed .sidebar-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.sidebar-link:hover {
    background: var(--sidebar-bg-hover);
    color: #f8fafc;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg, rgba(59, 130, 246, 0.18));
    color: var(--sidebar-active-text, #93c5fd);
}

.sidebar-link .icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.sidebar-link .label {
    transition: opacity var(--transition);
}

.app-shell.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 11px;
}

.app-shell.sidebar-collapsed .sidebar-link .label {
    display: none;
}

.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: var(--sidebar-bg-hover);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    min-width: 0;
}

.app-shell.sidebar-collapsed .sidebar-user-info {
    display: none;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: var(--sidebar-text-muted);
    text-transform: capitalize;
}

.sidebar-logout {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background var(--transition);
}

.sidebar-logout:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    border-color: rgba(220, 38, 38, 0.3);
}

.app-shell.sidebar-collapsed .sidebar-logout .label {
    display: none;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1035;
}

/* ── Main area ── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.app-shell.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text);
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.topbar-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 2px 0 0;
}

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

/* ── Components ── */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.card-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
}

.action-card .action-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.action-card.primary .action-icon { background: #dbeafe; }
.action-card.success .action-icon { background: #dcfce7; }
.action-card.warning .action-icon { background: #fef3c7; }

.action-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.action-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    flex: 1;
}

.btn-app {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform 0.15s ease;
}

.btn-app:active { transform: scale(0.98); }

.btn-primary-app {
    background: var(--primary);
    color: #fff;
}

.btn-primary-app:hover { background: var(--primary-hover); color: #fff; }

.btn-outline-app {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline-app:hover {
    background: var(--body-bg);
}

.btn-success-app { background: var(--success); color: #fff; }
.btn-danger-app { background: var(--danger); color: #fff; }
.btn-warning-app { background: var(--warning); color: #fff; }
.btn-sm-app { padding: 6px 12px; font-size: 0.8rem; }

.alert-app {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success-app {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger-app {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-bar input,
.filter-bar select,
.form-control-app {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
}

.filter-bar input:focus,
.filter-bar select:focus,
.form-control-app:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Table */
.table-app {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table-app th {
    text-align: left;
    padding: 12px 14px;
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

.table-app td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table-app tbody tr:hover {
    background: #f8fafc;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.badge-app {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e0e7ff;
    color: #3730a3;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.chart-card h4 {
    margin: 0 0 16px;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Pagination override */
.pagination { margin: 0; }

/* ── Guest / auth pages ── */
.guest-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

.guest-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}

.guest-card .logo-wrap {
    text-align: center;
    margin-bottom: 24px;
}

.guest-card .logo-wrap img {
    max-width: 160px;
    height: auto;
}

.guest-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin: 0 0 6px;
}

.guest-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 28px;
    font-size: 0.95rem;
}

.form-group-app {
    margin-bottom: 16px;
}

.form-group-app label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group-app input,
.form-group-app select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
}

.form-group-app input:focus,
.form-group-app select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.guest-links {
    text-align: center;
    margin-top: 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.guest-links a {
    color: var(--primary);
    font-weight: 600;
}

/* Landing page */
.landing-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 45%, #f1f5f9 100%);
    color: var(--text);
    display: flex;
    flex-direction: column;
}

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 40px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.landing-nav img { height: 48px; }

.landing-nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.landing-nav-links a {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
}

.landing-nav-links a.ghost {
    color: var(--text-muted);
}

.landing-nav-links a.ghost:hover {
    background: var(--body-bg);
    color: var(--text);
}

.landing-nav-links a.solid {
    background: var(--primary);
    color: #fff;
}

.landing-nav-links a.solid:hover {
    background: var(--primary-hover);
    color: #fff;
}

.landing-main {
    flex: 1;
}

.landing-hero {
    max-width: 1180px;
    margin: 0 auto;
    padding: 48px 24px 32px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
}

.landing-hero-content {
    text-align: left;
}

.landing-video-panel {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
    border: 1px solid var(--border);
    background: #0f172a;
}

.landing-video-panel video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.landing-hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin: 0 0 16px;
    line-height: 1.15;
    color: var(--text);
}

.landing-eyebrow {
    display: inline-block;
    margin: 0 0 16px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.landing-lead {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin: 0 0 32px;
    line-height: 1.7;
}

.landing-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
}

.landing-btn-primary {
    padding: 14px 28px;
}

.landing-btn-secondary {
    padding: 14px 28px;
    background: #fff;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    text-align: left;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px 48px;
}

.landing-feature {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.landing-feature-icon {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #eff6ff;
    font-size: 1.25rem;
    margin-bottom: 14px;
}

.landing-feature h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.landing-feature p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.landing-footer {
    padding: 24px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.6);
}

.landing-footer p { margin: 0; }

.role-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.role-pill {
    padding: 8px 20px;
    border-radius: 999px;
    border: 2px solid var(--border);
    background: transparent;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all var(--transition);
}

.role-pill.active {
    color: #fff;
    border-color: transparent;
}

.role-pill[data-role="student"].active { background: var(--primary); }
.role-pill[data-role="faculty"].active { background: var(--success); }
.role-pill[data-role="librarian"].active { background: #7c3aed; }

.hidden { display: none !important; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.65);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

/* Mobile */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .app-shell.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .mobile-menu-btn { display: block; }

    .sidebar-toggle { display: none; }

    .app-shell.sidebar-collapsed .sidebar-link .label,
    .app-shell.sidebar-collapsed .sidebar-brand-text,
    .app-shell.sidebar-collapsed .sidebar-user-info {
        display: block;
        opacity: 1;
        width: auto;
    }

    .app-shell.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 11px 14px;
    }

    .landing-nav { padding: 12px 20px; }

    .landing-hero {
        grid-template-columns: 1fr;
        padding-top: 32px;
    }

    .landing-hero-content {
        text-align: center;
    }

    .landing-cta {
        justify-content: center;
    }

    .landing-video-panel {
        order: -1;
        max-width: 520px;
        margin: 0 auto;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .main-content { padding: 16px; }
    .filter-bar { flex-direction: column; }
    .filter-bar input, .filter-bar select { width: 100%; }
    .guest-card { padding: 28px 20px; }
}

/* Bootstrap pagination (used by Laravel links) */
.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-item .page-link {
    display: block;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    background: var(--surface);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
}

/* Form pages */
.page-header-actions {
    margin-bottom: 16px;
}

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

.page-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-import-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.inline-import-form input[type="file"] {
    max-width: 220px;
    padding: 8px;
}

.form-page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
}

.form-card {
    max-width: none;
}

.form-aside {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    margin: 0 0 16px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-hint {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.role-guide-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.6;
}

.role-guide-list li {
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    .form-page-grid {
        grid-template-columns: 1fr;
    }

    .form-row-2 {
        grid-template-columns: 1fr;
    }
}
