/* 
 * Premium Design System V5 for Library Management System
 * Indigo/Slate palette · Battambang (KH) + Outfit (EN) Typography
 * Modern glass-morphism · Micro-animations · Responsive
 */

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

/* ── Design Tokens ── */
:root {
    --primary: #1a56a8;
    --primary-hover: #154a91;
    --primary-light: rgba(26, 86, 168, 0.1);
    --primary-gradient: linear-gradient(135deg, #1a3f7a 0%, #1a56a8 50%, #2563eb 100%);
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@view-transition {
    navigation: auto;
}

/* ── Base & Typography ── */
html,
body {
    height: 100%;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    animation: pageIn 0.5s ease-out;
}

.page-wrapper {
    flex: 1 0 auto;
    opacity: 1;
    transform: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    view-transition-name: page-content;
}

body.page-is-leaving .page-wrapper {
    opacity: 0;
    transform: translateY(8px);
}

body.modal-open .page-wrapper {
    transform: none;
}

html.modal-open,
body.modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.modal-open .page-wrapper,
body.modal-open .main-wrapper {
    overflow: hidden !important;
}

.page-transition-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10050;
    width: 0;
    height: 3px;
    pointer-events: none;
    background: var(--primary-gradient);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    opacity: 0;
    transition: width 0.32s ease, opacity 0.16s ease;
}

body.page-is-loading .page-transition-bar {
    width: 78%;
    opacity: 1;
}

body.page-has-loaded .page-transition-bar {
    width: 100%;
    opacity: 0;
}

::view-transition-old(page-content),
::view-transition-new(page-content) {
    animation-duration: 0.2s;
    animation-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
    body,
    .page-wrapper,
    .page-transition-bar,
    ::view-transition-old(page-content),
    ::view-transition-new(page-content) {
        animation: none !important;
        transition: none !important;
    }
}

/* 🇰🇭 Battambang for Khmer Language */
body[lang="kh"],
html[lang="kh"] body {
    font-family: 'Battambang', 'Outfit', serif;
    line-height: 1.9;
}

html[lang="kh"] .navbar-nav .nav-link,
html[lang="kh"] .stat-label,
html[lang="kh"] .stat-value,
html[lang="kh"] h1,
html[lang="kh"] h2,
html[lang="kh"] h3,
html[lang="kh"] h4,
html[lang="kh"] h5,
html[lang="kh"] h6,
html[lang="kh"] .btn,
html[lang="kh"] .form-control,
html[lang="kh"] .form-select,
html[lang="kh"] label,
html[lang="kh"] .modal-title,
html[lang="kh"] .badge,
html[lang="kh"] th,
html[lang="kh"] td,
html[lang="kh"] p,
html[lang="kh"] span,
html[lang="kh"] a {
    font-family: 'Battambang', serif;
}

/* ── Page Load Animation ── */
@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

/* Focus Accessibility */
*:focus-visible {
    outline: 3px solid rgba(26, 86, 168, 0.5);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ══════════════════════════════════════════
   NAVBAR — Premium Glass Navigation
   ══════════════════════════════════════════ */
.navbar-premium {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6) !important;
    padding: 0.5rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
    transition: all var(--transition-base);
}

body.has-fixed-header {
    padding-top: 86px;
}

body.has-fixed-header .navbar-premium {
    top: 0;
    z-index: 1040;
}

.navbar-brand {
    gap: 0.8rem;
    padding: 0.25rem 0;
}

.navbar-brand img {
    transition: all var(--transition-smooth);
    border-radius: 8px;
}

.navbar-brand:hover img {
    transform: scale(1.05) rotate(-2deg);
}

.brand-divider {
    width: 1.5px;
    height: 24px;
    background: rgba(203, 213, 225, 0.7);
    margin: 0 4px;
}

.brand-text {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    font-weight: 800;
}

.nav-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--secondary) !important;
    padding: 0.5rem 1.1rem !important;
    border-radius: 50px;
    transition: all var(--transition-base);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: all 0.3s ease;
    border-radius: 2px;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 20px;
}

.nav-link:hover {
    color: var(--primary) !important;
    background: rgba(26, 86, 168, 0.06);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--primary) !important;
    background: var(--primary-light);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(26, 86, 168, 0.12);
}

.nav-link i {
    font-size: 1rem;
    transition: transform var(--transition-base);
}

.nav-link:hover i {
    transform: scale(1.15);
}

/* Navbar Logout Button */
.btn-logout-premium {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-logout-premium:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* Language Switcher (Navbar) */
.btn-lang-premium {
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0.5rem 1.2rem !important;
    color: var(--primary) !important;
    border-radius: 50px !important;
    transition: all var(--transition-base) !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-lang-premium:hover {
    border-color: var(--primary) !important;
    background: white !important;
    transform: translateY(-1px);
}

.btn-lang-premium::after {
    border: none !important;
    content: '\F282';
    font-family: 'bootstrap-icons';
    font-size: 0.6rem;
    vertical-align: middle;
}

.dropdown-lang-menu {
    border-radius: 12px !important;
    padding: 0.5rem !important;
    min-width: 80px !important;
    margin-top: 10px !important;
}

.dropdown-lang-menu .dropdown-item {
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    padding: 0.4rem 1rem !important;
    color: var(--secondary) !important;
    text-align: center;
}

.dropdown-lang-menu .dropdown-item:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.dropdown-lang-menu .dropdown-item.active {
    background: var(--primary) !important;
    color: white !important;
}

/* ══════════════════════════════════════════
   CARDS — Premium Glass Cards
   ══════════════════════════════════════════ */
.card-premium {
    background: var(--surface);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-smooth);
    overflow: hidden;
    position: relative;
}

.card-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card-premium:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: rgba(26, 86, 168, 0.15);
}

