/* --- Variables & Color Palettes --- */
:root[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-card: #1e293b;
  --bg-card-subtle: #172033;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.2);
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.2);
  --whatsapp: #22c55e;
  --compass-rim: #334155;
  --compass-face: #0f172a;
}

:root[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #059669;
  --primary-glow: rgba(5, 150, 105, 0.15);
  --accent-gold: #d97706;
  --accent-gold-glow: rgba(217, 119, 6, 0.15);
  --whatsapp: #16a34a;
  --compass-rim: #cbd5e1;
  --compass-face: #ffffff;
}

/* --- Base Resets --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

.app-container {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.pill-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 38px;
}

.icon-btn {
  padding: 6px 10px;
  font-size: 1rem;
}

/* --- Location Bar --- */
.location-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.location-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pin-icon {
  font-size: 1.2rem;
}

.location-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.location-coords {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px;
}

/* --- Common Card Styles --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

/* --- Countdown Card --- */
.countdown-card {
  background: linear-gradient(
    135deg,
    var(--bg-card) 0%,
    var(--bg-card-subtle) 100%
  );
  border-left: 4px solid var(--accent-gold);
  text-align: center;
}

.countdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.badge-next {
  background: var(--accent-gold-glow);
  color: var(--accent-gold);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.date-str {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.next-prayer-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.countdown-timer {
  font-size: 2.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--primary);
  margin-bottom: 4px;
}

.next-prayer-time {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Daily Prayer Times List --- */
.prayer-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prayer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-card-subtle);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.prayer-row.active {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.p-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.p-time {
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

/* 1-Line Attribution */
.attribution-line {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.attribution-line a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.attribution-line a:hover {
  text-decoration: underline;
}

/* WhatsApp Share Button */
.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--whatsapp);
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-wa:active {
  transform: scale(0.96);
}

/* --- Compass & Map --- */
.qibla-angle {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.compass-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 16px;
}

.compass-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.compass-status.aligned {
  background: var(--primary-glow);
  color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.compass-dial {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 6px solid var(--compass-rim);
  background: var(--compass-face);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0 14px rgba(0, 0, 0, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 18px;
  transform: rotate(0deg);
  transition: transform 0.12s ease-out;
}

.cardinal-mark {
  position: absolute;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cardinal-mark.n {
  top: 6px;
  color: #ef4444;
}
.cardinal-mark.e {
  right: 8px;
}
.cardinal-mark.s {
  bottom: 6px;
}
.cardinal-mark.w {
  left: 8px;
}

.qibla-pointer-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(0deg);
}

.qibla-marker {
  position: absolute;
  top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kaaba-icon {
  font-size: 1.4rem;
  margin-bottom: -4px;
}

.qibla-needle {
  width: 4px;
  height: 48px;
  background: linear-gradient(to bottom, var(--accent-gold), transparent);
  border-radius: 2px;
}

.compass-dial.is-aligned .qibla-needle {
  background: linear-gradient(to bottom, var(--primary), transparent);
}

.compass-center {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 2px solid #ffffff;
  z-index: 2;
}

.compass-readout {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
}

.readout-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  text-align: center;
}

.readout-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.readout-value {
  font-size: 1rem;
  font-weight: 700;
}

.map-container {
  width: 100%;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* --- Buttons & Modals --- */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
}

.btn-secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  padding: 24px;
  text-align: center;
}

.modal-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.modal-card h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.city-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin: 16px 0;
}

.city-item-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.mt-3 {
  margin-top: 12px;
}

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 12px 0 24px;
}
