/**
 * Live Nadhom (Tuhfatul Athfal) - Stylesheet
 * Scoped under .ln-app-wrapper & #ln-* IDs to guarantee zero conflict with Al-Qur'an Tahfidz
 */

.ln-app-wrapper,
.ln-app-wrapper *,
.ln-modal,
.ln-modal *,
#ln-toast {
  box-sizing: border-box !important;
  font-family: 'Spectral', Georgia, Cambria, 'Times New Roman', serif !important;
}

.ln-app-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  color: #1e293b;
  background-color: #f8fafc;
  min-height: 100vh;
}

/* Header & HUD */
.ln-header {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.ln-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ln-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

.ln-brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.ln-brand-sub {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

/* Scoreboard & Controls Bar */
.ln-scoreboard {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.ln-scoreboard-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.ln-santri-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ln-santri-select-wrap select,
.ln-santri-select-wrap input {
  padding: 8px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.875rem;
  background: #ffffff;
  color: #0f172a;
  outline: none;
}

.ln-santri-select-wrap select:focus,
.ln-santri-select-wrap input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

/* Timer Stopwatch Box */
.ln-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 8px;
}

.ln-timer-display {
  font-family: monospace, 'Courier New', Courier !important;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0369a1;
  min-width: 55px;
  text-align: center;
}

.ln-timer-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s ease;
}

.ln-timer-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.ln-timer-btn.is-active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Score Badges */
.ln-score-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ln-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}

.ln-score-final {
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  color: #0369a1;
  font-size: 1.1rem;
  font-weight: 900;
}

.ln-badge-jaly {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.ln-badge-khofiy {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

/* Material Selector Toolbar */
.ln-material-toolbar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.ln-chapter-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ln-chapter-select {
  padding: 8px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  background: #ffffff;
  color: #0f172a;
  min-width: 250px;
  outline: none;
}

.ln-chapter-select:focus {
  border-color: #0284c7;
}

.ln-range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
}

.ln-range-inputs input {
  width: 55px;
  text-align: center;
  padding: 6px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 700;
}

.ln-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ln-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.825rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ln-toggle-btn:hover {
  background: #e2e8f0;
}

.ln-toggle-btn.is-active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.ln-btn-finish {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.25);
  transition: all 0.15s ease;
}

.ln-btn-finish:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  transform: translateY(-1px);
}

/* Verses Container */
.ln-verses-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 2rem;
}

/* Chapter Heading Divider */
.ln-chapter-header {
  background: linear-gradient(135deg, #f0fdf4, #e0f2fe);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 12px 18px;
  margin: 12px 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ln-chapter-header-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0369a1;
}

.ln-chapter-header-ar {
  font-family: 'Amiri', 'Scheherazade New', serif !important;
  font-size: 1.35rem;
  color: #047857;
  direction: rtl;
}

/* Bait Card (Two Hemistichs) */
.ln-bait-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 20px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  position: relative;
}

.ln-bait-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.ln-bait-card.has-error {
  border-color: #fca5a5;
  background: #fffafa;
}

.ln-bait-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  border-bottom: 1px dashed #f1f5f9;
  padding-bottom: 6px;
}

.ln-bait-badge {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}

.ln-bait-chapter-tag {
  font-size: 0.78rem;
  color: #64748b;
  font-style: italic;
}

/* Arabic Poetry Layout (2 Hemistichs: Shadr & 'Ajuz) */
.ln-bait-arabic {
  direction: rtl;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif !important;
  font-size: 1.65rem;
  line-height: 2.2;
  text-align: justify;
  text-align-last: justify;
  margin: 6px 0;
}

.ln-syathr {
  flex: 1 1 45%;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fafaf9;
}

.ln-syathr-sep {
  flex: 0 0 auto;
  color: #0284c7;
  font-size: 1.25rem;
  line-height: 1;
  user-select: none;
  opacity: 0.8;
}

/* Individual Clickable Word */
.ln-word {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  user-select: none;
}

.ln-word:hover {
  background: #e0f2fe;
  color: #0369a1;
  transform: translateY(-1px);
}

.ln-word.is-jaly {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-bottom: 2.5px solid #dc2626 !important;
  font-weight: bold;
}

.ln-word.is-khofiy {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-bottom: 2.5px solid #d97706 !important;
  font-weight: bold;
}

/* Indonesian Translation */
.ln-bait-translation {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
  font-style: italic;
  display: block;
}

.ln-bait-translation.is-hidden {
  display: none !important;
}

/* Errors Summary in Card */
.ln-bait-marks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ln-mark-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.ln-mark-pill.is-jaly {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.ln-mark-pill.is-khofiy {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Modal Dialogs */
.ln-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ln-modal-backdrop.is-open {
  display: flex !important;
}

.ln-modal-content {
  background: #ffffff;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 1.5rem;
  position: relative;
}

.ln-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.75rem;
}

.ln-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.ln-modal-close,
.ln-modal-close-btn {
  background: transparent !important;
  border: none !important;
  font-size: 1.35rem !important;
  cursor: pointer !important;
  color: #64748b !important;
  padding: 0 !important;
  line-height: 1 !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: none !important;
  transition: all 0.15s ease !important;
}

.ln-modal-close:hover,
.ln-modal-close-btn:hover {
  color: #0f172a !important;
  background: #f1f5f9 !important;
}

.ln-word-preview {
  direction: rtl;
  font-family: 'Amiri', serif !important;
  font-size: 2rem;
  text-align: center;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 1rem;
  color: #0369a1;
}

.ln-type-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 1rem;
}

.ln-type-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.875rem;
  cursor: pointer;
  border: 2px solid transparent;
  text-align: center;
  transition: all 0.15s ease;
}

.ln-type-btn.type-jaly {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.ln-type-btn.type-jaly.is-selected {
  background: #dc2626;
  color: #ffffff;
  border-color: #b91c1c;
}

.ln-type-btn.type-khofiy {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.ln-type-btn.type-khofiy.is-selected {
  background: #d97706;
  color: #ffffff;
  border-color: #b45309;
}

.ln-presets-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 6px;
}

.ln-presets-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}

.ln-preset-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s ease;
}

.ln-preset-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.ln-custom-note {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  resize: vertical;
}

.ln-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ln-btn-save-mark {
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 800;
  font-size: 0.875rem;
  cursor: pointer;
  flex: 1;
}

.ln-btn-save-mark:hover {
  background: #0369a1;
}

.ln-btn-delete-mark {
  background: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
}

.ln-btn-delete-mark:hover {
  background: #dc2626;
}

/* Toast Notifications */
#ln-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2);
  z-index: 999999;
  display: none;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

#ln-toast.is-show {
  display: flex !important;
}

/* Responsive */
@media (max-width: 768px) {
  .ln-bait-arabic {
    flex-direction: column !important;
    text-align: center !important;
    text-align-last: center !important;
    gap: 6px !important;
  }
  .ln-syathr {
    width: 100% !important;
    justify-content: center !important;
    padding: 6px 4px !important;
  }
  .ln-syathr-sep {
    transform: none !important;
    margin: 2px 0 !important;
    font-size: 1rem !important;
    color: #0284c7 !important;
    opacity: 0.8 !important;
  }
}