.card-premium:hover::before {
    opacity: 1;
}

/* ══════════════════════════════════════════
   STAT CARDS — Dashboard Statistics
   ══════════════════════════════════════════ */
.stat-card {
    position: relative;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 200px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--primary-light);
    top: -50px;
    right: -50px;
    opacity: 0.5;
    transition: all var(--transition-smooth);
}

.stat-card:hover::after {
    transform: scale(1.5);
    opacity: 0.3;
}

.stat-card .stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.2rem;
    font-size: 1.5rem;
    background: var(--primary-light);
    color: var(--primary);
    transition: all var(--transition-smooth);
    position: relative;
    z-index: 2;
}

.stat-card:hover .stat-icon {
    transform: scale(1.15) rotate(-8deg);
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 25px rgba(26, 86, 168, 0.3);
}

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    color: var(--text-main);
    line-height: 1.1;
    position: relative;
    z-index: 2;
    letter-spacing: -0.03em;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: relative;
    z-index: 2;
}

/* ══════════════════════════════════════════
   TABLES — Modern Data Tables
   ══════════════════════════════════════════ */
.table-modern {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.table-modern thead th {
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1.1rem 1.25rem;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid rgba(226, 232, 240, 0.8);
    white-space: nowrap;
}

.table-modern thead th:last-child {
    border-right: none;
}

.table-modern tbody td {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    border-right: 1px solid rgba(226, 232, 240, 0.4);
    vertical-align: middle;
    font-size: 0.88rem;
    color: var(--text-main);
    transition: all var(--transition-fast);
}

.table-modern tbody td:last-child {
    border-right: none;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-modern tbody tr {
    transition: all var(--transition-fast);
}

.table-modern tbody tr:hover {
    background-color: rgba(26, 86, 168, 0.02);
}

/* ══════════════════════════════════════════
   BUTTONS — Premium Button System
   ══════════════════════════════════════════ */
.btn-premium {
    font-weight: 600;
    padding: 0.55rem 1.3rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

.btn-premium-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(26, 86, 168, 0.2);
}

.btn-premium-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 86, 168, 0.3);
    color: white;
}

.btn-premium-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--secondary);
}

.btn-premium-outline:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* ══════════════════════════════════════════
   UTILITIES & BADGES
   ══════════════════════════════════════════ */
.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-status {
    padding: 0.45em 0.85em;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.availability-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
}

.availability-badge-reference {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.availability-badge-loan {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.availability-badge-download {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.availability-badge-view {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #d8b4fe;
}

/* ══════════════════════════════════════════
   MODALS — Refined Dialogs
   ══════════════════════════════════════════ */
.modal {
    width: 100% !important;
    z-index: 20000 !important;
    background: transparent !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
}

.modal-backdrop {
    z-index: 19990 !important;
    background-color: #0f172a;
}

.modal-backdrop.show {
    opacity: 0.5;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-dialog {
    margin-left: auto !important;
    margin-right: auto !important;
    max-height: calc(100vh - 3.5rem);
    pointer-events: auto;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100% - 3.5rem);
}

.modal-content {
    position: relative;
    z-index: 20001;
    display: flex;
    flex-direction: column;
    max-height: inherit;
    border-radius: 20px;
    border: none;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    pointer-events: auto;
}

.modal-content > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3.5rem);
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

.modal-dialog-scrollable .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex-shrink: 0;
}

.modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    padding: 1.5rem 1.75rem;
    background: linear-gradient(145deg, #fafbfc 0%, #f8fafc 100%);
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding: 1.75rem;
}

/* ══════════════════════════════════════════
   SELECT2 — Premium Theme Overrides
   ══════════════════════════════════════════ */
.select2-container--default .select2-selection--single {
    height: 46px !important;
    padding: 8px 12px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    background-color: #fff !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #1e293b !important;
    line-height: normal !important;
    padding-left: 0 !important;
    font-weight: 500 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
    right: 10px !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(26, 86, 168, 0.1) !important;
}

.select2-container--default .select2-selection--multiple {
    min-height: 46px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    background-color: #fff !important;
    padding: 4px 8px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: rgba(26, 86, 168, 0.08) !important;
    border: 1px solid rgba(26, 86, 168, 0.18) !important;
    border-radius: 999px !important;
    color: var(--text-main) !important;
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    padding: 4px 10px 4px 24px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    border: none !important;
    color: var(--primary) !important;
    font-weight: 700 !important;
    left: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(26, 86, 168, 0.1) !important;
}

.select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden !important;
    margin-top: 5px !important;
    z-index: 20002 !important;
}

