@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  /* Brand */
  --primary:           #002D62;
  --primary-dark:      #001B3D;
  --primary-light:     #0047A0;
  --secondary:         #E3B23C;
  --secondary-hover:   #D4A02A;
  --accent:            #E3B23C;

  /* Status */
  --success:  #10B981;
  --danger:   #EF4444;
  --warning:  #F59E0B;
  --info:     #3B82F6;

  /* Neutrals — Light Mode */
  --bg-body:      #F9FAFB;
  --bg-card:      #FFFFFF;
  --bg-sidebar:   #0F172A;
  --bg-light:     #F3F4F6;
  --bg-input:     #F8FAFC;
  --dark:         #1F2937;

  --text-heading:  #111827;
  --text-body:     #374151;
  --text-muted:    #6B7280;
  --text-on-dark:  #F9FAFB;
  --border-color:  #E5E7EB;

  /* Sidebar link color */
  --sidebar-link:  #94A3B8;
  --sidebar-hover: #F8FAFC;

  /* Sizing */
  --header-height: 68px;
  --sidebar-width: 260px;
  --admin-topbar-height: 56px;

  /* Radius */
  --radius:    12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Shadows */
  --shadow-sm:      0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow:         0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.05);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-premium: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-nav:     0 8px 32px rgba(0,45,98,0.15);

  /* Typography — fluid scale */
  --font-base: 'Inter', 'Lexend', sans-serif;
  --fs-xs:   clamp(0.7rem,  1.5vw,  0.8rem);
  --fs-sm:   clamp(0.8rem,  1.8vw,  0.9rem);
  --fs-base: clamp(0.9rem,  2vw,    1rem);
  --fs-md:   clamp(1rem,    2.5vw,  1.1rem);
  --fs-lg:   clamp(1.15rem, 3vw,    1.35rem);
  --fs-xl:   clamp(1.4rem,  4vw,    1.75rem);
  --fs-2xl:  clamp(1.75rem, 5vw,    2.25rem);
  --fs-3xl:  clamp(2rem,    6vw,    2.75rem);
  --fs-hero: clamp(2.1rem,  7vw,    3.0rem);

  --transition:      all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ─── DARK MODE ─────────────────────────────────────────────── */
body.dark-mode {
  --bg-body:      #0B1628;
  --bg-card:      #1A2744;
  --bg-light:     #1E2E4A;
  --bg-input:     #162038;
  --dark:         #E2E8F0;
  --text-heading: #F1F5F9;
  --text-body:    #CBD5E1;
  --text-muted:   #94A3B8;
  --border-color: #2D4070;
  --shadow:       0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.5);
  --bg-sidebar:   #060F1F;
  --sidebar-link: #7D9BC1;
  --sidebar-hover:#E2E8F0;
}

