@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  /* Default Theme (Ficus Sage) */
  --bg-gradient: linear-gradient(135deg, #fdfdfa 0%, #e8ebe1 100%);
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(89, 104, 75, 0.3);
  --text-primary: #2c2f2a;
  --text-secondary: #5a6157;
  --accent: #59684b;
  --cover-bg: #f4f6ef;
  --cover-text: #2c2f2a;
  --cover-texture: url("https://www.transparenttextures.com/patterns/woven.png");
  --page-shadow: rgba(89, 104, 75, 0.2);
}

/* 1. Ficus Sage */
[data-theme="ficus-sage"], [data-theme="elegance-gold"] {
  --bg-gradient: linear-gradient(135deg, #fdfdfa 0%, #e8ebe1 100%);
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(89, 104, 75, 0.3);
  --text-primary: #2c2f2a;
  --text-secondary: #5a6157;
  --accent: #59684b;
  --cover-bg: #f4f6ef;
  --cover-text: #2c2f2a;
  --cover-texture: url("https://www.transparenttextures.com/patterns/woven.png"); /* Linen/Canvas */
}

/* 2. Modern Terracotta */
[data-theme="modern-terracotta"] {
  --bg-gradient: linear-gradient(135deg, #fdf8f5 0%, #e8d5cc 100%);
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(226, 114, 91, 0.3);
  --text-primary: #4a3b32;
  --text-secondary: #7a6b62;
  --accent: #e2725b;
  --cover-bg: #e2725b;
  --cover-text: #fff;
  --cover-texture: url("https://www.transparenttextures.com/patterns/leather.png"); /* Leather */
}

/* 3. Regal Navy */
[data-theme="regal-navy"] {
  --bg-gradient: linear-gradient(135deg, #e0e5ec 0%, #b8c6db 100%);
  --glass-bg: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(0, 31, 63, 0.3);
  --text-primary: #001f3f;
  --text-secondary: #395273;
  --accent: #001f3f;
  --cover-bg: #001f3f;
  --cover-text: #fff;
  --cover-texture: url("https://www.transparenttextures.com/patterns/leather.png");
}

/* 4. Minimalist White */
[data-theme="minimalist-white"] {
  --bg-gradient: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-primary: #111;
  --text-secondary: #777;
  --accent: #000;
  --cover-bg: #f9f9f9;
  --cover-text: #000;
  --cover-texture: url("https://www.transparenttextures.com/patterns/paper.png"); /* Fine paper */
}

/* 5. Midnight Noir */
[data-theme="midnight-noir"] {
  --bg-gradient: linear-gradient(135deg, #1f1f1f 0%, #0a0a0a 100%);
  --glass-bg: rgba(0, 0, 0, 0.6);
  --glass-border: rgba(200, 200, 200, 0.2);
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --accent: #b0c4de;
  --cover-bg: #111;
  --cover-text: #f0f0f0;
  --cover-texture: url("https://www.transparenttextures.com/patterns/black-scales.png"); /* Scaled leather */
}

/* 6. Vintage Sepia */
[data-theme="vintage-sepia"] {
  --bg-gradient: linear-gradient(135deg, #f4ecd8 0%, #d4c4a8 100%);
  --glass-bg: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(139, 90, 43, 0.3);
  --text-primary: #5c3a21;
  --text-secondary: #8c6b4f;
  --accent: #8b5a2b;
  --cover-bg: #8b5a2b;
  --cover-text: #f4ecd8;
  --cover-texture: url("https://www.transparenttextures.com/patterns/worn-dots.png"); /* Old textured leather */
}

/* 7. Forest Emerald */
[data-theme="forest-emerald"] {
  --bg-gradient: linear-gradient(135deg, #e3ede3 0%, #b3cbb3 100%);
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(23, 74, 43, 0.3);
  --text-primary: #174a2b;
  --text-secondary: #3b6e4e;
  --accent: #174a2b;
  --cover-bg: #174a2b;
  --cover-text: #f5f5f5;
  --cover-texture: url("https://www.transparenttextures.com/patterns/leather.png");
}

/* 8. Soft Pastel */
[data-theme="soft-pastel"] {
  --bg-gradient: linear-gradient(135deg, #ffe6ea 0%, #e6f0ff 100%);
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 182, 193, 0.4);
  --text-primary: #5a4b5e;
  --text-secondary: #8a7b8e;
  --accent: #ffb6c1;
  --cover-bg: #fff0f5;
  --cover-text: #5a4b5e;
  --cover-texture: url("https://www.transparenttextures.com/patterns/cubes.png"); /* Soft geometric */
}

/* 9. Rustic Charm */
[data-theme="rustic-charm"] {
  --bg-gradient: linear-gradient(135deg, #f0ebd8 0%, #c4b7a6 100%);
  --glass-bg: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(101, 67, 33, 0.3);
  --text-primary: #3b2f2f;
  --text-secondary: #6e5c5c;
  --accent: #654321;
  --cover-bg: #ebd5c1;
  --cover-text: #3b2f2f;
  --cover-texture: url("https://www.transparenttextures.com/patterns/wood-pattern.png"); /* Wood */
}

/* 10. Monochrome Pearl */
[data-theme="monochrome-pearl"] {
  --bg-gradient: linear-gradient(135deg, #f5f5f5 0%, #dcdcdc 100%);
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(150, 150, 150, 0.3);
  --text-primary: #333;
  --text-secondary: #777;
  --accent: #708090;
  --cover-bg: #e0e6ed;
  --cover-text: #2c3e50;
  --cover-texture: url("https://www.transparenttextures.com/patterns/woven.png");
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  transition: background 0.5s ease, color 0.5s ease;
}

body.admin-page-body {
  background: linear-gradient(135deg, #fdfdfa 0%, #e8ebe1 100%) !important;
  color: #2c2f2a !important;
}

h1, h2, h3, .serif {
  font-family: 'Playfair Display', serif;
}

/* Glassmorphism Container */
.glass-container {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  width: 90%;
  max-width: 600px;
  margin: 2rem auto;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
input, select, button {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.8);
  color: #333;
  transition: all 0.3s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}
button.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: none;
  cursor: pointer;
  margin-top: 1rem;
}
button.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
button.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
button.btn-secondary:hover {
  background: rgba(0,0,0,0.05);
}

/* Alert */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
}
.alert.success { background: #d4edda; color: #155724; display: block; }
.alert.error { background: #f8d7da; color: #721c24; display: block; }

/* Visual Theme Picker */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.theme-card {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  background: rgba(255,255,255,0.5);
  transition: all 0.2s;
}
.theme-card:hover {
  background: rgba(255,255,255,0.8);
}
.theme-card.selected {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.theme-color-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto 5px;
  border: 1px solid rgba(0,0,0,0.1);
}
.theme-card span {
  font-size: 0.8rem;
  font-weight: 500;
  color: #333;
}

/* Landing Page (Demo) */
.landing-container {
  text-align: center;
  max-width: 800px;
  padding: 40px 20px;
}
.hero-title {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: var(--accent);
}
.hero-subtitle {
  font-size: 1.2rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  color: var(--text-secondary);
}
.landing-features {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 40px;
  flex-wrap: wrap;
}
.feature-item {
  background: var(--glass-bg);
  padding: 20px;
  border-radius: 12px;
  width: 200px;
  border: 1px solid var(--glass-border);
}
.feature-item i {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 15px;
}

/* Flipbook Viewer */
.flipbook-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  padding: 5px; /* Minimal padding so it fills almost the entire screen */
  overflow: hidden;
}
#flipbook {
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  transition: transform 0.3s;
}
.page {
  position: relative;
  /* NO overflow: hidden here, so 3D shadows don't get clipped! */
  box-shadow: 0 15px 35px rgba(0,0,0,0.3); /* Global drop shadow on the table */
}
.page.--left {
  border-radius: 4px 0 0 4px;
}
.page.--right {
  border-radius: 0 4px 4px 0;
}

/* 3D Thick Paper Edge Simulation (2mm board thickness) */
.page.--left::before {
  content: ""; position: absolute; top: 0; left: -6px; bottom: 0; width: 6px;
  background: linear-gradient(to right, #777 0%, #ccc 40%, #fff 100%);
  z-index: -1; pointer-events: none;
  border-radius: 3px 0 0 3px;
  box-shadow: -2px 5px 10px rgba(0,0,0,0.2);
}
.page.--right::before {
  content: ""; position: absolute; top: 0; right: -6px; bottom: 0; width: 6px;
  background: linear-gradient(to left, #777 0%, #ccc 40%, #fff 100%);
  z-index: -1; pointer-events: none;
  border-radius: 0 3px 3px 0;
  box-shadow: 2px 5px 10px rgba(0,0,0,0.2);
}

/* Removed dark spine shadows as requested */
.page.--left .page-content::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  /* Very subtle highlight only on the edge, no dark shadow */
  background: linear-gradient(to right, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 8%);
  pointer-events: none;
  z-index: 20;
}
.page.--right .page-content::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: linear-gradient(to left, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 8%);
  pointer-events: none;
  z-index: 20;
}

.page-content {
  width: 100%;
  height: 100%;
  background-color: #fdfdfd;
  background-image: url("https://www.transparenttextures.com/patterns/cream-paper.png");
  border: solid 4px #ffffff;
  overflow: hidden; /* Clip images here instead of .page */
  position: relative;
  box-shadow: inset 0px 0px 15px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* 3D Thick Paper Edge Simulation (2mm board thickness) */
.page.--left::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 6px;
  background: linear-gradient(to right, #999 0%, #eee 40%, #fff 100%);
  z-index: 10; pointer-events: none;
  border-right: 1px solid rgba(0,0,0,0.1);
}
.page.--right::before {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 6px;
  background: linear-gradient(to left, #999 0%, #eee 40%, #fff 100%);
  z-index: 10; pointer-events: none;
  border-left: 1px solid rgba(0,0,0,0.1);
}
.page-content.full-image { padding: 40px; }
.page-content img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* changed from cover to prevent cropping */
  opacity: 0;
  transition: opacity 0.5s ease;
  cursor: zoom-in;
}
.page-content img.loaded { opacity: 1; }

/* Cover Pages */
.page.cover, .page.page-cover {
  background-color: var(--cover-bg);
  background-image: var(--cover-texture);
  background-blend-mode: multiply;
  color: var(--cover-text);
  border: none;
  box-shadow: inset 0 0 50px rgba(0,0,0,0.8), inset 0 0 10px rgba(255,255,255,0.1), 0 20px 40px rgba(0,0,0,0.5);
}

/* Spine Hinge (Groove) & Cover Lighting for Hardcover */
.page.page-cover.--left::after {
  content: ""; position: absolute; inset: 0;
  /* Inner spine shadow (right side) + Groove + Outer highlight */
  background: linear-gradient(to right, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 15%, rgba(0,0,0,0) 85%, rgba(0,0,0,0.6) 92%, rgba(255,255,255,0.1) 95%, rgba(0,0,0,0.8) 100%);
  z-index: 20; pointer-events: none;
}
.page.page-cover.--right::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to left, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 15%, rgba(0,0,0,0) 85%, rgba(0,0,0,0.6) 92%, rgba(255,255,255,0.1) 95%, rgba(0,0,0,0.8) 100%);
  z-index: 20; pointer-events: none;
}

/* Hardcover Outer Thickness Edge */
.page.page-cover.--left::before {
  content: ""; position: absolute; top: 0; left: -10px; bottom: 0; width: 10px;
  background: linear-gradient(to right, #222, #555, #888);
  z-index: -1; pointer-events: none;
  border-radius: 4px 0 0 4px;
  box-shadow: -3px 8px 15px rgba(0,0,0,0.4);
}
.page.page-cover.--right::before {
  content: ""; position: absolute; top: 0; right: -10px; bottom: 0; width: 10px;
  background: linear-gradient(to left, #222, #555, #888);
  z-index: -1; pointer-events: none;
  border-radius: 0 4px 4px 0;
  box-shadow: 3px 8px 15px rgba(0,0,0,0.4);
}

.page.cover .cover-content, .page.page-cover .cover-content {
  background: transparent;
  box-shadow: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  
  /* Reset width/height to let inset dictate size */
  width: auto;
  height: auto;
  margin: 0;
  
  /* Use absolute inset based on actual book dimensions (--bh and --bw) */
  position: absolute;
  top: calc(var(--bh) * 0.05);
  bottom: calc(var(--bh) * 0.05);
  left: calc(var(--bw) * 0.05);
  right: calc(var(--bw) * 0.12); /* More room for the spine hinge */
  
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  padding: calc(var(--bh) * 0.05);
  z-index: 10;
  box-sizing: border-box;
}

/* Back cover spine is on the left */
.page.page-cover.--right .cover-content {
  left: calc(var(--bw) * 0.12);
  right: calc(var(--bw) * 0.05);
}

.cover-title { 
    font-size: calc(var(--bw) * 0.09); 
    margin-bottom: calc(var(--bh) * 0.03); 
    line-height: 1.1; 
    word-break: normal; 
    overflow-wrap: break-word; 
    hyphens: auto;
    padding: 0 5%;
}
.cover-subtitle { font-size: calc(var(--bw) * 0.045); font-weight: 300; letter-spacing: 2px; text-transform: uppercase; margin-bottom: calc(var(--bh) * 0.02); }
.cover-date { font-size: calc(var(--bw) * 0.04); margin-top: auto; opacity: 0.8; }
.cover-content h2.serif { font-size: calc(var(--bw) * 0.08); margin-bottom: calc(var(--bh) * 0.02); }

/* Grid Layouts for Auto-Engine */
.photo-grid-2 { display: grid; grid-template-rows: 1fr 1fr; gap: 3px; height: 100%; width: 100%; }
.photo-grid-3 { display: grid; grid-template-rows: 1fr 1fr 1fr; gap: 3px; height: 100%; width: 100%; }
.photo-grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; height: 100%; width: 100%; }
.photo-grid-mixed { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; height: 100%; width: 100%; }
.photo-grid-mixed .featured { grid-column: 1 / -1; }

.photo-grid-5 { 
    display: grid; 
    grid-template-columns: repeat(6, 1fr); 
    grid-template-rows: 1fr 1fr; 
    gap: 3px; 
    height: 100%; 
    width: 100%; 
}
.photo-grid-5 img:nth-child(1), .photo-grid-5 img:nth-child(2) {
    grid-column: span 3;
}
.photo-grid-5 img:nth-child(3), .photo-grid-5 img:nth-child(4), .photo-grid-5 img:nth-child(5) {
    grid-column: span 2;
}

.photo-grid-6 { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    grid-template-rows: repeat(3, 1fr); 
    gap: 3px; 
    height: 100%; 
    width: 100%; 
}

.photo-grid-2 img, .photo-grid-3 img, .photo-grid-2-col img, .photo-grid-mixed img, .photo-grid-5 img, .photo-grid-6 img { 
    object-fit: contain; 
    border-radius: 6px; 
    width: 100%; 
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
}

/* Floating Action Bar */
.action-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-radius: 30px;
  display: flex;
  gap: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  z-index: 1000;
  border: 1px solid var(--glass-border);
}
.action-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}
.action-btn:hover {
  background: rgba(255,255,255,0.5);
  color: var(--accent);
  transform: scale(1.1);
}

/* Loading */
.loader {
  border: 4px solid rgba(0,0,0,0.1);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

@media (max-width: 768px) {
  .cover-title { font-size: 1.8rem; }
  .cover-subtitle { font-size: 1rem; }
  .hero-title { font-size: 2.5rem; }
  .responsive-grid {
      grid-template-columns: 1fr;
  }
  .glass-container {
      padding: 20px;
      width: 95%;
  }
}

.responsive-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 99999;
    padding: 20px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.lightbox.show {
    opacity: 1;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 100000;
}
.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}
.lightbox-content-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.lightbox-content.loaded {
    opacity: 1;
}
.lightbox-loader {
    position: absolute;
    color: white;
    font-size: 1.2rem;
    pointer-events: none;
}

/* Lightbox Action Buttons */
.lightbox-actions {
    position: absolute;
    bottom: 20px;
    right: 35px;
    display: flex;
    gap: 15px;
    z-index: 100000;
}
.lightbox-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}
.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}
.lightbox-btn.active {
    color: #ff4757;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal.show {
    display: flex;
    opacity: 1;
}
.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
}
.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #666;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover {
    color: #000;
}

/* Favorites List Styles */
.fav-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.fav-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.back-cover-logo {
    width: 100% !important;
    max-width: 350px !important;
    height: auto !important;
    max-height: calc(var(--bh) * 0.20) !important;
    object-fit: contain;
    opacity: 0.9 !important;
    margin: 0 auto;
    display: block;
}
.fav-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: transform 0.2s;
}
.fav-remove-btn:hover {
    transform: scale(1.1);
}

