/* ==========================================================================
   Angular Reader Design System - Càn Long Đại Tạng Kinh
   Standalone Volume Reader (Tập 001 - 168)
   Inspired by Angular.dev - Modern, Clean, Material Design, Zero-Clutter
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;

  /* Theme Colors */
  --bg-body: #0f172a;
  --bg-toolbar: #1e293b;
  --bg-surface: #1e293b;
  --bg-drawer: #0f172a;
  --border-subtle: #334155;
  --border-strong: #475569;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Angular Gradients */
  --angular-red: #e11d48;
  --angular-purple: #9333ea;
  --angular-blue: #4f46e5;
  --angular-gradient: linear-gradient(135deg, #e11d48 0%, #a855f7 50%, #4f46e5 100%);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-toolbar: #ffffff;
  --bg-surface: #ffffff;
  --bg-drawer: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #64748b;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* Header Navbar */
.reader-header {
  height: 52px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--angular-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1rem;
}

.brand-info h1 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Secondary Navigation Toolbar */
.reader-toolbar {
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 40;
  gap: 0.5rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-toolbar);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  filter: brightness(1.1);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.action-btn.btn-primary {
  background: var(--angular-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.25);
}

.action-btn.btn-icon-only {
  width: 36px;
  padding: 0;
}

.page-select-dropdown {
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-toolbar);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  max-width: 140px;
}

.page-stepper-container {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-toolbar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 0.5rem;
  height: 36px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.page-input-box {
  width: 48px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-body);
  color: var(--text-main);
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  outline: none;
}

/* Stage Area (Viewport + Margins + Drawer) */
.stage-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background-color: #12141a;
}

[data-theme="light"] .stage-container {
  background-color: #e2e8f0;
}

/* Sidebar Drawer */
.sidebar-drawer {
  width: 250px;
  background: var(--bg-drawer);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal);
  overflow: hidden;
  z-index: 30;
}

.sidebar-drawer.collapsed {
  width: 0;
  border-right: none;
}

.drawer-header {
  height: 44px;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.drawer-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.page-chip {
  padding: 0.5rem 0.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.page-chip:hover {
  filter: brightness(1.15);
  border-color: var(--border-strong);
}

.page-chip.active {
  background: var(--angular-gradient);
  color: white;
  border-color: transparent;
}

/* Reader Viewport */
.viewport-wrapper {
  flex: 1;
  display: flex;
  position: relative;
  overflow: auto;
  align-items: center;
  justify-content: center;
}

/* Margin Click Zones */
.margin-click-zone {
  flex: 1;
  min-width: 80px;
  height: 100%;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  z-index: 20;
  transition: background 0.2s ease;
}

.margin-click-zone.zone-left {
  justify-content: flex-end;
  padding-right: 1.5rem;
}

.margin-click-zone.zone-right {
  justify-content: flex-start;
  padding-left: 1.5rem;
}

.margin-click-zone:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .margin-click-zone:hover {
  background: rgba(0, 0, 0, 0.04);
}

.margin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  opacity: 0.65;
  transition: all 0.2s ease;
  pointer-events: none;
}

.margin-click-zone:hover .margin-pill {
  opacity: 1;
  transform: scale(1.05);
  background: var(--angular-gradient);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(225, 29, 72, 0.4);
}

/* Book Stage & Page Overlay */
.book-stage {
  position: relative;
  display: inline-block;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-sm);
  transform-origin: center top;
  transition: transform 0.2s ease;
  background: white;
}

.book-click-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 15;
  pointer-events: auto;
}

.book-click-half {
  flex: 1;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}

.book-click-half.half-left:hover {
  background: linear-gradient(90deg, rgba(225, 29, 72, 0.08) 0%, transparent 60%);
}

.book-click-half.half-right:hover {
  background: linear-gradient(-90deg, rgba(147, 51, 234, 0.08) 0%, transparent 60%);
}

.reader-iframe {
  width: 820px;
  height: 1160px;
  max-width: 100%;
  border: none;
  background: white;
  display: block;
}

/* Page Flip Toast */
.flip-toast {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.flip-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .brand-info span { display: none; }
  .reader-toolbar {
    overflow-x: auto;
    padding: 0.5rem;
  }
  .margin-click-zone { min-width: 45px; }
  .margin-pill span { display: none; }
  .sidebar-drawer { width: 180px; }
  .drawer-grid { grid-template-columns: repeat(2, 1fr); }
}
