/* =========================================
   SalahTime — CSS
   ========================================= */

:root {
  --green: #1a6b3c;
  --green-mid: #22854b;
  --green-light: #4caf7d;
  --green-pale: #e8f5ee;
  --gold: #c9a84c;
  --gold-light: #f0d98a;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* =========================================
   Splash Screen
   ========================================= */

.splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #1a6b3c 0%, #0f4025 60%, #07270f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.splash-content {
  text-align: center;
  padding: 24px;
  max-width: 340px;
  width: 100%;
  animation: fadeUp 0.6s ease forwards;
}

.splash-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  filter: drop-shadow(0 4px 16px rgba(255,255,255,0.15));
}

.splash-icon svg {
  width: 100%;
  height: 100%;
}

.splash-title {
  font-family: 'Amiri', serif;
  font-size: 42px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.splash-subtitle {
  font-size: 15px;
  color: rgba(255,255,255,0.72);
  line-height: 1.5;
  margin-bottom: 40px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(201,168,76,0.4);
}

.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(201,168,76,0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-large {
  width: 100%;
  font-size: 16px;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--green-pale);
}

.splash-note {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* =========================================
   Main App Layout
   ========================================= */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* =========================================
   Header
   ========================================= */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
  box-shadow: var(--shadow-sm);
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.logo-text {
  font-family: 'Amiri', serif;
  font-size: 22px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  transition: background 0.2s;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* =========================================
   Prayer Banner
   ========================================= */

.prayer-banner {
  background: var(--green-pale);
  border-bottom: 1px solid rgba(26,107,60,0.15);
  padding: 8px 16px;
  flex-shrink: 0;
  z-index: 9;
}

.prayer-banner-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--green);
  margin-bottom: 6px;
}

.prayer-times-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.prayer-times-strip::-webkit-scrollbar {
  display: none;
}

.prayer-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 68px;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.prayer-chip.current {
  background: var(--green);
  border-color: var(--green);
}

.prayer-chip.current .prayer-chip-name,
.prayer-chip.current .prayer-chip-time {
  color: white;
}

.prayer-chip-name {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.prayer-chip-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

/* =========================================
   Map
   ========================================= */

.map {
  flex: 1;
  min-height: 0;
  z-index: 1;
}

/* Custom Leaflet overrides */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  border: none !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: 'Inter', sans-serif !important;
}

.popup-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.popup-distance {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.popup-btn {
  display: inline-block;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: center;
  transition: background 0.2s;
}

.popup-btn:hover {
  background: var(--green-mid);
}

/* User location pulse */
.user-marker {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.25);
  animation: pulse 2s infinite;
}

/* Masjid marker */
.masjid-marker {
  width: 36px;
  height: 36px;
  background: var(--green);
  border: 2.5px solid white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.masjid-marker:hover {
  transform: rotate(-45deg) scale(1.15);
}

.masjid-marker-inner {
  transform: rotate(45deg);
  color: white;
  font-size: 16px;
  line-height: 1;
}

/* =========================================
   Bottom Sheet
   ========================================= */

.bottom-sheet {
  position: relative;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  z-index: 5;
  max-height: 55vh;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 4px;
}

.location-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.location-icon {
  width: 16px;
  height: 16px;
  color: var(--green);
  flex-shrink: 0;
}

.location-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* =========================================
   State Containers
   ========================================= */

.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.state-icon {
  width: 40px;
  height: 40px;
  color: var(--border);
}

.error-icon {
  color: #ef4444;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* =========================================
   Masjid List
   ========================================= */

.masjid-list {
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.masjid-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  animation: fadeUp 0.3s ease forwards;
}

.masjid-card:hover {
  border-color: var(--green-light);
  box-shadow: 0 2px 12px rgba(26,107,60,0.1);
  transform: translateY(-1px);
}

.masjid-card:active {
  transform: translateY(0);
}

.card-icon {
  width: 44px;
  height: 44px;
  background: var(--green-pale);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon svg {
  width: 24px;
  height: 24px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-distance {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

.card-direction {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-arrow {
  width: 20px;
  height: 20px;
  color: var(--border);
  flex-shrink: 0;
}

/* =========================================
   Modal / Detail Sheet
   ========================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px 0;
}

.modal-handle {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

.close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.close-btn svg {
  width: 18px;
  height: 18px;
}

.close-btn:hover {
  background: var(--border);
}

.modal-body {
  padding: 8px 20px 32px;
}

.modal-masjid-icon {
  width: 72px;
  height: 72px;
  background: var(--green-pale);
  border-radius: var(--radius-lg);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-masjid-icon svg {
  width: 48px;
  height: 48px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.3;
}

.modal-address {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--green-pale);
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
}

.meta-chip svg {
  width: 14px;
  height: 14px;
}

/* =========================================
   Prayer Times Grid (in modal)
   ========================================= */

.prayer-section {
  margin-bottom: 24px;
}

.prayer-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.prayer-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 10px;
}

.prayer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.prayer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}

.prayer-row.current-prayer {
  background: var(--green);
  border-color: var(--green);
}

.prayer-row.current-prayer .prayer-name,
.prayer-row.current-prayer .prayer-time {
  color: white;
}

.prayer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.prayer-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.modal-actions {
  margin-top: 4px;
}

/* =========================================
   Animations
   ========================================= */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

/* =========================================
   Responsive — larger screens
   ========================================= */

@media (min-width: 600px) {
  .modal-sheet {
    max-width: 480px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    margin-bottom: 24px;
  }

  .modal {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  .bottom-sheet {
    max-height: 50vh;
  }
}
