/* ═══════════════════════════════════════════════════
   RAMAYAN — Sacred Knowledge Portal
   Design System & Styles
═══════════════════════════════════════════════════ */

/* ---------- CSS Variables ---------- */
:root {
  --crimson-deep:   #0f0101;
  --crimson-dark:   #1a0505;
  --crimson-mid:    #2c0d0d;
  --crimson-light:  #3d1515;
  --gold-bright:    #f5b700;
  --gold-mid:       #d4940a;
  --gold-dim:       #9c6b07;
  --saffron:        #ff6b1a;
  --saffron-dim:    #c44d0e;
  --cream:          #fdf3dc;
  --cream-dim:      #e8d5a3;
  --white:          #ffffff;
  --text-primary:   #fdf3dc;
  --text-secondary: #c8a96e;
  --text-muted:     #7a5c3a;
  --accent-glow:    rgba(245, 183, 0, 0.3);
  --sidebar-width:  300px;
  --border-radius:  14px;
  --border-color:   rgba(245, 183, 0, 0.15);
  --glass-bg:       rgba(44, 13, 13, 0.7);
  --glass-border:   rgba(245, 183, 0, 0.2);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--crimson-deep);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sacred background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(255, 107, 26, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(245, 183, 0, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(26, 5, 5, 0.9) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════
   LOADING SCREEN
═══════════════════════════════════ */
.loading-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #2c0d0d 0%, #0f0101 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
}

.loading-inner {
  text-align: center;
  animation: fadeInUp 0.8s ease forwards;
}

.loading-logo {
  width: 140px;
  height: 140px;
  margin: 0 auto 24px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--gold-bright);
  box-shadow: 0 0 40px rgba(245, 183, 0, 0.4), 0 0 80px rgba(255, 107, 26, 0.2);
  animation: glow-pulse 2s ease-in-out infinite;
}

.loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loading-om-fallback {
  width: 100%;
  height: 100%;
  font-size: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--crimson-mid);
}

.loading-title {
  font-family: 'Cinzel', serif;
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.3em;
  text-shadow: 0 0 20px rgba(245, 183, 0, 0.6);
  margin-bottom: 8px;
}

.loading-subtitle {
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.loading-bar-wrap {
  width: 220px;
  height: 4px;
  background: rgba(245, 183, 0, 0.15);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-bright), var(--saffron));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(245, 183, 0, 0.6);
}

/* ═══════════════════════════════════
   MAIN APP LAYOUT
═══════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════
   SIDEBAR
═══════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--crimson-mid) 0%, var(--crimson-dark) 100%);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 50% 0%, rgba(245, 183, 0, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

/* Logo / Brand */
.sidebar-header {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.logo-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 16px rgba(245, 183, 0, 0.35);
  flex-shrink: 0;
  animation: glow-pulse 3s ease-in-out infinite;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fallback-om {
  font-size: 32px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--crimson-mid);
}

.brand-name {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px rgba(245, 183, 0, 0.4);
  line-height: 1.1;
}

.brand-tagline {
  font-size: 0.68rem;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Divider */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 183, 0, 0.25), transparent);
  margin: 4px 16px;
  flex-shrink: 0;
}

/* Section Labels */
.section-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Upload Section */
.upload-section {
  padding: 16px 18px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--gold-bright);
  background: rgba(245, 183, 0, 0.06);
  box-shadow: 0 0 20px rgba(245, 183, 0, 0.1);
  transform: translateY(-1px);
}

.drop-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

.drop-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drop-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* PDF Status */
.pdf-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(245, 183, 0, 0.07);
  border: 1px solid rgba(245, 183, 0, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}

