/* === CSS Variables === */
:root {
  --bg-color: #2F6F85;
  --bg-secondary: #245869;
  --accent-color: #ffffff;
  --text-color: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --transition: 0.3s ease;
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg-color);
  color: var(--text-color);
}

/* === Header === */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
  z-index: 100;
  pointer-events: none;
}

.header > * {
  pointer-events: auto;
}

.header-title {
  display: flex;
  flex-direction: column;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.header-title h1 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
}

.header-title span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* === Buttons === */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn svg {
  width: 22px;
  height: 22px;
}

.nav-btn svg {
  width: 24px;
  height: 24px;
}

/* === Main Container === */
.main-container {
  width: 100%;
  height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* === Sidebar (Thumbnails) === */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(20, 40, 50, 0.95);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease;
  z-index: 200;
}

.sidebar.open {
  width: 260px;
  box-shadow: 5px 0 20px rgba(0,0,0,0.3);
}

.sidebar-inner {
  padding: 16px;
  padding-top: 70px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.thumb-item {
  position: relative;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: var(--transition);
  background: #333;
}

.thumb-item.cover-thumb {
  aspect-ratio: 1/1.414;
}

.thumb-item:not(.cover-thumb) {
  aspect-ratio: 1.414/1;
  grid-column: span 2;
}

.thumb-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.thumb-item.active {
  box-shadow: 0 0 0 2px var(--accent-color);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-number {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-top-left-radius: 4px;
}

/* === Flipbook Container === */
.flipbook-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.flipbook-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  will-change: transform;
}

/* Zoom aktifken sayfa çevirmeyi blokla */
.flipbook-wrapper.zoomed {
  pointer-events: none; /* Flipbook kütüphanesinin event'lerini devre dışı bırak */
}

.flipbook-wrapper.zoomed * {
  pointer-events: none;
}

/* === Page Styling === */
.page {
  background-color: transparent; /* Beyaz boşluk olmasın */
  overflow: hidden;
  /* box-shadow kaldırıldı, resimlerin kendi gölgesi var */
}

/* Kapak Sayfası */
.cover-page .page-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center; /* Dikey ortala */
  justify-content: center;
}

.cover-page .page-content img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Kapağı sündürme, oranını koru */
  object-position: center;
}

/* Bölünmüş Sayfalar (Spread) */
.split-page .page-content {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.split-page .image-wrapper {
  width: 200%; /* Resim 2 kat genişlikte */
  height: 100%;
  position: absolute;
  top: 0;
}

.split-page.left .image-wrapper {
  left: 0; /* Sol yarıyı göster */
}

.split-page.right .image-wrapper {
  left: -100%; /* Sağ yarıyı göster (sola kaydır) */
}

.split-page img {
  width: 100%;
  height: 100%;
  object-fit: fill; /* Tam dolsun, crop olmasın */
  display: block;
}

/* === Navigation === */
.nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0.6;
}

.nav-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.5);
}

.nav-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.nav-prev {
  left: 15px;
}

.nav-next {
  right: 15px;
}

/* === Footer === */
.footer {
  position: fixed;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 25px;
  gap: 16px;
  z-index: 100;
}

.page-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.page-input {
  width: 40px;
  padding: 4px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  color: var(--text-color);
  text-align: center;
  font-size: 14px;
}

.page-input:focus {
  outline: none;
  border-color: white;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 12px;
}

/* === Loading Overlay === */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 20px;
  font-family: var(--font-heading);
  font-size: 1.1rem;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .header {
    padding: 10px 16px;
  }
  
  .header-title h1 {
    font-size: 1rem;
  }
  
  .header-title span {
    display: block;
    font-size: 0.7rem;
  }
  
  .sidebar.open {
    width: 100%;
  }
  
  .sidebar-inner {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .thumb-item:not(.cover-thumb) {
    grid-column: span 3;
  }
  
  .nav-btn {
    width: 40px;
    height: 40px;
  }
  
  .nav-prev { left: 10px; }
  .nav-next { right: 10px; }
  
  .footer {
    bottom: 10px;
    padding: 6px 14px;
    gap: 12px;
  }
  
  .zoom-controls {
    display: none;
  }
}

/* === Zoom Reset Button (Mobile) === */
.zoom-reset-btn {
  position: fixed;
  top: 70px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.zoom-reset-btn svg {
  width: 22px;
  height: 22px;
}

.zoom-reset-btn.visible {
  display: flex;
  animation: fadeInScale 0.2s ease;
}

.zoom-reset-btn:active {
  transform: scale(0.9);
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 480px) {
  .sidebar-inner {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .thumb-item:not(.cover-thumb) {
    grid-column: span 2;
  }
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
