:root{
  --primary:#0b1b2b; /* deep navy */
  --primary-dark:#07121a;
  --secondary:#8a5a2b; /* warm brown */
  --accent:#b06b2c; /* amber-ish accent */
  --background:#fbf7f2; /* warm off-white */
  --surface:#ffffff;
  --text:#1b1b1b;
  --text-muted:#6b6b6b;
  --border:rgba(27,27,27,0.08);
  --success:#2d8a4a;
  --danger:#c0392b;
  --radius:12px;
  --card-shadow: 0 6px 18px rgba(11,27,43,0.06);
}

/* Theme overrides using data-theme on <html> */
[data-theme="classic"]{
  --primary:#102A43;
  --primary-dark:#0B1F33;
  --accent:#B88A2A;
  --background:#F8F4EC;
  --surface:#FFFFFF;
  --text:#263238;
  --text-muted:#6B7280;
  --border: #E7DED0;
  --card-shadow: 0 8px 24px rgba(16,42,67,0.06);
}

[data-theme="midnight"]{
  --primary:#E8EDF3;
  --primary-dark:#DCE6F2;
  --accent:#D4AF37;
  --background:#0B1220;
  --surface:#111C2E;
  --text:#F5F7FA;
  --text-muted:#AAB5C4;
  --border:#26364A;
  --card-shadow: 0 8px 28px rgba(0,0,0,0.6);
}

[data-theme="sage"]{
  --primary:#315C4A;
  --primary-dark:#244638;
  --accent:#C28B4B;
  --background:#F4F1E8;
  --surface:#FFFFFF;
  --text:#26352F;
  --text-muted:#6B756F;
  --border:#DCE1D8;
  --card-shadow: 0 6px 18px rgba(49,92,74,0.05);
}

[data-theme="burgundy"]{
  --primary:#6B2433;
  --primary-dark:#4A1723;
  --accent:#C69A4B;
  --background:#FAF3EA;
  --surface:#FFFFFF;
  --text:#302426;
  --text-muted:#756A6C;
  --border:#E6D9D0;
  --card-shadow: 0 8px 24px rgba(107,36,51,0.06);
}

/* Smooth color transitions when switching themes */
body{transition:background-color 200ms ease,color 200ms ease,border-color 200ms ease}

/* Mobile-first base typography and spacing */
html{font-size:clamp(14px, 3.6vw, 16px)}
body{font-size:1rem;line-height:1.4}
.container{padding:0 12px;max-width:100%}

/* Make interactive targets thumb-friendly */
button, .btn, .nav-link, .nav-icon {min-height:44px;min-width:44px;white-space:nowrap;display:inline-flex;align-items:center;justify-content:center}

/* Product grid: mobile-first single column, expand via media queries */
.product-grid{display:block;gap:1rem}
.product-grid .col-md-3{flex:0 0 100%;max-width:100%}
.product-grid .card{width:100%}

@media (min-width:576px){
  .product-grid .col-md-3{flex:0 0 50%;max-width:50%}
}
@media (min-width:768px){
  .product-grid .col-md-3{flex:0 0 33.3333%;max-width:33.3333%}
}
@media (min-width:992px){
  .product-grid .col-md-3{flex:0 0 25%;max-width:25%}
}

/* Ensure images scale and preserve aspect ratio */
.card .card-img-top{width:100%;height:auto;aspect-ratio:3/4;object-fit:cover}

/* Product detail: stack on mobile */
.product-detail .cover{max-width:100%}
.product-detail .info{padding-left:0}

.product-detail .cover img{width:100%;height:auto;aspect-ratio:3/4;object-fit:cover;border-radius:10px}

/* Cart responsive: convert table into stacked cards on small screens */
.table-responsive-stack{display:block}
table.table{width:100%;border-collapse:collapse}
@media (max-width:767px){
  table.table thead{display:none}
  table.table tbody tr{display:block;border:1px solid var(--border);border-radius:10px;padding:8px;margin-bottom:8px}
  table.table tbody tr td{display:flex;justify-content:space-between;align-items:center;padding:6px 8px}
  table.table tbody tr td[data-label]::before{content:attr(data-label);color:var(--text-muted);font-weight:600;margin-right:8px}
  table.table tbody tr td input[type="number"]{width:72px}
}