/* Lightbox Styles for Sort Gallery */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.lightbox.show {
    display: flex;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 1010;
}
.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    z-index: 1010;
    transition: background 0.3s;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-nav-btn:hover {
    background: rgba(0,0,0,0.8);
}
.lightbox-prev {
    left: 20px;
}
.lightbox-next {
    right: 20px;
}
@media (max-width: 600px) {
    .lightbox-nav-btn {
        width: 40px; height: 40px; font-size: 1.2rem;
    }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
}
.lightbox-content-wrapper {
    position: relative;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s;
}
.lightbox-content.loaded {
    opacity: 1;
}
.lightbox-loader {
    position: absolute;
    border-color: white transparent transparent transparent;
}
.lightbox-actions {
    margin-top: 20px;
}
.lightbox-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}
.lightbox-btn.active {
    background: #25D366;
    border-color: #25D366;
}

/* =========================================================
   ADMIN DASHBOARD ENHANCEMENTS (STATS, BADGES, ROLES)
   ========================================================= */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.green { background: rgba(37, 211, 102, 0.15); color: #1e9e4f; }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.stat-icon.gold { background: rgba(212, 175, 55, 0.18); color: #b8911b; }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
.stat-icon.purple { background: rgba(147, 51, 234, 0.15); color: #7e22ce; }

.stat-details {
    flex-grow: 1;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-gold { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

/* Filter & Action Bars */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.admin-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-search-input {
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    font-size: 0.88rem;
    background: #fff;
    min-width: 220px;
}

.admin-filter-select {
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    font-size: 0.88rem;
    background: #fff;
    cursor: pointer;
}

/* Form Card Container */
.form-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 25px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

.currency-in { color: #16a34a; font-weight: 700; }
.currency-out { color: #dc2626; font-weight: 700; }

/* Role Control Classes */
body.role-admin .superadmin-only {
    display: none !important;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.admin-table th {
    padding: 12px 10px;
    background: rgba(89, 104, 75, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--glass-border);
}

.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.6);
}

/* Password Visibility & Input Helper Styles */
.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.password-field-wrapper input {
    width: 100%;
    padding-right: 42px;
}
.toggle-pwd-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    width: auto;
}
.toggle-pwd-btn:hover {
    color: var(--text-primary);
}

/* Credentials Box in Modal */
.credentials-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 14px 16px;
    margin: 15px 0;
    text-align: left;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}
.credentials-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    word-break: break-all;
}
.credentials-item:last-child {
    margin-bottom: 0;
}
.credentials-label {
    color: #64748b;
    font-weight: 600;
    margin-right: 10px;
    white-space: nowrap;
}
.credentials-val {
    color: #0f172a;
    font-weight: 700;
}

/* =========================================================
   INVOICE STYLING & PRINT MEDIA
   ========================================================= */
.invoice-sheet {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
#inv-preview-items-tbody tr:nth-child(even) {
    background-color: #f8fafc;
}
#inv-preview-items-tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}
#inv-edit-items-tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--glass-border);
}

#invoice-modal {
    display: none;
    position: fixed;
    z-index: 1000000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
#invoice-modal.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* =========================================================
   PRINT STYLES FOR INVOICE (FICUS FOCUS STYLE)
   ========================================================= */
@page {
    size: A4 portrait;
    margin: 0mm; /* Menghilangkan otomatis header browser (tanggal, judul) & footer (URL, halaman) */
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0mm;
    }

    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    body > *:not(#invoice-modal) {
        display: none !important;
    }

    #invoice-modal,
    #invoice-modal.show {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        opacity: 1 !important;
        z-index: 999999 !important;
        transform: none !important;
    }

    #invoice-modal .modal-content {
        display: block !important;
        position: static !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        max-height: none !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        transform: none !important;
    }

    .invoice-no-print {
        display: none !important;
    }

    #printable-invoice-container {
        display: block !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        /* Mepet ke atas (padding atas 4mm) */
        padding: 4mm 14mm 10mm 14mm !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
        transform: none !important;
    }

    #printable-invoice-container img {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}