.status-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.pdf-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.pdf-pages {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Progress Bar */
.pdf-progress {
  margin-top: 12px;
  text-align: center;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.progress-bar-wrap {
  width: 100%;
  height: 5px;
  background: rgba(245, 183, 0, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-bright), var(--saffron));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(245, 183, 0, 0.5);
}

.progress-pct {
  font-size: 0.72rem;
  color: var(--gold-bright);
  font-weight: 600;
}

/* How It Works */
.info-section {
  padding: 16px 18px;
}

.how-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.how-list li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.how-num {
  background: linear-gradient(135deg, var(--gold-bright), var(--saffron));
  color: #1a0505;
  font-weight: 700;
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 18px 24px;
  margin-top: auto;
}

.footer-verse {
  font-family: 'Noto Serif Devanagari', serif;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
  text-align: center;
  margin-bottom: 4px;
}

.footer-verse-en {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
}

.clear-btn {
  width: 100%;
  padding: 9px 16px;
  background: transparent;
  border: 1px solid rgba(245, 183, 0, 0.2);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.clear-btn:hover {
  background: rgba(212, 148, 10, 0.1);
  border-color: var(--gold-dim);
  color: var(--gold-bright);
}

/* ═══════════════════════════════════
   CHAT AREA
═══════════════════════════════════ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--crimson-dark) 0%, var(--crimson-deep) 100%);
  position: relative;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 1, 1, 0.5);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  z-index: 5;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-avatar {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, var(--crimson-mid), var(--crimson-dark));
  border: 2px solid var(--gold-bright);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(245, 183, 0, 0.25);
  animation: glow-pulse 4s ease-in-out infinite;
}

.chat-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.chat-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 14px;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.badge-dot.active {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
  animation: blink 1.5s ease-in-out infinite;
}

#badge-text {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(245, 183, 0, 0.2);
  border-radius: 3px;
}

/* Messages */
.message {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: messageIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.message.user-message {
  flex-direction: row-reverse;
}

.message-avatar {
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  background: var(--crimson-mid);
  border: 2px solid var(--gold-bright);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(245, 183, 0, 0.2);
}

.user-message .message-avatar {
  background: linear-gradient(135deg, #1a3a6b, #0d1f40);
  border-color: #4a90d9;
  box-shadow: 0 0 10px rgba(74, 144, 217, 0.2);
}

.message-bubble {
  max-width: 680px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 14px 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.user-message .message-bubble {
  background: rgba(26, 58, 107, 0.4);
  border-color: rgba(74, 144, 217, 0.2);
}

.message-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-sender {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gold-bright);
  letter-spacing: 0.08em;
}

.user-message .message-sender {
  color: #6aadff;
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.message-text {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.message-text p + p {
  margin-top: 8px;
}

.message-text strong {
  color: var(--gold-bright);
}

.message-text em {
  color: var(--cream-dim);
  font-style: italic;
}

.message-text ul {
  margin-top: 8px;
  padding-left: 20px;
  list-style: none;
}

.message-text ul li {
  margin-bottom: 5px;
  position: relative;
  padding-left: 16px;
}

.message-text ul li::before {
  content: '🔸';
  position: absolute;
  left: -4px;
  font-size: 0.65rem;
  top: 2px;
}

/* Welcome list */
.welcome-list {
  margin-top: 8px !important;
}

/* Results */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.result-card {
  background: rgba(245, 183, 0, 0.04);
  border: 1px solid rgba(245, 183, 0, 0.15);
  border-radius: 10px;
  padding: 14px 16px;
  transition: all 0.2s ease;
}

.result-card:hover {
  border-color: rgba(245, 183, 0, 0.3);
  background: rgba(245, 183, 0, 0.07);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.result-rank {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  color: var(--saffron);
  font-weight: 600;
  letter-spacing: 0.1em;
}

.result-page {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.result-score {
  font-size: 0.65rem;
  color: var(--gold-dim);
}

.result-snippet {
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--cream-dim);
}

.result-snippet mark {
  background: rgba(245, 183, 0, 0.25);
  color: var(--gold-bright);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}

.no-results {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* Thinking indicator */
.thinking-bubble {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.thinking-dots {
  display: flex;
  gap: 5px;
  padding: 16px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-bright);
  animation: bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Input Area */
.input-area {
  padding: 16px 28px 22px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 1, 1, 0.4);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
}

.question-input {
  flex: 1;
  background: rgba(44, 13, 13, 0.6);
  border: 1.5px solid rgba(245, 183, 0, 0.2);
  border-radius: 50px;
  padding: 13px 22px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  outline: none;
  transition: all 0.25s ease;
  caret-color: var(--gold-bright);
}

.question-input::placeholder {
  color: var(--text-muted);
}

.question-input:focus {
  border-color: var(--gold-bright);
  background: rgba(44, 13, 13, 0.8);
  box-shadow: 0 0 16px rgba(245, 183, 0, 0.12);
}

.question-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gold-bright), var(--saffron));
  color: #1a0505;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(245, 183, 0, 0.3);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 24px rgba(245, 183, 0, 0.45);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.03em;
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 100;
  background: var(--gold-bright);
  color: #1a0505;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* ═══════════════════════════════════
   UTILITIES
═══════════════════════════════════ */
.hidden {
  display: none !important;
}

/* ═══════════════════════════════════
   ANIMATIONS
═══════════════════════════════════ */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(245, 183, 0, 0.25); }
  50% { box-shadow: 0 0 28px rgba(245, 183, 0, 0.5), 0 0 50px rgba(255, 107, 26, 0.15); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-6px); opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════
   RESPONSIVE
═══════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-width: 280px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-header {
    padding: 14px 16px 14px 60px;
  }

  .messages-container {
    padding: 16px 14px;
  }

  .input-area {
    padding: 12px 14px 16px;
  }

  .message-bubble {
    max-width: calc(100vw - 80px);
  }

  .header-badge {
    display: none;
  }
}