body.dark-mode a { color: #7EB5FF; }
body.dark-mode a:hover { color: var(--secondary); }
body.dark-mode .text-primary { color: #7EB5FF !important; }
body.dark-mode .btn-primary { color: #fff; }
body.dark-mode .btn-accent  { color: var(--primary-dark); }
body.dark-mode .btn-outline { border-color: #7EB5FF; color: #7EB5FF; }
body.dark-mode .btn-outline:hover { background: #7EB5FF; color: var(--primary-dark); }
body.dark-mode .btn-secondary { background: var(--bg-light); color: var(--text-heading); border-color: var(--border-color); }
body.dark-mode .admin-sidebar { background: var(--bg-sidebar); }
body.dark-mode .hero-slider .slide-content { background: rgba(0,0,0,0.6); }
body.dark-mode #global-loader { background: rgba(11,22,40,0.92); }
body.dark-mode .form-control { background: var(--bg-input); color: var(--text-heading); border-color: var(--border-color); }
body.dark-mode .form-control:focus { background: var(--bg-card); border-color: #7EB5FF; box-shadow: 0 0 0 4px rgba(126,181,255,0.12); }
body.dark-mode th { color: var(--text-muted); }
body.dark-mode .badge-info    { background: rgba(59,130,246,0.2);  color: #93C5FD; }
body.dark-mode .badge-success { background: rgba(16,185,129,0.2);  color: #6EE7B7; }
body.dark-mode .badge-warning { background: rgba(245,158,11,0.2);  color: #FCD34D; }
body.dark-mode .badge-danger  { background: rgba(239,68,68,0.2);   color: #FCA5A5; }
body.dark-mode .feature-card  { background: var(--bg-card); border-color: var(--border-color); }
body.dark-mode .feature-icon  { background: rgba(126,181,255,0.12); color: #7EB5FF; }
body.dark-mode .nav-drawer    { background: var(--bg-card); }
body.dark-mode .nav-drawer nav a { color: var(--text-heading); }
body.dark-mode .dropdown      { background: var(--bg-card); border-color: var(--border-color); }
body.dark-mode .account-sidebar { background: var(--bg-card); border-color: var(--border-color); }
body.dark-mode .chat-bot-msg  { background: var(--bg-light); color: var(--text-heading); }
body.dark-mode .msg-bubble.received { background: var(--bg-light); color: var(--text-heading); }
body.dark-mode .admin-topbar { background: var(--bg-sidebar); }

/* ─── BOX MODEL RESET ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* FIX: Consolidated into a single, clean focus-visible rule — was duplicated */
* { outline: none; }
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-body);
  color: var(--text-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

body.admin-layout {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover { color: var(--secondary); }

img, video, picture, iframe {
  max-width: 100%;
  display: block;
  height: auto;
}

/* FIX: Removed deprecated -webkit-optimize-contrast vendor prefix */
img { image-rendering: auto; }
img[loading="lazy"] { opacity: 0; transition: opacity 0.4s ease; }
img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) { opacity: 1; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

ul, ol { list-style: none; }

/* =========================================
   2. LAYOUT & UTILITIES
   ========================================= */
.container {
  width: min(92%, 1200px);
  margin-inline: auto;
  padding-block: 1.25rem;
}

.main-content { flex: 1; }

.d-flex         { display: flex; }
.flex-column    { flex-direction: column; }
.flex-wrap      { flex-wrap: wrap; }
.flex-grow      { flex-grow: 1; }
.flex-1         { flex: 1; }
.align-center   { align-items: center; }
.align-start    { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }

.d-grid { display: grid; }

.d-none        { display: none !important; }
.d-block       { display: block; }
.d-inline-flex { display: inline-flex; }

@media (min-width: 769px)  { .d-md-none     { display: none !important; } }
@media (max-width: 768px)  { .d-none-mobile { display: none !important; } .d-md-block { display: block; } }

.gap-05 { gap: 0.5rem; }
.gap-1  { gap: 1rem; }
.gap-2  { gap: 2rem; }

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mt-3 { margin-top: 3rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.ml-1 { margin-left: 1rem; }
.mr-1 { margin-right: 1rem; }
.mx-auto { margin-inline: auto; }

.p-0  { padding: 0 !important; }
.p-1  { padding: 1rem; }
.p-2  { padding: 2rem; }
.py-0 { padding-block: 0 !important; }
.py-1 { padding-block: 1rem; }
.py-2 { padding-block: 2rem; }
.py-3 { padding-block: 3rem; }
.px-1 { padding-inline: 1rem; }
.px-2 { padding-inline: 2rem; }

.w-80  { width: 80px; }
.w-250 { width: 250px; }
.w-100 { width: 100%; }
.w-auto{ width: auto; }
.h-100 { height: 100%; }
.h-200 { height: 200px; }
.h-250 { height: 250px; }
.min-h-0 { min-height: 0; }

.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-left     { text-align: left; }
.text-white    { color: #fff !important; }
.text-primary  { color: var(--primary) !important; }
.text-secondary{ color: var(--secondary) !important; }
.text-muted    { color: var(--text-muted) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-info     { color: var(--info) !important; }
.text-heading  { color: var(--text-heading) !important; }
.font-bold     { font-weight: 700; }
.font-medium   { font-weight: 500; }

.text-truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bg-light       { background-color: var(--bg-light); }
.bg-white       { background-color: var(--bg-card); }
.bg-primary     { background-color: var(--primary); }
.bg-dark        { background-color: var(--dark); }
.bg-dark-overlay {
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.border-top    { border-top: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-white  { border-color: rgba(255,255,255,0.6) !important; }
.border-0      { border: none !important; }

.rounded         { border-radius: var(--radius); }
.rounded-lg      { border-radius: var(--radius-lg); }
.shadow          { box-shadow: var(--shadow); }
.shadow-lg       { box-shadow: var(--shadow-lg); }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.pos-rel         { position: relative; }
.pos-abs         { position: absolute; }
.top-0           { top: 0; }
.left-0          { left: 0; }
.right-0         { right: 0; }
.bottom-0        { bottom: 0; }
.top-10          { top: 10px; }
.right-10        { right: 10px; }
.m-1             { margin: 1rem; }
.object-cover    { object-fit: cover; }
.object-contain  { object-fit: contain; }
.opacity-90      { opacity: 0.9; }
.opacity-80      { opacity: 0.8; }
.cursor-pointer  { cursor: pointer; }
.user-select-none{ user-select: none; }
.transition      { transition: var(--transition); }

/* =========================================
   3. BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.5rem;
  font-family: var(--font-base);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-radius: 50px;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover  { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0);    box-shadow: var(--shadow-sm); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px 0 rgba(0,45,98,0.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0,45,98,0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-heading);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-light);
  border-color: var(--text-muted);
  color: var(--text-heading);
}

.btn-accent {
  background: var(--secondary);
  color: var(--primary-dark);
  border-color: var(--secondary);
  font-weight: 700;
}
.btn-accent:hover {
  background: var(--secondary-hover);
  border-color: var(--secondary-hover);
  color: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; color: #fff; }

.btn-info { background: var(--info); color: #fff; border-color: var(--info); }

.btn-sm { padding: 0.35rem 0.9rem;  font-size: var(--fs-xs); }
.btn-lg { padding: 0.9rem 2.25rem;  font-size: var(--fs-md); }
.btn-xl { padding: 1.1rem 2.75rem;  font-size: var(--fs-lg); }

@media (max-width: 480px) {
  .btn-block-mobile { width: 100%; justify-content: center; }
}

/* =========================================
   4. FORMS
   ========================================= */
.form-group {
  margin-bottom: 1.25rem;
  position: relative;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--text-heading);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  font-family: var(--font-base);
  font-size: max(var(--fs-base), 16px); /* prevents iOS auto-zoom */
  background: var(--bg-input);
  color: var(--text-heading);
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  background: var(--bg-card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,45,98,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-light);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

textarea.form-control { resize: vertical; min-height: 120px; }

.password-wrapper { position: relative; }
.password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  user-select: none;
  padding: 4px;
  background: none;
  border: none;
  font-family: var(--font-base);
  transition: var(--transition-fast);
}
.password-toggle:hover { color: var(--primary); }

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
}
.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--success); }
.invalid-feedback { color: var(--danger);  font-size: var(--fs-xs); margin-top: 0.25rem; }
.valid-feedback   { color: var(--success); font-size: var(--fs-xs); margin-top: 0.25rem; }

/* =========================================
   5. CARDS
   ========================================= */

/* FIX: Removed redundant background-color:#fff (overridden), background-clip:border-box,
   and fixed inconsistent indentation */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

/* Admin cards should not lift on hover */
.admin-content .card:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-heading);
  background: rgba(0,0,0,0.01);
}
.card-body   { padding: 1.5rem; }
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.01);
}

.book-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.book-card img {
  height: 280px;
  object-fit: cover;
  width: 100%;
  transition: transform 0.4s ease;
}
.book-card:hover img { transform: scale(1.04); }
.book-card .card-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}
.book-card .btn { margin-top: auto; }

/* =========================================
   6. TABLES
   ========================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Table-responsive inside a card — strip double shadow/radius */
.card > .table-responsive,
.card .table-responsive {
  border-radius: 0;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: var(--fs-sm);
}
thead tr { background: var(--bg-light); }
th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-body);
  vertical-align: middle;
}
tr:last-child td   { border-bottom: none; }
tbody tr:hover td  { background: rgba(0,45,98,0.03); }

/* =========================================
   7. BADGES
   ========================================= */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 50px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-primary { background: rgba(0,45,98,0.1);   color: var(--primary); }
.badge-info    { background: rgba(59,130,246,0.1); color: var(--info); }
.badge-success { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.1); color: #B45309; }
.badge-danger  { background: rgba(239,68,68,0.1);  color: var(--danger); }

/* =========================================
   8. HEADER & NAVIGATION
   ========================================= */
header {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--header-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}
header .container {
  padding-block: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 100%;
}

.logo {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  text-decoration: none;
}
.logo:hover { color: var(--primary-dark); }
.logo img   { height: 40px; width: auto; }

.header-desktop {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

nav {
  display: flex;
  align-items: center;
}

nav > ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
}

nav > ul > li { position: relative; }

nav > ul > li > a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 0.8rem;
  color: var(--text-heading);
  font-weight: 500;
  font-size: var(--fs-sm);
  border-radius: 8px;
  transition: var(--transition-fast);
  white-space: nowrap;
}
nav > ul > li > a:hover,
nav > ul > li > a.active {
  color: var(--primary);
  background: rgba(0,45,98,0.06);
}
nav > ul > li > a .nav-chevron {
  font-size: 0.65em;
  transition: transform 0.25s ease;
}
nav > ul > li:hover > a .nav-chevron { transform: rotate(180deg); }

.nav-cart-wrap { position: relative; }
.nav-cart-badge {
  position: absolute;
  top: -4px;
  right: 2px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-nav);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1000;
  list-style: none;
}
.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.875rem;
  color: var(--text-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: 8px;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.dropdown li a:hover { background: var(--bg-light); color: var(--primary); }
.dropdown li a i { width: 1rem; text-align: center; color: var(--text-muted); }
.dropdown li + li { margin-top: 0.1rem; }
.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.4rem 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-heading);
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: var(--transition-fast);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle:hover { background: var(--border-color); }

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1998;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.nav-overlay.open { opacity: 1; }

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 85vw);
  background: var(--bg-card);
  z-index: 1999;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-premium);
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-drawer.open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.nav-drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-heading);
  font-size: 1rem;
  transition: var(--transition-fast);
}
.nav-drawer-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.nav-drawer nav { flex: 1; padding: 1rem; }
.nav-drawer nav > ul {
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
}
.nav-drawer nav > ul > li { width: 100%; }
.nav-drawer nav > ul > li > a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-heading);
  font-weight: 500;
  font-size: var(--fs-base);
  border-radius: var(--radius);
  transition: var(--transition-fast);
  width: 100%;
  justify-content: space-between;
}
.nav-drawer nav > ul > li > a:hover,
.nav-drawer nav > ul > li > a.active {
  background: rgba(0,45,98,0.07);
  color: var(--primary);
}
.nav-drawer-link-left { display: flex; align-items: center; gap: 0.75rem; }
.nav-drawer-link-left i { width: 1.25rem; text-align: center; color: var(--primary); }