.select2-container--open {
    z-index: 20002 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
}

.select2-results__option {
    padding: 10px 15px !important;
    font-size: 0.9rem !important;
}

.modal-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(226, 232, 240, 0.5);
    padding: 1.25rem 1.75rem;
    background: #fafbfc;
}

/* ══════════════════════════════════════════
   FORMS — Global Form Refinements
   ══════════════════════════════════════════ */
.form-control,
.form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    transition: all var(--transition-base);
    color: var(--text-main);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26, 86, 168, 0.1);
}

label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 0.4rem;
}

/* ══════════════════════════════════════════
   SCROLLBAR — Custom Scrollbar
   ══════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* ══════════════════════════════════════════
   FOOTER — Premium Glassmorphism
   ══════════════════════════════════════════ */
.footer-premium {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    padding: 0.5rem 0 !important;
    margin-top: auto;
    flex-shrink: 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.03);
}

/* DataTables Length Select Refinement */
.dataTables_length select {
    width: 70px !important;
    padding: 0.35rem 0.5rem !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
    margin: 0 5px !important;
}

.dataTables_length label {
    font-weight: 500 !important;
    color: var(--secondary) !important;
    margin-bottom: 0 !important;
}

.footer-premium::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(26, 86, 168, 0.2) 20%,
            rgba(26, 86, 168, 0.5) 50%,
            rgba(26, 86, 168, 0.2) 80%,
            transparent 100%);
}

.footer-logo-mini {
    filter: drop-shadow(0 2px 4px rgba(26, 86, 168, 0.1));
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.footer-premium:hover .footer-logo-mini {
    transform: scale(1.1) rotate(-5deg);
    filter: drop-shadow(0 4px 8px rgba(26, 86, 168, 0.2));
}

/* ══════════════════════════════════════════
   DASHBOARD CARDS — Color-Coded Variants
   ══════════════════════════════════════════ */
.stat-card {
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    opacity: 0;
    transition: all 0.6s ease;
}

.stat-card:hover::after {
    opacity: 1;
    transform: translate(-30px, 30px);
}

/* Indigo Variant (Primary) */
.stat-card-indigo {
    background: linear-gradient(145deg, #ffffff, #f5f3ff);
}

.stat-card-indigo .stat-icon {
    background: rgba(26, 86, 168, 0.1);
    color: #1a56a8;
}

.stat-card-indigo.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(26, 86, 168, 0.2);
    border-color: rgba(26, 86, 168, 0.3);
}

.stat-card-indigo.stat-card:hover::before {
    background: #1a56a8;
}

.stat-card-indigo.stat-card:hover::after {
    background: radial-gradient(circle, rgba(26, 86, 168, 0.2) 0%, transparent 70%);
}

/* Sky Variant (Digital) */
.stat-card-sky {
    background: linear-gradient(145deg, #ffffff, #f0f9ff);
}

.stat-card-sky .stat-icon {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}

.stat-card-sky.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.3);
}

.stat-card-sky.stat-card:hover::before {
    background: #0ea5e9;
}

/* Amber Variant (Warning) */
.stat-card-amber {
    background: linear-gradient(145deg, #ffffff, #fffbeb);
}

.stat-card-amber .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-card-amber.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.3);
}

.stat-card-amber.stat-card:hover::before {
    background: #f59e0b;
}

/* Rose Variant (Danger/Students) */
.stat-card-rose {
    background: linear-gradient(145deg, #ffffff, #fff1f2);
}

.stat-card-rose .stat-icon {
    background: rgba(225, 29, 72, 0.1);
    color: #e11d48;
}

.stat-card-rose.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(225, 29, 72, 0.2);
    border-color: rgba(225, 29, 72, 0.3);
}

.stat-card-rose.stat-card:hover::before {
    background: #e11d48;
}

/* Emerald Variant (Success/Authors) */
.stat-card-emerald {
    background: linear-gradient(145deg, #ffffff, #ecfdf5);
}

.stat-card-emerald .stat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-card-emerald.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
}

.stat-card-emerald.stat-card:hover::before {
    background: #10b981;
}

/* Violet Variant (Categories) */
.stat-card-violet {
    background: linear-gradient(145deg, #ffffff, #f5f3ff);
}

.stat-card-violet .stat-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.stat-card-violet.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
}

.stat-card-violet.stat-card:hover::before {
    background: #8b5cf6;
}

/* ══════════════════════════════════════════
   BOOK & EBOOK CARDS — Enhanced
   ══════════════════════════════════════════ */
.card-book,
.card-ebook {
    border: none;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    transition: all var(--transition-smooth);
    overflow: hidden;
}

.card-book:hover,
.card-ebook:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: var(--shadow-xl);
}

.card-img-container {
    height: 240px;
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    position: relative;
}

.card-img-container img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-smooth);
}

.card-book:hover .card-img-container img,
.card-ebook:hover .card-img-container img {
    transform: scale(1.06);
}

/* ══════════════════════════════════════════
   SEARCH — Premium Search Bar
   ══════════════════════════════════════════ */
.search-container {
    max-width: 500px;
    position: relative;
}

.search-container i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
    font-size: 1rem;
    transition: color var(--transition-base);
    z-index: 2;
}

