/* ============ CSS VARIABLES & RESET ============ */
:root {
  --primary: #5B4CDB;
  --primary-light: #7C6FE8;
  --primary-dark: #4338A8;
  --accent: #F0A500;
  --bg: #F8F6FF;
  --bg-card: #FFFFFF;
  --text-primary: #2D2644;
  --text-secondary: #6B6283;
  --text-light: #9B92B5;
  --border: #E8E3F3;
  --shadow-sm: 0 2px 8px rgba(91, 76, 219, 0.08);
  --shadow-md: 0 4px 20px rgba(91, 76, 219, 0.12);
  --shadow-lg: 0 8px 40px rgba(91, 76, 219, 0.15);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ LAYOUT ============ */
.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  padding-bottom: 100px;
}

/* ============ HEADER ============ */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(91, 76, 219, 0.25);
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.app-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.app-logo-icon {
  font-size: 24px;
}

/* ============ NAVIGATION ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 100;
  border-top: 1px solid var(--border);
}

.nav-btn {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-btn .nav-icon {
  font-size: 22px;
  transition: transform 0.2s;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.active .nav-icon {
  transform: scale(1.15);
}

.nav-btn:hover {
  color: var(--primary);
}

/* ============ ANIMATIONS ============ */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ HERO SECTION ============ */
.hero-section {
  text-align: center;
  padding: 40px 0 30px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ============ SEARCH ============ */
.search-container {
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-family: var(--font-body);
  border: 2px solid var(--border);
  border-radius: 50px;
  background: white;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(91, 76, 219, 0.1);
}

.search-input::placeholder {
  color: var(--text-light);
}

/* ============ DAILY VERSE ============ */
.daily-verse-card {
  background: linear-gradient(135deg, var(--primary), #7C6FE8, #A78BFA);
  color: white;
  padding: 28px;
  border-radius: var(--radius-lg);
  margin: 20px 0 32px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.daily-verse-card::before {
  content: '"';
  position: absolute;
  top: -20px;
  right: 20px;
  font-size: 120px;
  font-family: var(--font-display);
  opacity: 0.15;
  line-height: 1;
}

.daily-label {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.daily-verse-text {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.7;
  margin-bottom: 12px;
  font-style: italic;
}

.daily-verse-ref {
  font-size: 14px;
  opacity: 0.9;
  font-weight: 600;
  margin-bottom: 12px;
}

.daily-verse-card .btn-text {
  color: white;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============ SECTION TITLE ============ */
.section-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* ============ CATEGORIES GRID ============ */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.category-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--cat-color);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--cat-color);
}

.category-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.category-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.category-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.category-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--cat-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ BACK BUTTON ============ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 10px 0;
  margin-bottom: 16px;
  transition: opacity 0.2s;
}

.back-btn:hover {
  opacity: 0.7;
}

.back-arrow {
  font-size: 18px;
}

/* ============ CATEGORY HEADER ============ */
.category-header {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 70%, white));
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  color: white;
}

.category-header-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.category-header-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.category-header-desc {
  font-size: 16px;
  opacity: 0.9;
}

/* ============ VERSE LIST ============ */
.verse-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.verse-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--cat-color, var(--primary));
}