.nav-drawer .drawer-sub {
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 2.5rem;
  padding-bottom: 0.5rem;
}
.nav-drawer .drawer-sub.open { display: flex; }
.nav-drawer .drawer-sub li a {
  display: block;
  padding: 0.55rem 0.75rem;
  color: var(--text-body);
  font-size: var(--fs-sm);
  border-radius: 8px;
}
.nav-drawer .drawer-sub li a:hover { background: var(--bg-light); color: var(--primary); }

.nav-drawer-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.theme-toggle-btn {
  background: transparent;
  border: 1.5px solid var(--border-color);
  padding: 0.4rem 0.875rem;
  border-radius: 20px;
  color: var(--text-heading);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-family: var(--font-base);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.theme-toggle-btn:hover { background: var(--bg-light); border-color: var(--text-muted); }

.header-select-form select.form-control {
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  background-color: transparent;
  border-color: var(--border-color);
  border-radius: 8px;
  height: auto;
  min-width: 0;
  cursor: pointer;
}

/* =========================================
   9. HERO / IMAGE SLIDER
   ========================================= */
.hero-slider {
  position: relative;
  width: 100%;
  height: clamp(340px, 55vw, 600px);
  overflow: hidden;
  border-radius: var(--radius-xl);
  margin-bottom: 3rem;
  box-shadow: var(--shadow-premium);
  background: var(--dark);
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.9s ease-in-out;
  pointer-events: none;
}
.slide.active { opacity: 1; pointer-events: auto; }
.slide > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 8s ease;
}
.slide.active > img { transform: scale(1.05); }

