/* --- GLOBÁLNÍ PROMĚNNÉ --- */
:root {
  --zoom: 1;
  --shadow-size: 40px;
  --shadow-offset: 0px; 
  --shadow-color: rgba(0, 0, 0, 0.5); 
}

/* --- ZÁKLADNÍ ROZLOŽENÍ STRÁNKY --- */
body {
  margin: 0;
  padding: 0;
  width: 100vw; 
  height: 100vh; 
  position: relative; 
  background-color: #f0f0f0;
  overflow: hidden; 
  transition: background-color 0.5s ease;
}

/* --- TMAVÝ REŽIM (DARK MODE) --- */
body.dark-mode {
  background-color: #000000;
}

body.dark-mode .settings-menu {
  background-color: #2c2c2c;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

body.dark-mode .setting-item,
body.dark-mode .setting-group {
  color: #ecf0f1; 
}

body.dark-mode .menu-divider {
  background: #444; 
}

/* --- FUNKCE PŘIBLÍŽENÍ (ZOOM) --- */
.zoom-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Používáme už jen uživatelský zoom, responzivitu řeší knihovna s krabičkou */
  transform: translate(-50%, -50%) scale(var(--zoom));
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- CHYTRÝ ZÁMEK OBALU (NATIVNÍ RESPONZIVITA) --- */
.book-bounding-box {
  /* CSS Magie: Vypočítá max velikost tak, aby se vešla na obrazovku, ale VŽDY zachovala poměr 8:6 */
  width: min(95vw, 800px, calc(85vh * 8 / 6));
  height: min(85vh, 600px, calc(95vw * 6 / 8));
  position: relative;
}

/* --- HLAVNÍ KONTEJNER LETÁKU --- */
.flipBook {
  width: 100%;
  height: 100%;
  opacity: 0; 
  transition: opacity 0.8s ease, transform 0.6s ease; 
  transform: translateX(-25%); 
}

/* --- JEDNOTLIVÉ STRÁNKY --- */
.page {
  background-color: #fff;
  position: relative;
  overflow: hidden;
}

/* --- 3D EFEKT ROZEVŘENÉ KNIHY --- */
/* Vnitřní stíny simulující hloubku a ohyb papíru u hřbetu */
.shadow-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset -25px 0 30px -15px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 10;
}

.shadow-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 25px 0 30px -15px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 10;
}

/* --- NAČÍTACÍ KOLEČKO (PRELOADER) --- */
.loader {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #e74c3c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transition: opacity 0.5s ease;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --- VNĚJŠÍ ZÁŘE (GLOW EFEKT) --- */
.with-shadow {
  filter: drop-shadow(0 var(--shadow-offset) var(--shadow-size) var(--shadow-color));
}

/* --- UŽIVATELSKÉ ROZHRANÍ (GUI) --- */
.settings-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: Arial, sans-serif;
}

/* Hlavní kulaté tlačítko pro otevření menu (ozubené kolo) */
.settings-btn {
  background: #e74c3c; 
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 26px; 
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: background 0.3s ease, transform 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  line-height: 1;
}

.settings-btn:hover {
  background: #c0392b; 
  transform: rotate(45deg); 
}

/* Skrytý vyjížděcí panel s funkcemi */
.settings-menu {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 230px; 
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: bottom right;
}

.settings-menu.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

/* --- PRVKY UVNITŘ MENU --- */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #333;
  font-weight: bold;
}

/* Tlačítka Zapnuto/Vypnuto */
.toggle-action-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  color: white;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  width: 75px; 
  transition: background 0.3s ease, transform 0.1s ease;
}

.toggle-action-btn:active {
  transform: scale(0.95);
}

.toggle-action-btn.on { background-color: #3498db; }
.toggle-action-btn.off { background-color: #e74c3c; }

/* Oddělovací čára v menu */
.menu-divider {
  border: 0;
  height: 1px;
  background: #e0e0e0;
  margin: 0;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #333;
  font-weight: bold;
}

/* --- MODERNÍ POSUVNÍKY (CUSTOM SLIDERS) --- */
/* Úprava výchozích HTML posuvníků pro čistší vzhled */
.setting-group input[type="range"] {
  -webkit-appearance: none; 
  appearance: none;
  width: 100%;
  height: 6px; 
  background: #e0e0e0;
  border-radius: 5px;
  outline: none;
  margin-top: 5px;
  margin-bottom: 5px;
}

/* Stylizace samotného "kolečka" (tlačítka) na posuvníku */
.setting-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e74c3c; 
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3); 
  transition: transform 0.1s ease, background 0.1s ease;
}

.setting-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2); 
  background: #c0392b;
}

/* --- VÝBĚR BARVY (COLOR PICKER) --- */
/* Moderní zakulacený design bez výchozích ošklivých rámečků prohlížeče */
.setting-group input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  background: transparent;
  margin-top: 4px;
}

.setting-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.setting-group input[type="color"]::-webkit-color-swatch {
  border: 2px solid #ecf0f1;
  border-radius: 8px;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.1);
}

/* --- NAVIGAČNÍ ŠIPKY --- */
.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(0, 0, 0, 0.5);
  border: none;
  width: 50px;
  height: 80px;
  font-size: 35px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}

body.dark-mode .nav-arrow {
  color: rgba(255, 255, 255, 0.7);
}

.nav-arrow:hover {
  background: rgba(231, 76, 60, 0.9);
  color: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.left-arrow {
  left: 15px;
}

.right-arrow {
  right: 15px;
}

/* --- PROGRESS BAR (NEONOVÁ ZÁŘE) --- */
.progress-container {
  position: fixed;
  bottom: 35px; /* Výškově ladí s nastavením vpravo */
  left: 50%;
  transform: translateX(-50%);
  width: 50%; /* Zabírá polovinu obrazovky ve středu */
  max-width: 600px;
  min-width: 200px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

body.dark-mode .progress-container {
  background: rgba(255, 255, 255, 0.1);
}

.progress-container.hidden {
  opacity: 0;
  pointer-events: none;
}

.progress-bar {
  height: 100%;
  width: 0%; /* Na začátku knihy je na nule */
  background: #e74c3c;
  border-radius: 4px;
  box-shadow: 0 0 10px #e74c3c, 0 0 20px #e74c3c; /* NEONOVÝ EFEKT */
  transition: width 0.4s ease; /* Plynulé posunutí při otočení stránky */
}