/* =========================================================
   Sadbhavana Awaj ePaper — Frontend Styles
   Inspired by Aaj Tak ePaper layout
   ========================================================= */

:root {
  --saep-primary: #c0392b;
  --saep-accent: #e74c3c;
  --saep-dark: #1a1a1a;
  --saep-light: #f8f8f8;
  --saep-border: #ddd;
  --saep-radius: 8px;
  --saep-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* Wrapper */
.saep-wrapper {
  font-family: 'Noto Sans Devanagari', 'Hind', Arial, sans-serif;
  max-width: 1100px;
  margin: 0 auto 40px;
  background: #fff;
  border-radius: var(--saep-radius);
  box-shadow: var(--saep-shadow);
  overflow: hidden;
  border: 1px solid var(--saep-border);
}

/* ── Header ─────────────────────────────────── */
.saep-header {
  background: linear-gradient(135deg, var(--saep-primary) 0%, var(--saep-accent) 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saep-logo { height: 48px; object-fit: contain; filter: brightness(0) invert(1); }

.saep-title-text { display: flex; flex-direction: column; }
.saep-name { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.5px; }
.saep-tagline { font-size: 0.8rem; opacity: .85; }

.saep-edition-date {
  font-size: 0.85rem;
  background: rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Toolbar ─────────────────────────────────── */
.saep-toolbar {
  background: var(--saep-dark);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.saep-nav-group, .saep-tools-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.saep-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.saep-btn:hover { background: var(--saep-accent); border-color: var(--saep-accent); }

.saep-page-counter {
  color: #eee;
  font-size: 0.85rem;
  padding: 0 8px;
  white-space: nowrap;
}
.saep-page-counter span { color: #fff; font-weight: 700; }

/* ── Section Tabs ─────────────────────────────── */
.saep-sections-bar {
  background: #f0f0f0;
  border-bottom: 2px solid var(--saep-primary);
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 0;
}

.saep-section-tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all .2s;
  font-family: inherit;
}
.saep-section-tab:hover  { background: #e8e8e8; color: var(--saep-primary); }
.saep-section-tab.active { color: var(--saep-primary); border-bottom-color: var(--saep-primary); background: #fff; }

/* ── Viewer Area ─────────────────────────────── */
.saep-viewer-area {
  position: relative;
  background: #2a2a2a;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.saep-page-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  user-select: none;
}

.saep-page-slide {
  display: none;
  position: relative;
  max-width: 780px;
  width: 100%;
  animation: saepFadeIn 0.3s ease;
}
.saep-page-slide.active { display: block; }

@keyframes saepFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.saep-page-inner {
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.saep-page-img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center center;
  transition: transform 0.3s ease;
  max-height: 80vh;
  object-fit: contain;
}

/* Watermark */
.saep-watermark {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.7rem;
  color: rgba(150,0,0,0.25);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
}

.saep-page-label {
  position: absolute;
  top: 10px;
  left: 12px;
  background: var(--saep-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 3px;
}
.saep-page-label:empty { display: none; }

/* Click zones */
.saep-click-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 80px;
  cursor: pointer;
  z-index: 10;
}
.saep-click-left  { left: 0; }
.saep-click-right { right: 0; }
.saep-click-left:hover  { background: linear-gradient(to right, rgba(0,0,0,0.25), transparent); }
.saep-click-right:hover { background: linear-gradient(to left,  rgba(0,0,0,0.25), transparent); }

/* Swipe hint */
.saep-swipe-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: #eee;
  font-size: 0.75rem;
  padding: 4px 14px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s;
}
.saep-swipe-hint.hidden { opacity: 0; }

/* ── Thumbnail Strip ─────────────────────────── */
.saep-thumb-strip {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 12px 16px;
  background: #1a1a1a;
  scrollbar-width: thin;
  scrollbar-color: var(--saep-accent) #333;
}

.saep-thumb {
  flex-shrink: 0;
  width: 60px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity .2s, transform .2s;
  text-align: center;
  position: relative;
}
.saep-thumb:hover, .saep-thumb.active { opacity: 1; transform: scale(1.05); }
.saep-thumb.active::after {
  content: '';
  display: block;
  height: 3px;
  background: var(--saep-accent);
  border-radius: 2px;
  margin-top: 3px;
}

.saep-thumb img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 3px;
  border: 2px solid transparent;
  display: block;
}
.saep-thumb.active img { border-color: var(--saep-accent); }

.saep-thumb span {
  color: #aaa;
  font-size: 0.65rem;
  display: block;
  margin-top: 3px;
}

/* ── Share Modal ─────────────────────────────── */
.saep-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 99999;
  align-items: center;
  justify-content: center;
}
.saep-modal.open { display: flex; }

.saep-modal-inner {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  min-width: 280px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: saepFadeIn .25s ease;
}
.saep-modal-inner h3 { margin: 0 0 20px; color: var(--saep-dark); }

.saep-share-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.saep-share-btns a, .saep-share-copy {
  display: block;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity .2s;
  border: none;
  font-family: inherit;
}
.saep-share-btns a:hover, .saep-share-copy:hover { opacity: .85; }
.saep-share-fb   { background: #1877F2; color: #fff; }
.saep-share-tw   { background: #000; color: #fff; }
.saep-share-wa   { background: #25D366; color: #fff; }
.saep-share-copy { background: #f0f0f0; color: #333; }

.saep-modal-close {
  background: transparent;
  border: 1px solid #ddd;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  color: #666;
}

/* ── Archive ─────────────────────────────────── */
.saep-archive { max-width: 1100px; margin: 0 auto; padding: 20px 0; }
.saep-archive-title {
  font-size: 1.4rem;
  color: var(--saep-primary);
  border-bottom: 3px solid var(--saep-primary);
  padding-bottom: 10px;
  margin-bottom: 24px;
}

.saep-archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.saep-archive-card {
  border-radius: var(--saep-radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  transition: transform .2s, box-shadow .2s;
}
.saep-archive-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }

.saep-archive-link { text-decoration: none; color: inherit; display: block; }

.saep-archive-cover {
  width: 100%;
  height: 210px;
  object-fit: cover;
  display: block;
}

.saep-archive-nocover {
  width: 100%;
  height: 210px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.saep-archive-info {
  padding: 10px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saep-archive-date  { font-size: 0.72rem; color: #888; }
.saep-archive-name  { font-size: 0.82rem; font-weight: 700; color: var(--saep-dark); line-height: 1.3; }
.saep-archive-pages { font-size: 0.7rem; color: var(--saep-primary); }

/* No edition */
.saep-no-edition {
  text-align: center;
  padding: 40px;
  color: #888;
  font-size: 1rem;
}

/* ── Fullscreen ──────────────────────────────── */
.saep-wrapper.fullscreen {
  position: fixed !important;
  inset: 0 !important;
  max-width: 100% !important;
  border-radius: 0 !important;
  z-index: 99990 !important;
  overflow-y: auto;
  margin: 0 !important;
}
.saep-wrapper.fullscreen .saep-viewer-area { min-height: calc(100vh - 200px); }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  .saep-toolbar { flex-direction: column; align-items: flex-start; }
  .saep-name { font-size: 1.2rem; }
  .saep-page-container { padding: 10px; }
  .saep-archive-grid { grid-template-columns: repeat(2, 1fr); }
  .saep-thumb { width: 50px; }
  .saep-thumb img { width: 50px; height: 66px; }
  .saep-click-zone { width: 50px; }
}