.slide-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,45,98,0.55) 100%);
}

.slide-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  max-width: min(680px, 90%);
  animation: slideUp 0.6s ease 0.3s both;
}
.slide.active .slide-content { animation: slideUp 0.6s ease 0.3s both; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.slide-content h1 {
  font-size: clamp(1.5rem, 4.5vw, 2.5rem);
  color: #fff;
  margin-bottom: 0.75rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-weight: 800;
}
.slide-content p {
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  color: rgba(255,255,255,0.92);
  margin-bottom: 1.5rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  width: clamp(36px, 5vw, 48px);
  height: clamp(36px, 5vw, 48px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  transition: var(--transition);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
}
.slider-btn:hover { background: rgba(255,255,255,0.35); transform: translateY(-50%) scale(1.1); }
.slider-prev { left: clamp(8px, 2.5vw, 20px); }
.slider-next { right: clamp(8px, 2.5vw, 20px); }

.slider-dots {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}
.slider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.slider-dot.active {
  background: #fff;
  width: 24px;
  border-radius: 4px;
}

.hero-section {
  position: relative;
  min-height: clamp(300px, 50vw, 560px);
  background: linear-gradient(rgba(0,45,98,0.72), rgba(0,45,98,0.72)),
              url('images/hero-bg.jpg') center/cover no-repeat;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-premium);
  padding: clamp(2rem, 5vw, 4rem) 1.5rem;
}
.hero-content h1 {
  font-size: var(--fs-hero);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.3);
  margin-bottom: 1rem;
}
.hero-content p {
  font-size: var(--fs-lg);
  opacity: 0.92;
  margin-bottom: 2rem;
  max-width: 580px;
  margin-inline: auto;
}