/* Admin responsive: offcanvas sidebar on mobile */
.admin-sidebar{position:relative;transition:transform .25s ease,opacity .25s ease}
.admin-sidebar .nav-link{justify-content:flex-start}
@media (max-width:991px){
  .admin-sidebar{position:fixed;left:0;top:0;bottom:0;width:280px;transform:translateX(-110%);z-index:1100;padding:1.5rem;background:var(--surface)}
  .admin-sidebar.open{transform:translateX(0);box-shadow:0 12px 40px rgba(11,27,43,0.2)}
  .admin-topbar{position:sticky;top:0;z-index:1050;background:var(--surface)}
  .admin-overlay{display:none;position:fixed;inset:0;background:rgba(11,27,43,0.45);z-index:1090}
  .admin-overlay.show{display:block}
}

/* Base reset and typography */
*{box-sizing:border-box}
html,body{height:100%;background:var(--background);color:var(--text);font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial}
h1,h2,h3,h4,h5{font-family:'Playfair Display',serif;color:var(--primary);margin-bottom:.5rem}
p{color:var(--text-muted);line-height:1.55}

/* Container tweaks */
.container{max-width:1140px}

/* Navbar */
.navbar{background:transparent;padding:1rem 0;transition:all .25s ease}
.navbar.sticky{background:linear-gradient(180deg,rgba(255,255,255,0.9),rgba(255,255,255,0.8));box-shadow:0 6px 18px rgba(11,27,43,0.06);backdrop-filter:saturate(120%) blur(6px);position: sticky;top:0;z-index:999;}
.navbar-brand{font-family:'Playfair Display',serif;font-weight:700;color:var(--primary);letter-spacing:.4px}
.nav-link{color:var(--text-muted);font-weight:600}
.nav-link:hover{color:var(--primary)}
.nav-icon{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px}

/* Navbar search and actions on mobile */
@media (max-width:767px){
  .navbar .d-flex {width:100%}
  .navbar .d-flex .form-control{width:100%}
  .navbar .nav-item {margin-left:0.5rem;margin-right:0.5rem}
  .cart-label{display:none}
}

/* Header hero */
.hero{padding:3.5rem 0;background:linear-gradient(180deg,transparent,rgba(255,255,255,0.6));position:relative}
.hero .lead{font-size:1.125rem;color:var(--text-muted)}
.hero .lead-label{letter-spacing:1px;color:var(--text-muted);font-weight:700}
.hero .display-5{font-family:'Playfair Display',serif;font-size:clamp(28px,6vw,44px);line-height:1.02}
.hero-visual{position:relative;height:320px;display:flex;align-items:center;justify-content:center}
.hero-book{position:absolute;width:140px;border-radius:8px;box-shadow:0 12px 30px rgba(11,27,43,0.12);transform-origin:center;transition:transform .5s ease,opacity .4s ease}
.hero-book-image{display:block;width:100%;border-radius:inherit}
.hero-book:nth-child(1){transform:translate(-40px,-10px) rotate(-6deg) scale(1.05);z-index:4}
.hero-book:nth-child(2){transform:translate(0px,10px) rotate(4deg);z-index:3}
.hero-book:nth-child(3){transform:translate(40px,-6px) rotate(-2deg);z-index:2}
.hero-book:nth-child(4){transform:translate(80px,12px) rotate(6deg);z-index:1}
.hero-book:hover{transform:translateY(-8px) scale(1.06)}

@media (max-width:767px){
  .hero{padding:2rem 0}
  .hero-visual{height:220px}
  .hero-book{width:110px}
}

/* Product grid & cards */
.product-grid .card{border:0;border-radius:12px;overflow:hidden}
.product-grid .card img{object-fit:cover;height:220px;width:100%;display:block}
.product-title{font-size:1rem;margin-bottom:.25rem}
.product-grid .card .card-body{padding:1rem}
.product-meta{font-size:.875rem;color:var(--text-muted)}

/* New responsive CSS Grid for products */
.products-grid{display:grid;grid-template-columns:repeat(1,minmax(0,1fr));gap:24px;align-items:stretch}
.products-grid > .grid-full{grid-column:1/-1}
.product-item{display:block}
.product-item .card{display:flex;flex-direction:column;height:100%}
.product-item .card img{width:100%;height:auto;aspect-ratio:2/3;object-fit:cover}
.product-item .card-body{flex:1;display:flex;flex-direction:column;padding:16px}
.product-item .card-footer{padding:12px 16px;background:transparent;border-top:0}
.product-item .product-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-clamp:2}
.product-item .product-meta{margin-bottom:8px}
.product-item .price-current{font-weight:700;color:var(--primary)}
.product-item .price-old{font-size:.9rem;color:var(--text-muted);text-decoration:line-through;margin-left:8px}
.product-item .discount-badge{margin-left:8px}

