/* ==========================================================================
   LOVEHADITH - MODERN ISLAMIC DESIGN SYSTEM
   Inspired by premium Quran applications
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Prompt:wght@300;400;500;600;700&family=Scheherazade+New:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Color Palette - Light Mode */
  --primary: #065f46;          /* Deep Islamic Emerald */
  --primary-hover: #047857;
  --primary-light: #ecfdf5;
  --primary-glow: rgba(6, 95, 70, 0.2);
  
  --secondary: #b45309;        /* Warm Gold / Bronze */
  --secondary-light: #fef3c7;
  
  --accent: #0284c7;           /* Sky Blue */
  --accent-light: #e0f2fe;

  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-arabic: #1e293b;

  --border-color: #e2e8f0;
  --border-focus: #059669;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-gold: 0 4px 15px rgba(180, 83, 9, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Typography */
  --font-thai: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-arabic: 'Amiri', 'Scheherazade New', serif;
  --font-ui: 'Inter', var(--font-thai);

  --arabic-size: 1.65rem;
}

[data-theme="dark"] {
  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-light: rgba(16, 185, 129, 0.15);
  --primary-glow: rgba(16, 185, 129, 0.3);

  --secondary: #f59e0b;
  --secondary-light: rgba(245, 158, 11, 0.15);

  --bg-page: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #243248;
  --bg-subtle: #182234;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-arabic: #f1f5f9;

  --border-color: #334155;
  --border-focus: #10b981;

  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* Reset & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-thai);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header & Navigation Bar */
.modern-nav {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%);
  color: #ffffff;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 2px solid rgba(217, 119, 6, 0.4);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: #ffffff;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: #ffffff;
}

.brand-logo:hover {
  color: #ffffff;
  text-decoration: none;
}

.logo-badge {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  color: #ffffff;
  font-size: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.25rem;
  letter-spacing: -0.5px;
  line-height: 1.2;
  font-weight: 700;
  color: #ffffff;
}

.brand-tagline {
  font-size: 0.75rem;
  color: #fbbf24;
  font-weight: 400;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
  background: #ffffff;
  padding: 2px;
}

.brand-title-group h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-arabic-title {
  font-family: var(--font-arabic);
  font-size: 1.4rem;
  color: #fbbf24;
  font-weight: 700;
  margin-left: 0.3rem;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #d1fae5;
  margin: 0;
  font-weight: 300;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-link-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  transform: translateY(-1px);
}

.theme-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fbbf24;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(15deg);
}

/* Hero & Search Section */
.hero-banner {
  background: linear-gradient(180deg, rgba(6, 78, 59, 0.9) 0%, rgba(6, 95, 70, 0.75) 100%),
              url('../img/best-books-of-hadith6.jpg') center/cover no-repeat;
  padding: 3rem 1.5rem 3.5rem;
  color: #ffffff;
  text-align: center;
  position: relative;
}