.verse-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.verse-card-ref {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.verse-card-preview {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
  font-style: italic;
}

.verse-card-action {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

/* ============ VERSE DISPLAY ============ */
.verse-display {
  background: linear-gradient(135deg, #faf9ff, #f0eeff);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 20px;
  border: 2px solid var(--border);
  position: relative;
}

.verse-display-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.verse-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.verse-actions-top {
  display: flex;
  gap: 8px;
}

.verse-reference {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.verse-text-full {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.8;
  color: var(--text-primary);
  font-style: italic;
  border: none;
  padding: 0;
  margin: 0 0 20px;
}

/* ============ AUDIO CONTROLS ============ */
.verse-audio-controls {
  display: flex;
  justify-content: center;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
}

.audio-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.03);
}

/* ============ EXPLANATION & APPLICATION CARDS ============ */
.explanation-card, .application-card, .chapter-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.explanation-card {
  border-left: 4px solid var(--primary);
}

.application-card {
  border-left: 4px solid var(--accent);
}

.chapter-card {
  border-left: 4px solid #00b894;
  text-align: center;
}

.explanation-title, .application-title, .chapter-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.explanation-text, .application-text, .chapter-desc {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.chapter-desc {
  margin-bottom: 16px;
}

/* ============ COMMENTS ============ */
.comments-section {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.comments-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.comment-form {
  margin-bottom: 24px;
}

.comment-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--font-body);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text-primary);
  line-height: 1.6;
}

.comment-input:focus {
  border-color: var(--primary-light);
}

.comment-submit {
  margin-top: 10px;
}

.no-comments {
  color: var(--text-light);
  font-style: italic;
  text-align: center;
  padding: 16px;
}

.comment-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
}

.comment-date {
  font-size: 12px;
  color: var(--text-light);
}

.comment-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.comment-delete {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
  font-family: var(--font-body);
}

.comment-delete:hover {
  color: #e74c3c;
}

/* ============ VERSE NAVIGATION ============ */
.verse-nav, .chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

/* ============ BUTTONS ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 10px 22px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 4px 0;
}

.btn-text:hover {
  text-decoration: underline;
}

.icon-btn {
  background: none;
  border: 2px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-light);
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn.saved {
  color: #e74c7b;
  border-color: #e74c7b;
}

/* ============ STUDY BIBLE ============ */
.study-header {
  text-align: center;
  padding: 40px 0 24px;
}

.study-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.study-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

.testament-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 20px;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: white;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-btn:hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.book-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 18px;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: var(--shadow-sm);
  text-align: center;
  border-top: 3px solid;
}

.book-card.old {
  border-top-color: #e17055;
}

.book-card.new {
  border-top-color: var(--primary);
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.book-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.book-chapters {
  font-size: 13px;
  color: var(--text-secondary);
}

.book-testament {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* ============ CHAPTERS VIEW ============ */
.chapters-header {
  text-align: center;
  padding: 24px 0;
}

.chapters-book-name {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.chapters-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.chapter-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.chapter-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
}

/* ============ READER VIEW ============ */
.reader-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.reader-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.font-controls {
  display: flex;
  gap: 4px;
}

.font-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: all 0.2s;
}

.font-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.reader-content {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
}

.bible-text {
  font-size: 18px;
  line-height: 2;
  color: var(--text-primary);
}

.bible-verse {
  margin-bottom: 8px;
  text-indent: -0.5em;
  padding-left: 0.5em;
}

.verse-number {
  font-weight: 800;
  font-size: 13px;
  color: var(--primary);
  vertical-align: super;
  margin-right: 3px;
}

/* ============ SAVED VERSES ============ */
.saved-header {
  text-align: center;
  padding: 40px 0 24px;
}

.saved-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.saved-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.saved-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.saved-card-ref {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.saved-card-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 10px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--text-light);
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ============ LOADING & ERROR ============ */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.error-message {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.error-detail {
  font-size: 14px;
  color: var(--text-light);
  margin: 8px 0 16px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .hero-title {
    font-size: 28px;
  }

  .categories-grid {
    grid-template-columns: 1fr;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .chapters-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }

  .verse-display {
    padding: 24px;
  }

  .verse-text-full {
    font-size: 18px;
  }

  .verse-reference {
    font-size: 22px;
  }

  .reader-content {
    padding: 20px;
  }

  .bible-text {
    font-size: 16px;
  }

  .reader-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .explanation-card, .application-card, .chapter-card, .comments-section {
    padding: 20px;
  }

  .daily-verse-card {
    padding: 24px;
  }

  .app-container {
    padding: 0 14px;
    padding-bottom: 100px;
  }
}

@media (min-width: 768px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