/* Hover polish */
.product-item .card{transition:transform .22s ease,box-shadow .22s ease}
.product-item:hover .card{transform:translateY(-6px);box-shadow:0 12px 30px rgba(11,27,43,0.12)}
.product-item:hover .card img{transform:scale(1.03)}

/* Responsive breakpoints */
@media (min-width:420px){
  .products-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (min-width:768px){
  .products-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (min-width:992px){
  .products-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media (min-width:1200px){
  .products-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}

/* Ensure pagination and header span full width */
.products-grid .page-header{padding:0;margin-bottom:0}
.empty-state .card{border-radius:12px}

/* Offcanvas filters (mobile) */
.filters-offcanvas{position:fixed;top:0;right:-100%;width:320px;height:100%;background:var(--surface);box-shadow:-8px 0 30px rgba(11,27,43,0.12);z-index:1050;transition:right .28s ease}
.filters-offcanvas.open{right:0}
.filters-backdrop{position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:1040;opacity:0;pointer-events:none;transition:opacity .2s}
.filters-backdrop.show{opacity:1;pointer-events:auto}
.filters-offcanvas .offcanvas-header{padding:1rem;border-bottom:1px solid rgba(0,0,0,0.06)}
.filters-offcanvas .offcanvas-body{padding:1rem;overflow:auto}

/* Product detail (PDP) */
.product-detail .cover{background:var(--muted-bg);padding:12px;border-radius:12px;display:flex;align-items:center;justify-content:center}
.product-detail .cover img{max-width:100%;height:auto;border-radius:6px}
.product-detail h2{font-family:'Playfair Display',serif;margin-bottom:.25rem}
.product-detail .muted{color:var(--text-muted);}
.product-detail .specs{font-size:.95rem;margin-top:1rem}

.product-viewer{max-width:420px}
.product-viewer__main{position:relative;display:flex;align-items:center;justify-content:center;min-height:420px;overflow:hidden;background:var(--muted-bg);border-radius:12px;cursor:zoom-in}
.product-viewer__slides{width:100%;height:100%;display:flex;align-items:center;justify-content:center}
.product-viewer__slide{display:none;width:100%;height:100%;align-items:center;justify-content:center}
.product-viewer__slide.is-active{display:flex}
.product-viewer__main img{max-width:100%;max-height:560px;object-fit:contain;border-radius:6px;transition:transform .2s ease}
.product-viewer__main img.is-zoomed{cursor:zoom-out}
.product-viewer__video{width:100%;height:100%;min-height:420px;border:0}
.product-viewer__arrow{position:absolute;top:50%;z-index:2;width:38px;height:38px;border:0;border-radius:50%;background:rgba(255,255,255,.9);color:var(--primary);font-size:2rem;line-height:1;transform:translateY(-50%);box-shadow:0 2px 8px rgba(0,0,0,.14)}
.product-viewer__arrow--prev{left:12px}
.product-viewer__arrow--next{right:12px}
.product-viewer__hint{position:absolute;right:10px;bottom:10px;padding:.25rem .5rem;background:rgba(255,255,255,.86);border-radius:6px;font-size:.72rem;color:var(--text-muted)}
.product-viewer__thumbs{display:flex;gap:.5rem;overflow-x:auto;padding:.75rem 2rem}
.product-viewer__thumb{width:64px;height:78px;flex:0 0 64px;padding:3px;border:1px solid var(--border);border-radius:7px;background:var(--surface)}
.product-viewer__thumb.is-active{border:2px solid var(--primary)}
.product-viewer__thumb img{width:100%;height:100%;object-fit:cover;border-radius:4px}
.product-viewer__thumb--video{display:flex;align-items:center;justify-content:center;font-size:.75rem;font-weight:600;color:var(--primary)}
.youtube-preview{margin-top:.75rem;overflow:hidden;border:1px solid var(--border);border-radius:8px;background:#000;aspect-ratio:16/9}
.youtube-preview iframe{width:100%;height:100%;border:0}
.product-viewer__controls{display:flex;align-items:center;justify-content:flex-end;gap:.4rem;font-size:.8rem;color:var(--text-muted)}
.product-gallery-admin{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:.75rem}
.product-gallery-admin__item{display:flex;flex-direction:column;gap:.25rem;font-size:.72rem;color:var(--text-muted)}
.product-gallery-admin__item img{width:100%;height:120px;object-fit:cover;border-radius:6px;border:1px solid var(--border)}

.product-info {
  margin-top: 1.7rem;
}

/* Mobile sticky add-to-cart bar */
.pdp-sticky{position:fixed;left:0;right:0;bottom:0;background:var(--surface);box-shadow:0 -6px 24px rgba(11,27,43,0.08);padding:.6rem .75rem;z-index:1060;display:flex;align-items:center;gap:.5rem}
.pdp-sticky .thumb{width:46px;height:60px;flex:0 0 46px;border-radius:6px;overflow:hidden}
.pdp-sticky .thumb img{width:100%;height:100%;object-fit:cover}
.pdp-sticky .meta{flex:1}
.pdp-sticky .meta .title{font-size:.95rem}
.pdp-sticky .meta .price{font-weight:700;color:var(--primary)}
.pdp-sticky .actions{display:flex;gap:.5rem}
.pdp-spacer{height:72px}

@media (min-width:768px){
  .pdp-sticky{display:none}
}

/* Cards */
.card{border-radius:var(--radius);border:1px solid var(--border);box-shadow:var(--card-shadow);overflow:hidden}
.card .card-img-top{object-fit:cover;height:260px;transition:transform .35s ease}
.card:hover .card-img-top{transform:scale(1.03)}
.product-title{font-size:1rem;color:var(--primary);margin-bottom:.25rem}
.product-author{color:var(--text-muted);font-size:.875rem}

.badge-discount{background:var(--secondary);color:#fff;border-radius:8px;padding:.25rem .5rem;font-size:.75rem}

/* Buttons */
.btn-primary{background:var(--primary);border-color:var(--primary);box-shadow:none;border-radius:10px;padding:.5rem .8rem}
.btn-primary:hover{background:var(--primary-dark);border-color:var(--primary-dark)}
.btn-outline-primary{color:var(--primary);border-color:var(--border);background:transparent}

/* Product grid */
.product-grid .col-md-3{display:flex}
.product-grid .card{flex:1;display:flex;flex-direction:column}

/* Product detail */
.product-detail .cover{max-width:420px;border-radius:10px;overflow:hidden}
.product-detail .info{padding-left:2rem}

/* Cart and summary */
.order-summary{background:var(--surface);border-radius:12px;padding:1rem;border:1px solid var(--border);box-shadow:0 6px 18px rgba(11,27,43,0.04)}

/* Admin styles */
.admin-sidebar{width:136px;background:var(--surface);border-radius:12px;padding:1rem;border:1px solid var(--border);height:100%}
.admin-topbar{background: var(--background);padding:.8rem 1rem;border-bottom:1px solid rgba(11,27,43,0.04)}
.admin-card{border-radius:12px;padding:1rem;background:var(--surface);box-shadow:0 8px 24px rgba(11,27,43,0.04)}

/* Tables */
.table thead th{background:transparent;border-bottom:2px solid var(--border);font-weight:600;color:var(--text)}
.table tbody tr:hover{background:rgba(11,27,43,0.02)}

/* Forms */
.form-control:focus{box-shadow:0 0 0 4px rgba(176,107,44,0.08);border-color:var(--secondary)}
.form-label{font-weight:600;color:var(--text)}

/* Touch-friendly small buttons and inputs */
.btn-sm{padding:.5rem .6rem;min-height:40px}
.form-control{padding:.6rem .75rem}
.form-control.form-control-sm{padding:.45rem .6rem}

/* Toasts */
.toastify{position:fixed;right:24px;top:24px;z-index:1080}
.toast{background:var(--surface);border-radius:10px;padding:.6rem 1rem;border:1px solid var(--border);box-shadow:0 6px 18px rgba(11,27,43,0.06);margin-bottom:.5rem}

/* Utilities */
.text-muted-2{color:var(--text-muted)}

/* Accessibility: visible focus */
*:focus{outline:3px solid rgba(11,27,43,0.08);outline-offset:2px}
*:focus:not(:focus-visible){outline:none}

@media (max-width:767px){
  .card .card-img-top{height:200px}
  .product-grid .col-md-3{flex:unset}
}
