/* styles.css */
/* Global reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  padding-bottom: 3rem;
}

.hero {
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  padding: 2rem 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  max-width: 900px;
  width: 100%;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-sizing: border-box;
}

/* Warning Banner */
.warning-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #fff3cd;
  color: #856404;
  border-top: 1px solid #ffeeba;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 2000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.logo {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.search-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  width: 100%;
}

#query {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  background: white;
  border: 2px solid #bdc3c7;
  border-radius: 0.5rem;
  resize: vertical;
  font-family: inherit;
  color: #333;
  min-height: 200px;
  max-height: 400px;
}

.options-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.source-select,
.hadith-collection-select {
  flex: 1;
  padding: 0.65rem;
  font-size: 0.9rem;
  border: 2px solid #bdc3c7;
  border-radius: 0.5rem;
  background-color: white;
  color: #333;
  font-family: inherit;
}

.control-buttons-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.main-action-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  text-transform: uppercase;
}

.main-action-btn:hover {
  background-color: #2980b9;
}

.secondary-btn {
  flex: 1;
  padding: 0.65rem;
  background-color: transparent;
  border: 1px solid #bdc3c7;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #555;
  transition: all 0.2s;
  font-family: inherit;
}

.secondary-btn:hover {
  background-color: rgba(0,0,0,0.05);
  border-color: #999;
}

/* Settings Panel Generic Styles */
.settings-panel {
  text-align: left;
  width: 100%;
}

.settings-panel label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  margin-top: 1rem;
  color: #333;
}

.settings-panel select,
.settings-panel input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #bdc3c7;
  border-radius: 0.5rem;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  background: white;
  color: #333;
}