.search-container .form-control {
    padding-left: 3rem;
    border-radius: 50px;
    border: 1.5px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    background: white;
    font-weight: 500;
}

.search-container .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26, 86, 168, 0.1), var(--shadow-md);
}

.search-container .form-control:focus+i,
.search-container:focus-within i {
    color: var(--primary);
}

/* ══════════════════════════════════════════
   TOAST — Notification Improvements
   ══════════════════════════════════════════ */
.toast {
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    border: none;
}

/* ══════════════════════════════════════════
   PROFILE CARD — Enhanced Profile
   ══════════════════════════════════════════ */
.profile-card {
    max-width: 500px;
    margin: auto;
    position: relative;
    overflow: visible;
}

.profile-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: var(--primary-gradient);
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0.9;
}

.profile-card>* {
    position: relative;
    z-index: 2;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 5px solid white;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
    margin-top: 2.5rem;
}

/* ══════════════════════════════════════════
   AUTH — Centered Layout (V4 Elite)
   ══════════════════════════════════════════ */
.auth-centered-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: clamp(0.75rem, 2.2vh, 1.5rem);
    position: relative;
    z-index: 10;
}

.auth-bg-immersive {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
}

.auth-bg-immersive::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.8) 100%);
    z-index: 1;
}

.auth-form-container {
    width: 100%;
    max-width: min(430px, calc(100vw - 1.5rem)) !important;
    padding: clamp(0.95rem, 1.8vh, 1.25rem) clamp(1rem, 2vw, 1.45rem);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    box-shadow: 0 28px 80px -22px rgba(0, 0, 0, 0.28);
    animation: authSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 20;
    line-height: 1.45;
}

html[lang="kh"] .auth-form-container,
body[lang="kh"] .auth-form-container {
    line-height: 1.45;
}

@keyframes authSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

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

.auth-logo-float {
    display: block;
    max-height: clamp(58px, 10vh, 88px) !important;
    max-width: min(100%, 190px);
    width: auto;
    object-fit: contain;
    margin: 0 auto clamp(0.7rem, 1.6vh, 1.1rem) !important;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.05));
    transition: all var(--transition-smooth);
    border-radius: 12px;
}

.auth-logo-float:hover {
    transform: scale(1.03) rotate(1deg);
}

.auth-form-container .text-center.mb-4 {
    margin-bottom: clamp(0.75rem, 1.6vh, 1.1rem) !important;
}

.auth-form-container h2 {
    font-size: clamp(1.2rem, 2.8vh, 1.55rem);
    line-height: 1.18;
}

/* Auth Floating Inputs */
.form-floating>.form-control {
    border: 2px solid #f1f5f9;
    border-radius: 16px;
    padding: 1.2rem 1rem;
    height: calc(3.5rem + 15px);
    background: #fff;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    font-weight: 500;
}

.form-floating>.form-control:focus {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), 0 8px 16px -4px rgba(37, 99, 235, 0.08);
    transform: translateY(-2px);
}

.form-floating>label {
    padding: 1.2rem 1.2rem;
    color: #94a3b8;
    font-weight: 600;
    transition: all 0.4s ease;
}

.auth-form-container .form-floating {
    margin-bottom: 0.85rem !important;
}

.auth-form-container .form-floating > .form-control {
    min-height: 64px;
    height: 64px;
    padding: 1.85rem 3rem 0.75rem 1rem;
}

.auth-form-container .form-floating > label {
    padding: 0.72rem 1rem;
    line-height: 1.25;
}

.auth-form-container .my-4 {
    margin-top: 0.95rem !important;
    margin-bottom: 0.95rem !important;
}

.auth-form-container .mb-4 {
    margin-bottom: 0.95rem !important;
}

/* SSO Button */
.btn-sso {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    background: white;
    font-weight: 700;
    color: #1e293b;
    transition: all var(--transition-base);
    margin-bottom: clamp(0.75rem, 1.5vh, 1rem);
    gap: 12px;
    min-height: 46px;
    white-space: normal;
    line-height: 1.25;
}

.btn-sso:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.06);
}

.btn-sso img {
    height: 24px;
}

/* Auth CTA Button */
.btn-auth {
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    border-radius: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--primary-gradient);
    border: none;
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-auth::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-auth:hover::before {
    left: 100%;
}

.btn-auth:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -8px rgba(26, 86, 168, 0.4);
    color: white;
}

/* Toggle Password */
.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
    z-index: 5;
}

/* Language Toggle Pill */
.lang-toggle-elite {
    display: inline-flex;
    max-width: 100%;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 50px;
    position: relative;
    border: 1px solid #e2e8f0;
}

.lang-toggle-elite .btn {
    border-radius: 50px;
    padding: 5px 18px;
    font-size: 0.75rem;
    font-weight: 800;
    border: none;
    transition: all var(--transition-base);
    z-index: 2;
    position: relative;
    white-space: nowrap;
}

.lang-toggle-elite .btn-active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.lang-toggle-elite .btn-inactive {
    background: transparent;
    color: var(--secondary);
}

.lang-toggle-elite .btn:hover:not(.btn-active) {
    color: var(--primary);
}