/* =========================================
   10. HOMEPAGE SECTIONS
   ========================================= */
.section-title { text-align: center; margin-bottom: 2.5rem; }
.section-title h2 { font-size: var(--fs-3xl); color: var(--primary); margin-bottom: 0.4rem; }
.section-title p  { color: var(--text-muted); font-size: var(--fs-md); }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(180px, 22vw, 260px), 1fr));
  gap: clamp(1rem, 2.5vw, 2rem);
  margin-bottom: 3.5rem;
}
.feature-card {
  text-align: center;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid transparent;
}
.feature-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}
.feature-icon {
  width: clamp(52px, 8vw, 64px);
  height: clamp(52px, 8vw, 64px);
  background: rgba(0,45,98,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--primary);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}
.feature-card h3 { font-size: var(--fs-md); margin-bottom: 0.5rem; }
.feature-card p  { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 0; }

.grid-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 22vw, 220px), 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
}

.cta-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  text-align: center;
  padding: clamp(2rem, 5vw, 4rem) 1.5rem;
}
.cta-banner h2 { color: #fff; }
.cta-banner p  { color: rgba(255,255,255,0.88); }

/* =========================================
   11. ACCOUNT / DASHBOARD LAYOUT
   ========================================= */
.account-layout {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  align-items: flex-start;
}
.account-sidebar {
  width: min(280px, 30vw);
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  border: 1px solid var(--border-color);
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}
.user-brief {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.user-avatar {
  width: 72px;
  height: 72px;
  background: var(--bg-light);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--text-muted);
  border: 2px solid var(--border-color);
}
.account-nav { list-style: none; }
.account-nav li { margin-bottom: 0.15rem; }
.account-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  color: var(--text-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: var(--transition-fast);
}
.account-nav a:hover { background: var(--bg-light); color: var(--primary); }
.account-nav a.active {
  background: rgba(0,45,98,0.07);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding-left: 0.85rem;
}
.account-nav i      { width: 18px; text-align: center; font-size: 0.9em; }
.account-content    { flex: 1; min-width: 0; }

/* =========================================
   12. ADMIN LAYOUT — SIDEBAR + CONTENT
   ========================================= */
body.admin-layout {
  flex-direction: row !important;
  overflow: hidden;
  height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
              width 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.admin-sidebar::-webkit-scrollbar       { width: 4px; }
.admin-sidebar::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.admin-sidebar .logo { color: #fff; }
.admin-sidebar .sidebar-main {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.admin-sidebar ul { list-style: none; padding: 0.75rem; }
.admin-sidebar li { margin-bottom: 0.25rem; }
.admin-sidebar a {
  color: var(--sidebar-link);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  transition: var(--transition-fast);
  font-weight: 500;
  font-size: var(--fs-sm);
  text-decoration: none;
}
.admin-sidebar a:hover {
  background: rgba(255,255,255,0.08);
  color: var(--sidebar-hover);
}
.admin-sidebar a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left: 3px solid var(--secondary);
  padding-left: 0.85rem;
}
.admin-sidebar i { width: 1.1rem; text-align: center; font-size: 0.9em; opacity: 0.8; }

.sidebar-section-label {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  margin-top: 0.25rem;
}

.admin-content {
  flex: 1;
  min-width: 0;
  padding: clamp(1rem, 3vw, 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-body);
  height: 100vh;
}

.admin-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--bg-sidebar);
  height: var(--admin-topbar-height);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 999;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-topbar .logo         { color: #fff; font-size: var(--fs-md); }
.admin-topbar .logo:hover   { color: var(--secondary); }
.admin-topbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.admin-topbar-toggle:hover { background: rgba(255,255,255,0.15); }

.admin-menu-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.45rem 0.875rem;
  color: var(--text-heading);
  font-family: var(--font-base);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.admin-menu-toggle:hover { background: var(--bg-light); }

.admin-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 1998; cursor: pointer; }
.admin-overlay.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 22vw, 220px), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--border-color);
}
.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}
.stat-card .stat-value {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* =========================================
   13. CHAT WIDGET
   ========================================= */
#chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0,45,98,0.45);
  display: flex !important;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 5000;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
  -webkit-tap-highlight-color: transparent;
}
#chat-widget:hover { transform: scale(1.1); box-shadow: 0 6px 22px rgba(0,45,98,0.55); }

#chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: clamp(300px, 90vw, 360px);
  height: min(500px, 70vh);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-premium);
  display: none;
  flex-direction: column;
  z-index: 5000;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.chat-header {
  padding: 0.875rem 1rem;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header span { font-weight: 600; font-size: var(--fs-sm); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg-light);
  -webkit-overflow-scrolling: touch;
}
.chat-user-msg {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  padding: 0.65rem 0.875rem;
  border-radius: 14px 14px 2px 14px;
  max-width: 82%;
  font-size: var(--fs-sm);
  word-wrap: break-word;
}
.chat-bot-msg {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-heading);
  padding: 0.65rem 0.875rem;
  border-radius: 14px 14px 14px 2px;
  max-width: 82%;
  font-size: var(--fs-sm);
  word-wrap: break-word;
}
.chat-input {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  background: var(--bg-card);
}
.chat-input .form-control { font-size: 14px; padding: 0.55rem 0.875rem; }

.chat-list-pane {
  width: min(300px, 100%);
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  padding-right: 1rem;
  overflow-y: auto;
}
.chat-view-pane {
  flex-grow: 1;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.messages-area {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.04);
}
.msg-bubble {
  max-width: 72%;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 18px;
  font-size: var(--fs-sm);
  word-wrap: break-word;
}
.msg-bubble.sent {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bubble.received {
  align-self: flex-start;
  background: #E5E7EB;
  color: var(--text-heading);
  border-bottom-left-radius: 4px;
}

/* =========================================
   14. TOASTS
   ========================================= */
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--dark);
  color: #fff;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastSlideIn 0.3s ease;
  font-size: var(--fs-sm);
  pointer-events: auto;
  min-width: 240px;
}
.toast-success { background: var(--success); }
.toast-danger  { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--dark); }
.toast-info    { background: var(--info); }

@keyframes toastSlideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* =========================================
   15. GLOBAL LOADER
   ========================================= */
#global-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#global-loader.active { opacity: 1; pointer-events: all; }

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   16. READER / WATERMARK
   ========================================= */