.hero-content {
  max-width: 900px;
  margin: 0 auto;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(251, 191, 36, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.hero-content h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hero-arabic-verse {
  font-family: var(--font-arabic);
  font-size: 1.8rem;
  color: #fef08a;
  margin-bottom: 1.5rem;
  direction: rtl;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Search Box Container */
.search-card-wrapper {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-align: left;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.5rem 1rem;
  transition: all 0.25s ease;
}

.search-input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
  background: var(--bg-surface);
}

.search-icon {
  color: var(--primary);
  font-size: 1.25rem;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.5rem 0.25rem;
  font-size: 1.05rem;
  font-family: var(--font-thai);
  color: var(--text-main);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.search-action-btns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.arabic-toggle-btn {
  background: var(--secondary-light);
  color: var(--secondary);
  border: 1px solid rgba(180, 83, 9, 0.3);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-arabic);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.arabic-toggle-btn:hover {
  background: #fde68a;
  transform: scale(1.05);
}

.btn-search-submit {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-search-submit:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}

/* Quick Arabic Terms Toolbar */
.arabic-quick-terms {
  display: none;
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.arabic-quick-terms.active {
  display: block;
}

.arabic-terms-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.arabic-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  direction: rtl;
}

.arabic-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-arabic);
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.arabic-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Filter Controls Grid */
.filters-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.custom-select-box {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-thai);
  font-size: 0.925rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.custom-select-box:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Quick Filter Pills */
.quick-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.pill-label {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.825rem;
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.filter-pill:hover,
.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 500;
}

/* Main Content Layout */
.main-container {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Results Status Bar */
.results-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.results-count-badge {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.font-size-adjuster {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.font-size-adjuster span {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 0.3rem;
}

.btn-font-size {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-font-size:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Hadith Cards Grid */
.hadiths-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hadith-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.hadith-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

/* Card Header */
.hadith-card-header {
  padding: 1rem 1.5rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-meta-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-collection {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(6, 95, 70, 0.25);
  font-weight: 600;
  font-size: 0.825rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.badge-collection.muslim {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(2, 132, 199, 0.25);
}

.badge-chapter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fdf4ff;
  color: #86198f;
  border: 1px solid #f0abfc;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.badge-chapter:hover {
  background: #a21caf;
  color: #ffffff;
  border-color: #a21caf;
  transform: translateY(-1px);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.badge-number {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-actions-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-card-action {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-card-action:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-card-action.bookmarked {
  color: #ea580c;
  background: #fff7ed;
  border-color: #fdba74;
}

/* Card Body */
.hadith-card-body {
  padding: 1.5rem;
}

.hadith-narrator-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border-color);
}

/* Arabic Text Display */
.hadith-arabic-box {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  line-height: 2.2;
  color: var(--text-arabic);
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border-right: 4px solid var(--primary);
  word-spacing: 0.15em;
}

/* Thai Translation Display */
.hadith-thai-box {
  direction: ltr;
  text-align: left;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-main);
  padding: 0 0.5rem;
}

.hadith-thai-box .quote-lead {
  font-weight: 600;
  color: var(--primary);
  margin-right: 0.25rem;
}

/* Card Detail Footer */
.hadith-card-footer {
  padding: 0.85rem 1.5rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  font-size: 0.825rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hadith-reference-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hadith-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hadith-source-tag a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.hadith-source-tag a:hover {
  color: var(--primary-hover, #047857);
}

/* Search Highlights */
mark.highlight {
  background-color: #fef08a;
  color: #854d0e;
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

[data-theme="dark"] mark.highlight {
  background-color: #854d0e;
  color: #fef08a;
}

/* Pagination */
.pagination-wrapper {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.page-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.page-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px dashed var(--border-color);
  margin: 2rem 0;
}

.empty-state i {
  font-size: 3.5rem;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

/* Toast Notifications */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: #ffffff;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  border-left: 4px solid var(--primary);
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* Footer */
.modern-footer {
  background: #042f2e;
  color: #e2e8f0;
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
  border-top: 3px solid #d97706;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.footer-brand h4 {
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-brand p {
  font-size: 0.875rem;
  color: #94a3b8;
  line-height: 1.7;
  margin: 0;
}

.footer-links h5 {
  font-size: 0.95rem;
  margin: 0 0 0.85rem;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: #fbbf24;
}

.footer-bottom {
  max-width: 1280px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
}

/* ==========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   Supports Mobile (<576px), Tablet (576px-991px), Desktop (992px-1279px), & Large Screens
   ========================================================================== */

/* --- Touch Device Optimizations --- */
@media (hover: none) and (pointer: coarse) {
  .btn-card-action,
  .nav-link-btn,
  .theme-toggle-btn,
  .pill-btn,
  .btn-font-size,
  .btn-search-submit,
  .arabic-toggle-btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* --- Tablets & Medium Screens (max-width: 991px) --- */
@media (max-width: 991px) {
  .hero-header {
    padding: 2.75rem 1.25rem 3.5rem;
  }

  .hero-content h2 {
    font-size: 1.85rem;
  }

  .hero-arabic-verse {
    font-size: 1.6rem;
  }

  .filters-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .hadith-card {
    padding: 1.6rem;
  }

  .hadith-text-arabic {
    font-size: 1.55rem;
    line-height: 2.1;
  }

  .footer-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* --- Mobile Landscape & Small Tablets (max-width: 768px) --- */
@media (max-width: 768px) {
  .nav-inner {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .brand-title-group h1 {
    font-size: 1.15rem;
  }

  .brand-arabic-title {
    display: none;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .nav-actions {
    gap: 0.4rem;
  }

  .nav-link-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.825rem;
  }

  .hero-header {
    padding: 2rem 1rem 3rem;
  }

  .hero-content h2 {
    font-size: 1.55rem;
    line-height: 1.35;
  }

  .hero-arabic-verse {
    font-size: 1.35rem;
    margin-bottom: 1.2rem;
  }

  .search-card-wrapper {
    padding: 1.15rem;
    border-radius: var(--radius-lg);
  }

  .search-input-group {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.6rem;
  }

  .search-input {
    font-size: 1rem;
    padding: 0.4rem 0;
  }

  .search-action-btns {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .arabic-toggle-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem;
  }

  .btn-search-submit {
    flex: 2;
    justify-content: center;
    padding: 0.65rem 1rem;
    min-height: 44px;
  }

  .filters-container {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .quick-pills-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .quick-pills-row::-webkit-scrollbar {
    display: none;
  }

  .pill-btn {
    flex-shrink: 0;
  }

  .results-header-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .font-size-adjuster {
    justify-content: space-between;
    width: 100%;
  }

  .hadith-card {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .hadith-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .card-meta-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .badge-collection,
  .badge-chapter,
  .badge-status,
  .badge-number {
    font-size: 0.78rem;
    padding: 0.25rem 0.55rem;
  }

  .card-actions-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.65rem;
  }

  .btn-card-action {
    flex: 1;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.45rem 0.5rem;
  }

  .hadith-text-arabic {
    font-size: 1.4rem;
    line-height: 2.1;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }

  .hadith-text-thai {
    font-size: 0.96rem;
    line-height: 1.75;
  }

  .pagination-container {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
  }

  .page-link-btn {
    min-width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .modern-footer {
    padding: 2.5rem 1rem 1.5rem;
    margin-top: 3rem;
  }

  .toast-notice {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    justify-content: center;
  }
}

/* --- Small Mobile Phones (max-width: 480px) --- */
@media (max-width: 480px) {
  .nav-link-btn span {
    display: none;
  }

  .brand-title-group .brand-subtitle {
    display: none;
  }

  .brand-title-group h1 {
    font-size: 1.05rem;
  }

  .hero-content h2 {
    font-size: 1.35rem;
  }

  .hero-arabic-verse {
    font-size: 1.2rem;
  }

  .hadith-card {
    padding: 1rem;
  }

  .hadith-text-arabic {
    font-size: 1.25rem;
    line-height: 2.0;
  }

  .hadith-text-thai {
    font-size: 0.92rem;
    line-height: 1.7;
  }

  .btn-card-action {
    font-size: 0.75rem;
    padding: 0.4rem 0.35rem;
  }

  .btn-card-action i {
    font-size: 0.85rem;
  }
}

/* ==========================================================================
   Fake & Weak Hadith Specific Styles (คลังตรวจสอบฮะดีษปลอม)
   ========================================================================== */
.badge-verdict-fabricated {
  background: rgba(239, 68, 68, 0.14) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
[data-theme="dark"] .badge-verdict-fabricated {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
}

.badge-verdict-weak {
  background: rgba(245, 158, 11, 0.14) !important;
  color: #d97706 !important;
  border: 1px solid rgba(245, 158, 11, 0.35) !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
[data-theme="dark"] .badge-verdict-weak {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #fbbf24 !important;
  border-color: rgba(245, 158, 11, 0.45) !important;
}

.badge-verdict-unknown {
  background: rgba(139, 92, 246, 0.14) !important;
  color: #7c3aed !important;
  border: 1px solid rgba(139, 92, 246, 0.35) !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
[data-theme="dark"] .badge-verdict-unknown {
  background: rgba(139, 92, 246, 0.22) !important;
  color: #a78bfa !important;
  border-color: rgba(139, 92, 246, 0.45) !important;
}

.badge-verdict-sound {
  background: rgba(16, 185, 129, 0.14) !important;
  color: #059669 !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fakehadith-card {
  border-left: 4px solid #ef4444;
}
.fakehadith-card.is-weak {
  border-left-color: #f59e0b;
}
.fakehadith-card.is-unknown {
  border-left-color: #8b5cf6;
}

.fakehadith-ruling-box {
  margin-top: 1rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.07);
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.95rem;
}
[data-theme="dark"] .fakehadith-ruling-box {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
}
.fakehadith-ruling-box.is-weak {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.25);
}
[data-theme="dark"] .fakehadith-ruling-box.is-weak {
  background: rgba(245, 158, 11, 0.12);
}
.fakehadith-ruling-box.is-unknown {
  background: rgba(139, 92, 246, 0.07);
  border-color: rgba(139, 92, 246, 0.25);
}
[data-theme="dark"] .fakehadith-ruling-box.is-unknown {
  background: rgba(139, 92, 246, 0.12);
}

.ruling-icon {
  font-size: 1.25rem;
  color: #ef4444;
  margin-top: 0.1rem;
  flex-shrink: 0;
}
.fakehadith-ruling-box.is-weak .ruling-icon {
  color: #f59e0b;
}
.fakehadith-ruling-box.is-unknown .ruling-icon {
  color: #8b5cf6;
}

.ruling-label {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
  color: var(--text-muted);
}
.ruling-text-th {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}
.ruling-text-ar {
  font-family: 'Amiri', serif;
  font-size: 1.1rem;
  direction: rtl;
  color: #dc2626;
  margin-top: 0.25rem;
}
[data-theme="dark"] .ruling-text-ar {
  color: #fca5a5;
}
.fakehadith-ruling-box.is-weak .ruling-text-ar {
  color: #d97706;
}
[data-theme="dark"] .fakehadith-ruling-box.is-weak .ruling-text-ar {
  color: #fcd34d;
}

/* Stats counter grid for fake hadith */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.stat-summary-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: center;
  transition: transform 0.2s ease, background 0.2s ease;
}
.stat-summary-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.22);
}
.stat-summary-num {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  display: block;
}
.stat-summary-title {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

/* Source badge button */
.btn-source-link {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  transition: color 0.15s ease;
}
.btn-source-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ==========================================================================
   Highlight Styling (Matches Quran luxury gold highlight)
   ========================================================================== */
mark.highlight,
mark.search-highlight {
  font-weight: 800;
  font-size: 1.08em;
  color: #92400e;
  background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
  padding: 0.15em 0.4em;
  border-radius: 6px;
  border: 1px solid #d97706;
  border-bottom: 3px solid #b45309;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
  display: inline-block;
  line-height: 1.35;
  transition: all 0.25s ease;
}

[data-theme="dark"] mark.highlight,
[data-theme="dark"] mark.search-highlight {
  color: #fef08a;
  background: linear-gradient(120deg, rgba(217, 119, 6, 0.45) 0%, rgba(180, 83, 9, 0.65) 100%);
  border: 1px solid #f59e0b;
  border-bottom: 3px solid #d97706;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

/* ==========================================================================
   Pagination Component & Per-Page Row Selector
   ========================================================================== */
.pagination-per-page {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.per-page-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--primary);
  font-weight: 600;
}

.per-page-select {
  padding: 0.45rem 0.95rem;
  border-radius: 9999px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.per-page-select:hover {
  border-color: var(--primary);
}

.per-page-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 61, 40, 0.15);
}

/* ==========================================================================
   User Auth Widget & Reading Tracker
   ========================================================================== */
.user-auth-widget-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-auth-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-auth-link:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.btn-nav-history {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fef3c7;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-nav-history:hover {
  background: rgba(245, 158, 11, 0.28);
  color: #ffffff;
}

.user-menu-dropdown-wrap {
  position: relative;
}

.user-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-profile-circle-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.user-profile-circle-btn:hover {
  transform: scale(1.08);
}

.user-avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  border: 2px solid #fde68a;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-profile-circle-btn:hover .user-avatar-circle {
  border-color: #ffffff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
}

.user-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-initials {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.user-avatar-sublabel {
  font-size: 0.65rem;
  color: #fde68a;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1;
  max-width: 54px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  display: block;
}

.user-avatar-img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #ffffff;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  z-index: 99999;
}

.user-dropdown-menu.active {
  display: flex;
}

.dropdown-header {
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.35rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.88rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--bg-main);
}

.dropdown-item.text-danger {
  color: #ef4444;
}

.dropdown-item-muted {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Bookmarks Modal */
.bookmarks-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 1rem;
}

.bookmarks-modal-overlay.open {
  display: flex;
}

.bookmarks-modal-content {
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.bookmarks-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.bookmarks-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.bookmarks-modal-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
}

.bookmarks-list-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bookmark-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.bookmark-item-row:hover {
  border-color: var(--primary);
  background: #ffffff;
}

.bookmark-link {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  text-decoration: none;
  flex: 1;
}

.btn-delete-bm {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.btn-delete-bm:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* ==========================================================================
   Ad Slots & Sponsor Banner System
   ========================================================================== */
.ad-slot-container {
  width: 100%;
  margin: 2rem 0;
  display: flex;
  justify-content: center;
}

.ad-slot-box {
  width: 100%;
  max-width: 900px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px dashed var(--border-color);
  background: rgba(248, 250, 252, 0.6);
  position: relative;
  transition: all 0.3s ease;
}

[data-theme="dark"] .ad-slot-box {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

.ad-placeholder-banner {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-decoration: none;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.ad-placeholder-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.ad-placeholder-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.ad-placeholder-text h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}

.ad-placeholder-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.ad-badge-sponsor {
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  font-weight: 700;
  border: 1px solid rgba(245, 158, 11, 0.3);
  white-space: nowrap;
}

.ad-slot-custom-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Responsive Breakpoint Enhancements (All 5 Viewports)
   ========================================================================== */

/* 1. Large Desktop (>= 1440px) */
@media (min-width: 1440px) {
  .hadith-container,
  .hadith-detail-container {
    max-width: 1380px !important;
    margin: 0 auto;
  }
  .hadith-card {
    padding: 2rem 2.25rem;
  }
  .hadith-arabic-box {
    font-size: 1.65rem;
    line-height: 2.3;
  }
  .hadith-thai-box {
    font-size: 1.15rem;
    line-height: 1.95;
  }
}

/* 2. Medium Desktop / Laptop (1024px - 1439px) */
@media (max-width: 1439px) and (min-width: 1024px) {
  .hadith-container,
  .hadith-detail-container {
    max-width: 1140px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

/* 3. Tablets (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
  .hadith-container,
  .hadith-detail-container {
    max-width: 100%;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  .search-inputs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 4. Mobile Devices (<= 767px) */
@media (max-width: 767px) {
  .hadith-container,
  .hadith-detail-container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  .search-inputs-grid {
    grid-template-columns: 1fr;
  }
  .card-meta-left {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .card-actions-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
  }
  .btn-card-action {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.4rem 0.35rem;
    justify-content: center;
  }
  .pagination-per-page {
    width: 100%;
    justify-content: center;
  }
  .pagination-nav-group {
    width: 100%;
    justify-content: center;
  }
  .ad-placeholder-banner {
    flex-direction: column;
    text-align: center;
  }
  .ad-placeholder-left {
    flex-direction: column;
  }
}

/* 5. Extra Small Mobile (< 380px) */
@media (max-width: 380px) {
  .hadith-card {
    padding: 0.85rem 0.75rem;
  }
  .hadith-arabic-box {
    font-size: 1.3rem;
    line-height: 2.0;
  }
  .hadith-thai-box {
    font-size: 0.92rem;
    line-height: 1.7;
  }
  .btn-card-action span {
    display: none;
  }
}

/* ==========================================================================
   MOBILE APP HAMBURGER & OFF-CANVAS DRAWER
   ========================================================================== */
.badge-index-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 9px;
  border-radius: 6px;
  border: 1px solid rgba(5, 150, 105, 0.25);
  letter-spacing: 0.01em;
}

[data-theme="dark"] .badge-index-count {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.mobile-app-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.mobile-app-hamburger:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.04);
}

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 30, 20, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.mobile-app-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 86vw;
  background: #064e3b;
  color: #ffffff;
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-app-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.15);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #ffffff;
}

.drawer-logo-badge {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #d97706, #b45309);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #ffffff;
}

.drawer-brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  display: block;
}

.drawer-brand-tag {
  font-size: 0.75rem;
  color: #a7f3d0;
  display: block;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.drawer-close-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
  color: #fca5a5;
  transform: rotate(90deg);
}

.drawer-user-card {
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #d97706;
}

.drawer-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #ffffff;
  display: block;
}

.drawer-user-role {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.drawer-guest-actions {
  display: flex;
  gap: 0.5rem;
}

.drawer-btn-login,
.drawer-btn-register {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.drawer-btn-login {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
}

.drawer-btn-register {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.drawer-nav-section {
  padding: 1rem 1.25rem 0.5rem;
}

.drawer-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #a7f3d0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.65rem;
}

.drawer-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.drawer-menu-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: #e2e8f0;
  text-decoration: none;
  transition: all 0.2s ease;
  background: transparent;
}

.drawer-menu-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(3px);
}

.drawer-menu-link.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fde68a;
  font-weight: 600;
  border-left: 3px solid #fde68a;
}

.drawer-menu-link .menu-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: #ffffff;
  flex-shrink: 0;
}

.drawer-menu-link.active .menu-icon-box {
  background: rgba(253, 230, 138, 0.2);
  color: #fde68a;
}

.drawer-menu-link .menu-text-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.drawer-menu-link .menu-label {
  font-size: 0.92rem;
  font-weight: 500;
}

.drawer-menu-link .menu-sublabel {
  font-size: 0.72rem;
  color: #94a3b8;
}

.drawer-menu-link .menu-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.4;
  transition: transform 0.2s;
}

.drawer-footer {
  margin-top: auto;
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.drawer-theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fde68a;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.drawer-copyright {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 0.75rem;
}

/* Collapse navbar on Mobile (< 992px) */
@media (max-width: 991px) {
  .modern-nav .nav-actions a.nav-link-btn,
  .site-header .nav-actions a.nav-link-btn {
    display: none !important;
  }

  .mobile-app-hamburger {
    display: inline-flex !important;
  }

  .nav-actions {
    flex-wrap: nowrap !important;
    gap: 0.45rem;
  }

  /* Tuck reading bookmark into the app drawer on mobile to keep top bar clean */
  .btn-nav-history {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .btn-auth-link span {
    display: none;
  }
  .btn-auth-link {
    padding: 0.45rem 0.65rem;
  }
}