/* Sidebar Feature Cards (legacy/auth) */
.feature-glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all var(--transition-base);
}

.feature-glass-card:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(10px);
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile Refinements
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
    .stat-card {
        min-height: 160px;
        padding: 1.5rem 1rem;
    }

    .stat-card .stat-value {
        font-size: 2rem;
    }

    .auth-form-container {
        padding: 2.5rem 1.5rem;
        border-radius: 24px;
        margin: 0 0.5rem;
    }

    .search-container {
        max-width: 100%;
    }

    .card-img-container {
        height: 180px;
    }

    .profile-card {
        margin: 0 0.5rem;
    }
}

@media (max-width: 992px) {
    .navbar-nav .nav-item {
        margin-bottom: 0.25rem;
    }

    .navbar-nav .nav-link {
        padding: 0.6rem 1.2rem !important;
    }
}

/* ══════════════════════════════════════════
   STICKY FOOTER — Always at Bottom
   ══════════════════════════════════════════ */
html,
body:not(.auth-bg-immersive) {
    height: 100%;
}

body:not(.auth-bg-immersive) {
    display: flex;
    flex-direction: column;
}

.page-wrapper {
    flex: 1 0 auto;
    /* This pushes the footer down by taking up all available space */
}

.footer-section {
    flex-shrink: 0;
}

/* ══════════════════════════════════════════
   ACTION BUTTONS — Consistent Table Actions
   ══════════════════════════════════════════ */
.btn-action-view,
.btn-action-edit,
.btn-action-delete {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.35rem 0.9rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all var(--transition-base);
    border: 1.5px solid;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.btn-action-view {
    background: rgba(26, 86, 168, 0.06);
    border-color: rgba(26, 86, 168, 0.25);
    color: var(--primary);
}

.btn-action-view:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 168, 0.25);
}

.btn-action-edit {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.32);
    color: #047857;
}

.btn-action-edit:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-action-delete {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

.btn-action-delete:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* Action button group in tables */
.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

/* ══════════════════════════════════════════
   TOAST — Premium Success/Alert Toast
   ══════════════════════════════════════════ */
.toast-container {
    z-index: 9999 !important;
}

.toast {
    border-radius: 16px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15) !important;
    border: none !important;
    overflow: hidden;
    animation: toastSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 320px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(80px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.toast.text-bg-success {
    background: linear-gradient(135deg, #059669, #10b981) !important;
}

.toast.text-bg-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
}

.toast.text-bg-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b) !important;
}

.toast.text-bg-info {
    background: linear-gradient(135deg, #0284c7, #0ea5e9) !important;
}

.toast .toast-body {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast .toast-body::before {
    font-family: 'bootstrap-icons';
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast.text-bg-success .toast-body::before {
    content: '\F26A';
    /* bi-check-circle-fill */
}

.toast.text-bg-danger .toast-body::before {
    content: '\F336';
    /* bi-exclamation-circle-fill */
}

.toast.text-bg-warning .toast-body::before {
    content: '\F33B';
    /* bi-exclamation-triangle-fill */
}

.toast.text-bg-info .toast-body::before {
    content: '\F431';
    /* bi-info-circle-fill */
}

/* ══════════════════════════════════════════
   DATATABLE — DataTable Improvements
   ══════════════════════════════════════════ */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    transition: all var(--transition-base);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 168, 0.1);
    outline: none;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    margin: 0 2px;
    font-size: 0.82rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(26, 86, 168, 0.25);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: var(--primary-light) !important;
    border-color: rgba(26, 86, 168, 0.2) !important;
    color: var(--primary) !important;
}

/* Badge improvements */
.badge.bg-success {
    background: linear-gradient(135deg, #059669, #10b981) !important;
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.4em 0.8em;
    border-radius: 50px;
    letter-spacing: 0.02em;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.4em 0.8em;
    border-radius: 50px;
    letter-spacing: 0.02em;
}

/* Modal improvements */
.modal-header.bg-primary {
    background: var(--primary-gradient) !important;
    border: none;
}

.modal-header.bg-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    border: none;
}

.modal-footer .btn-success {
    background: var(--primary-gradient);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    padding: 0.55rem 1.5rem;
}

.modal-footer .btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    padding: 0.55rem 1.5rem;
}

.modal-footer .btn-secondary {
    border-radius: 10px;
    font-weight: 600;
    padding: 0.55rem 1.5rem;
}

.modal-footer .btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    padding: 0.55rem 1.5rem;
}

/* ══════════════════════════════════════════
   UTILITIES — Extra
   ══════════════════════════════════════════ */
.extra-small {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
}

@keyframes footerPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse {
    animation: footerPulse 2s infinite ease-in-out;
    display: inline-block;
}

/* ══════════════════════════════════════════
   BOOK SEARCH RESULTS — Premium Cards
   ══════════════════════════════════════════ */
.book-result-card {
    transition: all var(--transition-base);
    border: 1.5px solid #f1f5f9;
    border-radius: 12px;
    background: #fff;
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: left;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.book-result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-light);
}

.book-result-img-wrapper {
    width: 100%;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.25rem;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    padding: 10px;
}