.model-info {
  display: block;
  font-size: 0.85rem;
  color: #000;
  margin-bottom: 1rem;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.modal-content {
  background-color: white;
  padding: 2rem;
  border-radius: 1rem;
  width: 90%;
  max-width: 400px;
  position: relative;
  text-align: center;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.5rem;
  cursor: pointer;
}

.credits-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.credit-link {
  display: block;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  text-decoration: none;
  color: #333;
}

/* Settings Page Specifics */
.settings-buttons-container {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.settings-buttons-container button {
  background: transparent;
  border: 1px solid #3498db;
  color: #3498db;
  padding: 0.8rem 1.5rem;
  border-radius: 0.5rem;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  width: 100%;
}

.settings-buttons-container button:hover {
  background: #3498db;
  color: white;
}

/* Result Output Styling */
.result {
  margin-top: 2rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 0.75rem;
  text-align: left;
}

.answer {
  color: #333;
  line-height: 1.8;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.answer h3 {
  color: #2c3e50;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.answer p {
  margin-bottom: 1rem;
}

.citations {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid rgba(0, 0, 0, 0.1);
}

.citations h3 {
  color: #2c3e50;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.citations a {
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
}

.citations a:hover {
  text-decoration: underline;
}

/* ========================================= */
/* THEME OVERRIDES */
/* ========================================= */

/* 0. Modern Blue Theme (Explicit) */
html[data-theme='modern'] body {
  background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
  font-family: 'Inter', sans-serif;
  color: #333;
}

html[data-theme='modern'] .hero {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

html[data-theme='modern'] h1 {
  color: #2c3e50;
  font-family: 'Inter', sans-serif;
}

html[data-theme='modern'] #query {
  background: white;
  border: 2px solid #bdc3c7;
  color: #333;
}

html[data-theme='modern'] .source-select,
html[data-theme='modern'] .hadith-collection-select,
html[data-theme='modern'] .settings-panel select,
html[data-theme='modern'] .settings-panel input {
  background: white;
  border: 2px solid #bdc3c7;
  color: #333;
}

html[data-theme='modern'] .main-action-btn {
  background-color: #3498db;
  color: white;
  border-radius: 0.5rem;
  font-family: 'Inter', sans-serif;
}

html[data-theme='modern'] .main-action-btn:hover {
  background-color: #2980b9;
  box-shadow: none;
}

html[data-theme='modern'] .secondary-btn {
  border: 1px solid #bdc3c7;
  color: #555;
}

html[data-theme='modern'] .secondary-btn:hover {
  background-color: rgba(0,0,0,0.05);
  border-color: #999;
}

html[data-theme='modern'] .settings-buttons-container button {
  border: 1px solid #3498db;
  color: #3498db;
  font-family: 'Inter', sans-serif;
}

html[data-theme='modern'] .settings-buttons-container button:hover {
  background: #3498db;
  color: white;
}

html[data-theme='modern'] .warning-banner {
  background-color: #fff3cd;
  color: #856404;
  border-color: #ffeeba;
}

html[data-theme='modern'] label {
  color: #333;
  font-family: 'Inter', sans-serif;
}

/* 1. Traditional Islamic Theme (Light Beige/Gold) */
html[data-theme='traditional'] body {
  background: linear-gradient(135deg, #f5f0e8, #e8dcc8);
  font-family: 'Georgia', serif;
  color: #3e2723;
}

html[data-theme='traditional'] .hero {
  background: rgba(245, 240, 232, 0.95);
  border: 2px solid #c9a961;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

html[data-theme='traditional'] h1 {
  color: #3e2723;
  font-family: 'Georgia', serif;
}

html[data-theme='traditional'] #query {
  background: #faf7f2;
  border: 1px solid #c9a961;
  color: #3e2723;
}

html[data-theme='traditional'] .source-select,
html[data-theme='traditional'] .hadith-collection-select,
html[data-theme='traditional'] .settings-panel select,
html[data-theme='traditional'] .settings-panel input {
  background-color: #e8dcc8;
  border: 1px solid #c9a961;
  color: #3e2723;
}

html[data-theme='traditional'] .main-action-btn {
  background: linear-gradient(135deg, #2d7d7d, #1f5f5f);
  color: #ffd700;
  border-radius: 2rem;
  font-family: 'Georgia', serif;
  letter-spacing: 1px;
}

html[data-theme='traditional'] .main-action-btn:hover {
  background: linear-gradient(135deg, #1f5f5f, #154a4a);
  box-shadow: 0 4px 12px rgba(45, 125, 125, 0.4);
}

html[data-theme='traditional'] .secondary-btn {
  border: 1px solid #c9a961;
  color: #3e2723;
  background-color: #faf7f2;
}

html[data-theme='traditional'] .secondary-btn:hover {
  background-color: #e8dcc8;
}

html[data-theme='traditional'] .settings-buttons-container button {
  border: 1px solid #c9a961;
  color: #c9a961;
  font-family: 'Georgia', serif;
  background: transparent;
}

html[data-theme='traditional'] .settings-buttons-container button:hover {
  background: rgba(201, 169, 97, 0.1);
  box-shadow: 0 0 10px rgba(201, 169, 97, 0.2);
}

html[data-theme='traditional'] .warning-banner {
  background-color: #fff8e1;
  color: #5d4037;
  border-color: #c9a961;
}

html[data-theme='traditional'] label {
  color: #3e2723;
  font-family: 'Georgia', serif;
  font-weight: 600;
}

html[data-theme='traditional'] .model-info {
  color: #8d7b68;
}

html[data-theme='traditional'] .result {
  background: rgba(245, 240, 232, 0.95);
  border: 1px solid #c9a961;
}

html[data-theme='traditional'] .answer {
  color: #3e2723;
  font-family: 'Georgia', serif;
}

html[data-theme='traditional'] .answer h3 {
  color: #2d1f1a;
  font-family: 'Georgia', serif;
}

html[data-theme='traditional'] .citations {
  border-top-color: rgba(201, 169, 97, 0.3);
}

html[data-theme='traditional'] .citations h3 {
  color: #2d1f1a;
  font-family: 'Georgia', serif;
}

html[data-theme='traditional'] .citations a {
  color: #1a5f5f;
  font-weight: 600;
}

html[data-theme='traditional'] .citations a:hover {
  color: #154a4a;
}

/* 2. Minimal White Theme */
html[data-theme='minimal'] body {
  background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #333;
}

html[data-theme='minimal'] .hero {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme='minimal'] h1 {
  color: #000;
  font-weight: 300;
}

html[data-theme='minimal'] #query,
html[data-theme='minimal'] .source-select,
html[data-theme='minimal'] .hadith-collection-select,
html[data-theme='minimal'] .settings-panel select,
html[data-theme='minimal'] .settings-panel input {
  background: #fafafa;
  border-color: #ddd;
  color: #333;
}

html[data-theme='minimal'] .main-action-btn {
  background: #333;
  color: #fff;
  border-radius: 0.5rem;
}

html[data-theme='minimal'] .main-action-btn:hover {
  background: #000;
}

html[data-theme='minimal'] .secondary-btn {
  border: 1px solid #ccc;
  color: #555;
}

html[data-theme='minimal'] .secondary-btn:hover {
  background: #f0f0f0;
  color: #000;
}

html[data-theme='minimal'] .settings-buttons-container button {
  border: 1px solid #333;
  color: #333;
}

html[data-theme='minimal'] .settings-buttons-container button:hover {
  background: #333;
  color: white;
}

html[data-theme='minimal'] .warning-banner {
  background-color: #fafafa;
  color: #333;
  border: 1px solid #333;
}

/* 3. Dark Theme (Standard) */
html[data-theme='dark'] body {
  background: #121212;
  color: #e0e0e0;
}

html[data-theme='dark'] .hero {
  background: #1e1e1e;
  border: 1px solid #333;
}

html[data-theme='dark'] h1 {
  color: #fff;
}

html[data-theme='dark'] #query,
html[data-theme='dark'] .source-select,
html[data-theme='dark'] .hadith-collection-select,
html[data-theme='dark'] .settings-panel select,
html[data-theme='dark'] .settings-panel input {
  background: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

html[data-theme='dark'] .main-action-btn {
  background: #3498db;
  color: white;
}

html[data-theme='dark'] .secondary-btn {
  border-color: #555;
  color: #aaa;
}

html[data-theme='dark'] .secondary-btn:hover {
  background: #333;
  color: #fff;
}

html[data-theme='dark'] .settings-buttons-container button {
  border-color: #81d4fa;
  color: #81d4fa;
}

html[data-theme='dark'] .settings-buttons-container button:hover {
  background: #81d4fa;
  color: #121212;
}

html[data-theme='dark'] label {
  color: #e0e0e0;
}

html[data-theme='dark'] .model-info {
  color: #fff;
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #bdc3c7;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.3s;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

html[data-theme='dark'] .dark-mode-toggle,
html[data-theme='traditional'] .dark-mode-toggle {
  background: rgba(0, 0, 0, 0.9);
  border-color: #555;
}

.dark-mode-toggle .sun-icon,
.dark-mode-toggle .moon-icon {
  position: absolute;
  transition: opacity 0.3s;
}

html[data-theme='light'] .dark-mode-toggle .sun-icon,
html[data-theme='modern'] .dark-mode-toggle .sun-icon,
html[data-theme='minimal'] .dark-mode-toggle .sun-icon {
  opacity: 1;
}

html[data-theme='light'] .dark-mode-toggle .moon-icon,
html[data-theme='modern'] .dark-mode-toggle .moon-icon,
html[data-theme='minimal'] .dark-mode-toggle .moon-icon {
  opacity: 0;
}

html[data-theme='dark'] .dark-mode-toggle .sun-icon,
html[data-theme='traditional'] .dark-mode-toggle .sun-icon {
  opacity: 0;
}

html[data-theme='dark'] .dark-mode-toggle .moon-icon,
html[data-theme='traditional'] .dark-mode-toggle .moon-icon {
  opacity: 1;
}

/* Password Input Wrapper */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.password-input-wrapper input {
  flex: 1;
  width: 100%;
  padding-right: 3rem !important;
}

.eye-icon {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.eye-icon:hover {
  opacity: 0.7;
}

.eye-icon .eye-open,
.eye-icon .eye-closed {
  position: absolute;
}

/* ========================================= */
/* RESPONSIVE DESIGN - MOBILE FIRST */
/* ========================================= */

/* Mobile devices (up to 480px) */
@media screen and (max-width: 480px) {
  body {
    padding: 1rem 0.5rem 3.5rem;
  }

  .hero {
    max-width: 100%;
    padding: 1.5rem 1rem;
    border-radius: 0.75rem;
    margin: 0 0.5rem;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .logo {
    width: 60px;
    height: 60px;
  }

  /* Textarea optimization for mobile */
  #query {
    min-height: 150px;
    max-height: 300px;
    font-size: 1rem;
    padding: 0.75rem;
  }

  /* Stack options vertically on mobile */
  .options-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .source-select,
  .hadith-collection-select {
    width: 100%;
    font-size: 0.9rem;
  }

  /* Stack control buttons vertically */
  .control-buttons-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .secondary-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .main-action-btn {
    padding: 1rem;
    font-size: 0.95rem;
  }

  /* Settings panel adjustments */
  .settings-panel select,
  .settings-panel input {
    font-size: 0.95rem;
    padding: 0.65rem;
  }

  /* Stack settings buttons vertically */
  .settings-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .settings-buttons-container button {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95%;
    padding: 1.5rem;
    border-radius: 0.75rem;
  }

  .close-modal {
    font-size: 1.25rem;
  }

  /* Dark mode toggle - smaller on mobile */
  .dark-mode-toggle {
    width: 45px;
    height: 45px;
    font-size: 1.25rem;
    top: 0.75rem;
    right: 0.75rem;
  }

  /* Warning banner */
  .warning-banner {
    font-size: 0.8rem;
    padding: 0.5rem;
  }

  /* Result output */
  .result {
    padding: 1rem;
    margin-top: 1.5rem;
  }

  .answer {
    font-size: 0.95rem;
  }

  .answer h3,
  .citations h3 {
    font-size: 1rem;
  }

  /* Model info */
  .model-info {
    font-size: 0.75rem;
  }

  /* Password input */
  .eye-icon {
    font-size: 1rem;
  }
}

/* Tablets - Portrait (481px to 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  body {
    padding: 1.5rem 1rem 3.5rem;
  }

  .hero {
    max-width: 95%;
    padding: 1.75rem 1.25rem;
    margin: 0 auto;
  }

  h1 {
    font-size: 1.75rem;
  }

  .logo {
    width: 70px;
    height: 70px;
  }

  #query {
    min-height: 180px;
    max-height: 350px;
    font-size: 1.25rem;
  }

  /* Buttons remain side by side but with better spacing */
  .control-buttons-row {
    gap: 0.5rem;
  }

  .secondary-btn {
    font-size: 0.85rem;
    padding: 0.6rem;
  }

  .main-action-btn {
    padding: 0.9rem;
    font-size: 0.95rem;
  }

  /* Settings buttons in 2x2 grid */
  .settings-row {
    gap: 0.85rem;
  }

  .settings-buttons-container button {
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  .dark-mode-toggle {
    width: 48px;
    height: 48px;
  }

  .modal-content {
    width: 85%;
  }
}

/* Tablets - Landscape & Small Desktops (769px to 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .hero {
    max-width: 750px;
  }

  #query {
    font-size: 1.35rem;
  }

  .settings-buttons-container button {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
  }
}

/* Large Desktops (1025px and above) */
@media screen and (min-width: 1025px) {
  .hero {
    max-width: 900px;
  }

  #query {
    font-size: 1.5rem;
  }
}

/* Landscape orientation adjustments for mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
  body {
    padding-bottom: 2.5rem;
  }

  .hero {
    padding: 1rem;
    margin: 0.5rem;
  }

  h1 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .logo {
    width: 50px;
    height: 50px;
    margin-bottom: 0.5rem;
  }

  #query {
    min-height: 100px;
    max-height: 200px;
  }

  .dark-mode-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .warning-banner {
    padding: 0.4rem;
    font-size: 0.75rem;
  }
}

/* Print styles */
@media print {
  .dark-mode-toggle,
  .warning-banner,
  .control-buttons-row,
  .settings-buttons-container {
    display: none !important;
  }

  .hero {
    box-shadow: none;
    border: 1px solid #000;
  }

  body {
    background: white;
  }
}

/* High DPI / Retina displays */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi) {
  .hero {
    backdrop-filter: blur(15px);
  }

  .logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .dark-mode-toggle:hover {
    transform: none;
  }

  .main-action-btn:hover {
    transform: none;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets for better mobile UX */
  button,
  .secondary-btn,
  .main-action-btn,
  select,
  input {
    min-height: 44px;
  }

  .settings-buttons-container button {
    min-height: 48px;
  }

  .dark-mode-toggle {
    min-width: 48px;
    min-height: 48px;
  }

  /* Remove hover effects on touch devices */
  .main-action-btn:hover,
  .secondary-btn:hover,
  .settings-buttons-container button:hover {
    transform: none;
  }
}