.reader-content     { position: relative; min-height: 80vh; }
.watermark-overlay  { position: absolute; inset: 0; pointer-events: none; z-index: 100; }

/* =========================================
   17. FOOTER
   ========================================= */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
footer a { color: var(--text-muted); transition: var(--transition-fast); }
footer a:hover { color: var(--primary); }
body.dark-mode footer a       { color: var(--text-muted); }
body.dark-mode footer a:hover { color: #7EB5FF; }

/* =========================================
   18. MISC COMPONENTS
   ========================================= */
.alert {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: var(--fs-sm);
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.alert-success { background: rgba(16,185,129,0.1);  border-color: var(--success); color: #065F46; }
.alert-danger  { background: rgba(239,68,68,0.1);   border-color: var(--danger);  color: #991B1B; }
.alert-warning { background: rgba(245,158,11,0.1);  border-color: var(--warning); color: #92400E; }
.alert-info    { background: rgba(59,130,246,0.1);  border-color: var(--info);    color: #1E40AF; }
body.dark-mode .alert-success { color: #6EE7B7; }
body.dark-mode .alert-danger  { color: #FCA5A5; }
body.dark-mode .alert-warning { color: #FCD34D; }
body.dark-mode .alert-info    { color: #93C5FD; }

.pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-body);
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 0 0.5rem;
}
.page-btn:hover    { background: var(--bg-light); color: var(--primary); border-color: var(--primary); }
.page-btn.active   { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.progress-wrap { background: var(--bg-light); border-radius: 50px; overflow: hidden; height: 8px; }
.progress-bar  { height: 100%; background: var(--primary); border-radius: 50px; transition: width 0.4s ease; }

.divider { height: 1px; background: var(--border-color); margin: 1.5rem 0; }

/* =========================================
   19. TOOLBAR ACTIONS
   ========================================= */
.toolbar-actions {
  padding-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
}

/* On mobile: currency form spans full width and centers */
.toolbar-actions > form:last-child {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  max-width: 200px;
}

@media (min-width: 768px) {
  .toolbar-actions {
    grid-template-columns: auto auto auto;
    /* FIX: justify-content:flex-end is not valid on grid — use end */
    justify-content: end;
  }

  .toolbar-actions > form:last-child {
    grid-column: auto;
    justify-self: auto;
    max-width: none;
  }
}

/* =========================================
   20. FLEXBOX GRID SYSTEM
   ========================================= */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -15px;
  margin-left: -15px;
}

[class*="col-"] {
  position: relative;
  width: 100%;
  padding: 10px;
}

/* Mobile (default) */
.col-1  { width: 8.333333%; }
.col-2  { width: 16.666667%; }
.col-3  { width: 25%; }
.col-4  { width: 33.333333%; }
.col-5  { width: 41.666667%; }
.col-6  { width: 50%; }
.col-7  { width: 58.333333%; }
.col-8  { width: 66.666667%; }
.col-9  { width: 75%; }
.col-10 { width: 83.333333%; }
.col-11 { width: 91.666667%; }
.col-12 { width: 100%; }

/* Tablet / md ≥ 768px */
@media (min-width: 768px) {
  .col-md-1  { width: 8.333333%; }
  .col-md-2  { width: 16.666667%; }
  .col-md-3  { width: 25%; }
  .col-md-4  { width: 33.333333%; }
  .col-md-5  { width: 41.666667%; }
  .col-md-6  { width: 50%; }
  .col-md-7  { width: 58.333333%; }
  .col-md-8  { width: 66.666667%; }
  .col-md-9  { width: 75%; }
  .col-md-10 { width: 83.333333%; }
  .col-md-11 { width: 91.666667%; }
  .col-md-12 { width: 100%; }
}

/* Extra large / xl ≥ 1200px */
@media (min-width: 1200px) {
  .col-xl-1  { width: 8.333333%; }
  .col-xl-2  { width: 16.666667%; }
  .col-xl-3  { width: 25%; }
  .col-xl-4  { width: 33.333333%; }
  .col-xl-5  { width: 41.666667%; }
  .col-xl-6  { width: 50%; }
  .col-xl-7  { width: 58.333333%; }
  .col-xl-8  { width: 66.666667%; }
  .col-xl-9  { width: 75%; }
  .col-xl-10 { width: 83.333333%; }
  .col-xl-11 { width: 91.666667%; }
  .col-xl-12 { width: 100%; }
}

/* =========================================
   21. RESPONSIVE — TABLET (≤ 1024px)
   ========================================= */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .hero-slider       { height: clamp(280px, 45vw, 500px); }
  .account-sidebar   { width: min(240px, 35vw); }
  .grid-books        { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .features-grid     { grid-template-columns: repeat(2, 1fr); }
  .admin-content     { padding: 1.5rem; }
}

/* =========================================
   22. RESPONSIVE — TABLET (≤ 900px)
   ========================================= */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2000;
    transform: translateX(-100%);
    height: 100vh;
  }
  .admin-sidebar.active { transform: translateX(0); }

  body.admin-layout {
    flex-direction: column !important;
    height: auto;
    overflow: auto;
  }
  .admin-content {
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow-y: visible;
    padding: 1rem;
  }

  .admin-topbar      { display: flex; }
  .admin-menu-toggle { display: none !important; }
}

/* =========================================
   23. RESPONSIVE — MOBILE (≤ 768px)
   ========================================= */
@media (max-width: 768px) {
  .container { width: 96%; }

  .menu-toggle     { display: flex; }
  .header-desktop  { display: none; }

  .hero-slider  { border-radius: var(--radius); margin-bottom: 2rem; }
  .hero-section { border-radius: var(--radius); }

  .section-title { margin-bottom: 1.75rem; }

  .grid-books    { grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }
  .book-card img { height: 200px; }

  .account-layout  { flex-direction: column; gap: 1rem; }
  .account-sidebar { width: 100%; position: static; order: -1; }

  .card > table,
  .card .table-responsive { border-radius: 0; }
  .table-responsive table { display: table; }
  th, td { white-space: nowrap; }

  #chat-widget { bottom: 16px; right: 16px; width: 50px; height: 50px; }

  /* ── Chat window: full-screen on mobile ── */
  #chat-window {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-height: 100dvh; /* dvh respects browser chrome on iOS/Android */
  }

  .chat-list-pane {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0 0 1rem;
    max-height: 220px;
  }
  .chat-view-pane { padding-left: 0; }

  #toast-container { top: calc(var(--header-height) + 8px); right: 8px; left: 8px; max-width: 100%; }
  .toast           { min-width: unset; width: 100%; }

  .p-2    { padding: 1.25rem; }
  .py-2   { padding-block: 1.5rem; }
  .gap-2  { gap: 1rem; }
  .card-body   { padding: 1rem; }
  .card-header { padding: 0.875rem 1rem; }

  .features-grid { grid-template-columns: 1fr 1fr; gap: 0.875rem; }
  .btn-lg        { padding: 0.8rem 1.75rem; font-size: var(--fs-base); }
}

/* =========================================
   24. RESPONSIVE — SMALL MOBILE (≤ 480px)
   ========================================= */
@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }
  .grid-books    { grid-template-columns: 1fr 1fr; }
  .stats-grid    { grid-template-columns: 1fr 1fr; }

  .btn    { padding: 0.6rem 1.2rem;  font-size: var(--fs-sm); }
  .btn-lg { padding: 0.75rem 1.5rem; font-size: var(--fs-base); }
  .btn-sm { padding: 0.3rem 0.75rem; font-size: var(--fs-xs); }

  .hero-content p { font-size: var(--fs-base); }
  .slider-btn     { width: 32px; height: 32px; font-size: 0.8rem; }

  .p-2  { padding: 1rem; }
  .py-3 { padding-block: 2rem; }
}

/* FIX: Extracted from invalid nested @media — was silently dropped by all browsers */
@media (max-width: 360px) {
  .grid-books { grid-template-columns: 1fr; }
}

/* =========================================
   25. PRINT
   ========================================= */
@media print {
  header, .admin-sidebar, .admin-topbar, #chat-widget, #chat-window,
  #toast-container, #global-loader, .no-print { display: none !important; }
  body { background: white; color: black; font-size: 12pt; }
  .container { width: 100%; max-width: 100%; }
  a { color: black; text-decoration: underline; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}