.book-result-img {
    max-height: 100%;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.book-result-content {
    width: 100%;
    flex: 1;
}

.book-result-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

.book-result-detail {
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.book-result-label {
    color: var(--text-muted);
    font-weight: 500;
}

.book-result-value {
    font-weight: 600;
}

/* =============================================================
   RESPONSIVE POLISH - shared public/admin layouts
 ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

.page-wrapper,
.main-wrapper,
.container,
.container-fluid,
.row,
.card-premium,
.modal-content {
    min-width: 0;
}

.container-fluid {
    width: 100%;
}

.main-wrapper,
.container-fluid.py-4,
.container-fluid.py-5 {
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

.navbar-premium .container-fluid {
    max-width: 1680px;
}

.navbar-toggler {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #f8fafc;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 4px rgba(26, 86, 168, 0.1);
}

.navbar-toggler-icon {
    width: 1.15em;
    height: 1.15em;
}

.navbar-collapse {
    min-width: 0;
}

.navbar-nav {
    min-width: 0;
}

.nav-link {
    white-space: nowrap;
}

.table-responsive {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

.table-modern {
    min-width: 720px;
}

.table-modern th,
.table-modern td {
    overflow-wrap: anywhere;
}

.dataTables_wrapper {
    max-width: 100%;
}

.dataTables_wrapper .row {
    --bs-gutter-y: 0.75rem;
}

.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    min-width: 0;
}

.dataTables_wrapper .dataTables_filter input {
    max-width: 100%;
}

.dataTables_wrapper .pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.action-btns {
    flex-wrap: wrap;
}

.card-premium.p-4,
.card-premium.p-5 {
    overflow-wrap: anywhere;
}

.btn-premium,
.btn-action-edit,
.btn-action-delete,
.modal-footer .btn {
    justify-content: center;
    white-space: normal;
    line-height: 1.25;
}

.profile-info-grid,
.info-item,
.info-value {
    min-width: 0;
}

.info-value {
    overflow-wrap: anywhere;
}

@media (max-width: 1199.98px) {
    .navbar-premium .container-fluid {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    .nav-link {
        padding-left: 0.8rem !important;
        padding-right: 0.8rem !important;
        font-size: 0.78rem;
    }

    .stat-card {
        min-height: 180px;
    }
}

@media (min-width: 768px) and (max-height: 860px) {
    .auth-centered-wrapper {
        align-items: center;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .auth-form-container {
        padding-top: 0.95rem;
        padding-bottom: 0.95rem;
    }

    .auth-logo-float {
        max-height: 68px !important;
    }

    .auth-form-container h2 {
        font-size: 1.28rem;
    }

    .auth-form-container .form-floating > .form-control {
        min-height: 60px;
        height: 60px;
        padding-top: 1.75rem;
        padding-bottom: 0.75rem;
    }

    .btn-sso,
    .btn-auth {
        min-height: 44px;
    }
}

@media (min-width: 768px) and (max-height: 720px) {
    .auth-logo-float {
        max-height: 56px !important;
    }

    .auth-form-container .text-center.mb-4 {
        margin-bottom: 0.65rem !important;
    }

    .auth-form-container h2 {
        font-size: 1.15rem;
    }

    .auth-form-container .my-4 {
        margin-top: 0.65rem !important;
        margin-bottom: 0.65rem !important;
    }
}

@media (max-width: 991.98px) {
    .navbar-premium {
        padding: 0.45rem 0;
    }

    .navbar-premium .navbar-collapse {
        margin-top: 0.75rem;
        padding: 0.75rem;
        border: 1px solid rgba(226, 232, 240, 0.8);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: var(--shadow-lg);
        max-height: calc(100vh - 88px);
        overflow-y: auto;
    }

    .navbar-nav {
        align-items: stretch !important;
        gap: 0.2rem;
    }

    .navbar-nav .nav-link {
        display: flex;
        align-items: center;
        width: 100%;
        white-space: normal;
        border-radius: 12px;
    }

    .navbar-collapse > .d-flex {
        align-items: stretch !important;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.75rem !important;
    }

    .main-wrapper,
    .container-fluid.py-4,
    .container-fluid.py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .card-premium.p-5 {
        padding: 2rem !important;
    }

    .auth-centered-wrapper {
        min-height: 100dvh;
        padding: 1.5rem;
    }

    .auth-form-container {
        max-width: min(100%, 410px) !important;
    }
}

@media (max-width: 767.98px) {
    body {
        line-height: 1.55;
    }

    .container,
    .container-fluid,
    .main-wrapper {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .navbar-premium .container-fluid,
    .footer-premium .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .navbar-brand {
        max-width: calc(100vw - 92px);
        margin-right: 0.5rem !important;
    }

    .navbar-brand img {
        max-width: 180px;
        height: 38px;
        object-fit: contain;
    }

    .brand-text {
        font-size: 0.95rem;
    }

    .main-wrapper,
    .container-fluid.py-4,
    .container-fluid.py-5 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    h2,
    .h2 {
        font-size: 1.45rem;
        line-height: 1.25;
    }

    h3,
    .h3 {
        font-size: 1.25rem;
    }

    .card-premium {
        border-radius: 14px;
    }

    .card-premium.p-4,
    .card-premium.p-5 {
        padding: 1.1rem !important;
    }

    .stat-card {
        min-height: 140px;
        padding: 1.25rem 1rem;
    }

    .stat-card .stat-icon {
        width: 52px;
        height: 52px;
        margin-bottom: 0.9rem;
        font-size: 1.2rem;
    }

    .stat-card .stat-value {
        font-size: 1.9rem;
    }

    .stat-card .stat-label {
        font-size: 0.75rem;
    }

    .search-wrapper,
    .search-container {
        max-width: none !important;
        width: 100%;
    }

    .card-book-elite,
    .card-ebook-elite,
    .card-book,
    .card-ebook {
        border-radius: 16px;
    }

    .book-cover-wrapper,
    .ebook-cover-wrapper,
    .card-img-container {
        height: clamp(180px, 58vw, 260px);
    }

    .book-content,
    .ebook-content {
        padding: 1rem !important;
    }

    .category-badge {
        max-width: calc(100% - 2rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-responsive {
        margin-left: -0.1rem;
        margin-right: -0.1rem;
    }

    .table-modern {
        min-width: 680px;
    }

    .table-modern thead th,
    .table-modern tbody td {
        padding: 0.8rem 0.85rem;
        font-size: 0.8rem;
    }

    .dataTables_wrapper > .d-flex,
    .dataTables_wrapper .row:first-child,
    .dataTables_wrapper .row:last-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100%;
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_filter label,
    .dataTables_wrapper .dataTables_length label {
        display: flex;
        width: 100%;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_paginate .pagination,
    .dataTables_wrapper .dataTables_paginate {
        justify-content: flex-start !important;
    }

    .modal-dialog {
        width: calc(100% - 1rem);
        margin: 0.5rem auto !important;
        max-height: calc(100dvh - 1rem);
    }

    .modal-dialog-centered {
        min-height: calc(100dvh - 1rem);
    }

    .modal-dialog-scrollable .modal-content,
    .modal-content {
        max-height: calc(100dvh - 1rem);
        border-radius: 16px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .modal-footer {
        align-items: stretch;
    }

    .modal-footer > * {
        flex: 1 1 100%;
        margin: 0 !important;
    }

    .auth-centered-wrapper {
        min-height: 100dvh;
        padding: 1rem;
        align-items: flex-start;
        justify-content: center;
    }

    .auth-form-container {
        max-width: 100% !important;
        margin: 0.25rem 0 !important;
        padding: 1.2rem 1rem !important;
        border-radius: 18px;
        box-shadow: 0 20px 55px -18px rgba(0, 0, 0, 0.28);
    }

    .auth-logo-float {
        max-height: 78px !important;
        max-width: min(82vw, 240px);
        margin-bottom: 0.75rem !important;
    }

    .auth-form-container .text-center.mb-4 {
        margin-bottom: 1rem !important;
    }

    .auth-form-container h2 {
        font-size: 1.35rem;
    }

    .auth-form-container p,
    .auth-form-container a,
    .auth-form-container label,
    .auth-form-container .small {
        line-height: 1.4;
    }

    .form-floating > .form-control {
        height: calc(3.15rem + 8px);
        padding-top: 1rem;
        padding-bottom: 0.85rem;
        font-size: 0.92rem;
    }

    .form-floating > label {
        padding-top: 1rem;
        padding-bottom: 0.85rem;
    }

    .toggle-password {
        right: 0.55rem !important;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .auth-form-container form > .d-flex.justify-content-between {
        align-items: flex-start !important;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .auth-form-container .form-check {
        min-width: 0;
    }

    .btn-sso,
    .btn-auth {
        min-height: 48px;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        font-size: 0.86rem;
        letter-spacing: 0.02em;
    }

    .auth-form-container .my-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .auth-form-container .mb-4 {
        margin-bottom: 1rem !important;
    }

    .lang-toggle-elite {
        width: 100%;
        justify-content: center;
    }

    .lang-toggle-elite .btn {
        flex: 1 1 0;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .profile-card-elite {
        margin: 1rem auto !important;
        border-radius: 18px !important;
    }

    .profile-cover {
        height: 120px !important;
    }

    .profile-avatar-wrapper {
        margin-top: -52px !important;
    }

    .profile-avatar-elite {
        width: 104px !important;
        height: 104px !important;
        border-width: 5px !important;
    }

    .profile-info-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
        padding: 0 !important;
    }

    .profile-info-grid .info-item {
        grid-column: auto !important;
    }

    .status-badge {
        right: 1rem !important;
        left: 1rem;
        text-align: center;
    }

    .toast-container {
        left: 0 !important;
        right: 0 !important;
        padding: 0.75rem !important;
    }

    .toast {
        min-width: 0;
        width: 100%;
    }

    .footer-premium {
        padding: 0.85rem 0 !important;
    }
}

@media (max-width: 575.98px) {
    .container,
    .container-fluid,
    .main-wrapper {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.flex-column.flex-md-row.justify-content-between.align-items-md-center {
        align-items: stretch !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        gap: 0.85rem;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex {
        width: 100%;
        flex-wrap: wrap;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex .btn {
        flex: 1 1 auto;
    }

    .btn-premium,
    .btn-action-edit,
    .btn-action-delete {
        width: 100%;
    }

    .action-btns {
        min-width: 150px !important;
    }

    .book-result-card {
        align-items: stretch;
        text-align: left;
    }

    .book-result-img-wrapper {
        height: 150px;
    }

    .pagination {
        gap: 0.25rem;
    }

    .page-link {
        min-width: 38px;
        text-align: center;
    }

    .auth-centered-wrapper {
        padding: 0.65rem;
    }

    .auth-form-container {
        padding: 1rem 0.85rem !important;
        border-radius: 16px;
    }

    .auth-logo-float {
        max-height: 66px !important;
        max-width: min(78vw, 210px);
    }

    .auth-form-container h2 {
        font-size: 1.2rem;
    }

    .auth-form-container .form-floating.mb-3,
    .auth-form-container .form-floating.mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .auth-form-container .d-flex.align-items-center.my-4 span {
        margin-left: 0.65rem !important;
        margin-right: 0.65rem !important;
        text-align: center;
    }
}

/* Compact auth layout for in-app mobile browsers */
@media (max-width: 575.98px) {
    html,
    body.auth-bg-immersive {
        min-height: 100%;
    }

    body.auth-bg-immersive {
        background-attachment: scroll;
        overflow-y: auto;
    }

    .auth-bg-immersive::before {
        position: fixed;
    }

    .auth-centered-wrapper {
        align-items: flex-start;
        min-height: 100svh;
        padding: max(0.65rem, env(safe-area-inset-top)) 0.65rem max(5.5rem, env(safe-area-inset-bottom));
    }

    .auth-form-container {
        max-width: min(100%, 390px) !important;
        margin: 0 auto !important;
        padding: 0.85rem 0.85rem 0.95rem !important;
        border-radius: 18px;
        line-height: 1.32;
    }

    .auth-logo-float {
        max-height: 58px !important;
        max-width: min(52vw, 150px) !important;
        margin-bottom: 0.45rem !important;
    }

    .auth-form-container .text-center,
    .auth-form-container .text-center.mb-4 {
        margin-bottom: 0.55rem !important;
    }

    .auth-form-container h2 {
        font-size: 1.22rem;
        line-height: 1.15;
        margin-bottom: 0 !important;
    }

    .auth-form-container p {
        margin-bottom: 0.55rem !important;
    }

    .btn-sso {
        min-height: 42px;
        padding: 0.55rem 0.7rem !important;
        border-radius: 14px;
        font-size: 0.86rem;
        gap: 0.45rem;
        margin-bottom: 0.55rem;
    }

    .btn-sso .rounded-circle {
        width: 22px !important;
        height: 22px !important;
        flex: 0 0 22px;
    }

    .auth-form-container .my-4 {
        margin-top: 0.55rem !important;
        margin-bottom: 0.55rem !important;
    }

    .auth-form-container .d-flex.align-items-center.my-4 span {
        font-size: 0.74rem;
        white-space: nowrap;
    }

    .auth-form-container .form-floating {
        margin-bottom: 0.55rem !important;
    }

    .auth-form-container .form-floating > .form-control {
        height: 58px;
        min-height: 58px;
        border-radius: 14px;
        padding: 1.7rem 2.75rem 0.75rem 0.85rem;
        font-size: 0.9rem;
    }

    .auth-form-container .form-floating > label {
        padding: 0.62rem 0.85rem;
        font-size: 0.9rem;
    }

    .toggle-password {
        right: 0.45rem !important;
        padding: 0.35rem 0.5rem !important;
    }

    .auth-form-container form > .d-flex.justify-content-between {
        gap: 0.45rem;
        margin-bottom: 0.65rem !important;
    }

    .auth-form-container .form-check-label,
    .auth-form-container a.small {
        font-size: 0.82rem;
    }

    .auth-form-container .form-check-input {
        width: 0.95em;
        height: 0.95em;
        margin-top: 0.2em;
    }

    .btn-auth {
        min-height: 44px;
        padding: 0.65rem 1rem !important;
        border-radius: 14px;
        font-size: 0.8rem;
        margin-bottom: 0.55rem !important;
    }

    .lang-toggle-elite {
        margin-top: 0.25rem;
    }
}

@media (max-width: 575.98px) and (max-height: 700px) {
    .auth-centered-wrapper {
        padding-top: 0.45rem;
        padding-bottom: max(5rem, env(safe-area-inset-bottom));
    }

    .auth-form-container {
        padding-top: 0.7rem !important;
        padding-bottom: 0.75rem !important;
    }

    .auth-logo-float {
        max-height: 46px !important;
        max-width: min(44vw, 128px) !important;
        margin-bottom: 0.3rem !important;
    }

    .auth-form-container h2 {
        font-size: 1.1rem;
    }

    .auth-form-container .my-4 {
        margin-top: 0.4rem !important;
        margin-bottom: 0.4rem !important;
    }

    .auth-form-container .form-floating > .form-control {
        height: 56px;
        min-height: 56px;
        padding-top: 1.65rem;
        padding-bottom: 0.75rem;
    }

    .btn-sso,
    .btn-auth {
        min-height: 40px;
    }
}
