/* Import premium Hebrew fonts from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;600;800&family=Secular+One&family=Frank+Ruhl+Libre:wght@700&display=swap');

/* Color Themes Configuration */
:root {
  /* Default: Midnight Navy Theme */
  --bg-gradient: linear-gradient(135deg, #030514 0%, #080c25 50%, #121845 100%);
  --card-bg: rgba(13, 20, 50, 0.45);
  --card-border: rgba(60, 100, 250, 0.25);
  --text-main: #f0f4ff;
  --text-muted: #a3b3cc;
  --accent: #6eb7ff;
  --highlight: #ffb703;
  --alert-glow: rgba(255, 183, 3, 0.6);
  --shabbat-gold: #ffc300;
  --font-base: 16px;
}

body.theme-charcoal {
  --bg-gradient: linear-gradient(135deg, #080808 0%, #121212 50%, #202020 100%);
  --card-bg: rgba(30, 30, 30, 0.5);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f5f5f5;
  --text-muted: #aaaaaa;
  --accent: #e0e0e0;
  --highlight: #d4af37;
  --alert-glow: rgba(212, 175, 55, 0.6);
  --shabbat-gold: #d4af37;
}

body.theme-emerald {
  --bg-gradient: linear-gradient(135deg, #010603 0%, #06180c 50%, #0d2e18 100%);
  --card-bg: rgba(10, 30, 18, 0.5);
  --card-border: rgba(46, 184, 114, 0.22);
  --text-main: #f0faf4;
  --text-muted: #a8c7b6;
  --accent: #78e0ab;
  --highlight: #ffd000;
  --alert-glow: rgba(255, 208, 0, 0.6);
  --shabbat-gold: #e5c158;
}

body.theme-royal {
  --bg-gradient: linear-gradient(135deg, #05020c 0%, #110822 50%, #251242 100%);
  --card-bg: rgba(25, 13, 45, 0.5);
  --card-border: rgba(162, 80, 240, 0.22);
  --text-main: #f8f4fc;
  --text-muted: #c2b4d4;
  --accent: #cca3ff;
  --highlight: #ffe169;
  --alert-glow: rgba(255, 225, 105, 0.6);
  --shabbat-gold: #ffd23f;
}

body.theme-burgundy {
  --bg-gradient: linear-gradient(135deg, #0b0203 0%, #1e070a 50%, #3a0d12 100%);
  --card-bg: rgba(38, 11, 14, 0.5);
  --card-border: rgba(230, 50, 70, 0.22);
  --text-main: #fff0f2;
  --text-muted: #d0abb0;
  --accent: #ffa3b1;
  --highlight: #e5c158;
  --alert-glow: rgba(229, 193, 88, 0.6);
  --shabbat-gold: #ffd60a;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Assistant', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  height: 100vh;
  padding: 0.8rem;
  overflow: hidden;
  direction: rtl;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: background 0.5s ease;
}

/* Font Size Scaling */
body[data-font-size="normal"] { --font-base: 15px; }
body[data-font-size="large"] { --font-base: 18px; }
body[data-font-size="xlarge"] { --font-base: 21px; }

/* Panels & Cards */
.glass-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  padding: 0.7rem 1rem;
  transition: all 0.3s ease;
}

/* 1. Top Header Bar (Inline Synagogue Panel) */
.top-header-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  height: 6vh;
  flex-shrink: 0;
  border-radius: 12px;
}

.top-header-bar .day-of-week {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.05);
  color: var(--text-main);
}

.top-header-bar .hebrew-date {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.15);
  color: var(--highlight);
}

.top-header-bar .parasha-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: calc(var(--font-base) * 1.05);
  color: var(--accent);
}

.header-divider {
  color: var(--card-border);
  font-weight: 300;
  font-size: calc(var(--font-base) * 1.1);
}

.special-day-tag {
  background: rgba(255, 183, 3, 0.15);
  border: 1px solid var(--highlight);
  color: var(--highlight);
  font-size: calc(var(--font-base) * 0.75);
  padding: 0.1rem 0.5rem;
  border-radius: 15px;
  font-weight: 600;
  margin-right: 0.5rem;
  animation: pulse-border 2s infinite alternate;
}

/* 2. Large Main Clock Container */
.main-clock-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 18vh;
  flex-shrink: 0;
  border: 2px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
  position: relative;
}

.main-clock-display {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 3.4);
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
  letter-spacing: 2px;
}

.clock-seconds-small {
  font-size: 0.55em;
  opacity: 0.75;
  margin-right: 0.1rem;
  font-weight: 400;
}

.main-clock-container .gregorian-date {
  font-size: calc(var(--font-base) * 0.85);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.3rem;
}

/* 3. Live Western Wall Container */
.kotel-container {
  height: 20vh;
  position: relative;
  overflow: hidden;
  padding: 0;
  flex-shrink: 0;
  border-radius: 16px;
  border: 2px solid var(--card-border);
}

.kotel-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #000;
}

.kotel-label {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: calc(var(--font-base) * 0.7);
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kotel-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #ff3b30;
  border-radius: 50%;
  animation: blink 1s infinite alternate;
}

/* 4. Zmanim Layout Panel */
.zmanim-container {
  flex: 1; /* Consumes remaining space dynamically */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.zmanim-section-title {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 0.95);
  color: var(--accent);
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 0.2rem;
  margin-bottom: 0.1rem;
}

/* 4a. Big Four Zmanim (Alot, Netz, Shkia, Tzeit) - Main Prominent Grid */
.big-four-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  flex-shrink: 0;
}

.zman-card-large {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.zman-card-large .zman-name {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.05);
  color: #ffffff;
}

.zman-card-large .zman-time {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.55);
  color: var(--highlight);
  text-shadow: 0 0 10px rgba(255, 183, 3, 0.2);
}

.zman-card-large .zman-opinion {
  font-size: calc(var(--font-base) * 0.7);
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* 4b. Dynamic Rotating Grid (Secondary switching list) */
.dynamic-zmanim-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

/* Dynamic Zman Cards */
.zman-card-small {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.zman-card-small .zman-name {
  font-size: calc(var(--font-base) * 0.85);
  font-weight: 600;
  color: var(--text-main);
}

.zman-card-small .zman-opinion {
  font-size: calc(var(--font-base) * 0.65);
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.zman-card-small .zman-time {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.1);
  color: var(--accent);
}

/* Upcoming zman alert state */
.zman-card-small.upcoming-alert {
  background: rgba(255, 183, 3, 0.12) !important;
  border: 1.5px solid var(--highlight) !important;
  box-shadow: 0 0 15px var(--alert-glow);
  transform: scale(1.02);
  animation: pulse-card 1.5s infinite alternate;
}
.zman-card-small.upcoming-alert .zman-name { color: #fff; }
.zman-card-small.upcoming-alert .zman-time { color: #fff; text-shadow: 0 0 5px var(--highlight); }

/* Scrollbar styling */
.dynamic-zmanim-grid::-webkit-scrollbar { width: 5px; }
.dynamic-zmanim-grid::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 10px; }
.dynamic-zmanim-grid::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 10px; }

/* 5. Shabbat / Holiday Cards */
.shabbat-container {
  height: 11vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1.5px solid rgba(110, 183, 255, 0.25);
  background: rgba(13, 25, 60, 0.4);
  transition: all 0.4s ease;
}

.shabbat-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex: 1;
}

.shabbat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s ease;
}

.shabbat-label {
  font-size: calc(var(--font-base) * 0.85);
  color: var(--text-muted);
}

.shabbat-val {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.25);
  color: var(--accent);
  margin-top: 0.1rem;
}

.shabbat-countdown {
  border-right: 1px solid var(--card-border);
  border-left: 1px solid var(--card-border);
  padding: 0 0.8rem;
  flex: 1.2;
  text-align: center;
}

.countdown-label {
  font-size: calc(var(--font-base) * 0.8);
  color: var(--text-muted);
}

.countdown-timer {
  font-family: 'Secular One', sans-serif;
  font-size: calc(var(--font-base) * 1.05);
  color: var(--highlight);
  margin-top: 0.1rem;
}

/* Friday & Saturday Night Highlight States */
body.friday-mode #shabbat-card {
  border: 2px solid var(--shabbat-gold) !important;
  background: rgba(60, 45, 10, 0.45) !important;
  box-shadow: 0 0 20px rgba(255, 195, 0, 0.4);
  animation: gentle-glow 3s infinite alternate;
}
body.friday-mode #shabbat-candles-col .shabbat-label {
  color: var(--shabbat-gold);
  font-weight: 800;
}
body.friday-mode #shabbat-candles-col .shabbat-val {
  color: #fff;
  font-size: calc(var(--font-base) * 1.6);
  text-shadow: 0 0 10px var(--shabbat-gold);
}
body.friday-mode #shabbat-havdalah-col, 
body.friday-mode #shabbat-havdalah-rt-col {
  opacity: 0.4;
}

body.motzei-shabbat-mode #shabbat-card {
  border: 2px solid var(--accent) !important;
  background: rgba(10, 45, 60, 0.45) !important;
  box-shadow: 0 0 20px rgba(110, 183, 255, 0.4);
}
body.motzei-shabbat-mode #shabbat-havdalah-col .shabbat-label,
body.motzei-shabbat-mode #shabbat-havdalah-rt-col .shabbat-label {
  color: var(--accent);
  font-weight: 800;
}
body.motzei-shabbat-mode #shabbat-havdalah-col .shabbat-val,
body.motzei-shabbat-mode #shabbat-havdalah-rt-col .shabbat-val {
  color: #fff;
  font-size: calc(var(--font-base) * 1.5);
  text-shadow: 0 0 10px var(--accent);
}
body.motzei-shabbat-mode #shabbat-candles-col {
  opacity: 0.4;
}

/* 6. Bottom Ticker Carousel */
.ticker-container {
  height: 5.5vh;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--card-border);
}

.ticker-title {
  background: var(--card-border);
  color: var(--text-main);
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  font-weight: 800;
  font-size: calc(var(--font-base) * 0.85);
  z-index: 3;
  box-shadow: 5px 0 10px rgba(0,0,0,0.5);
  border-radius: 0 12px 12px 0;
  flex-shrink: 0;
}

.ticker-carousel {
  flex: 1;
  height: 100%;
  position: relative;
}

.ticker-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  font-size: calc(var(--font-base) * 0.95);
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.ticker-slide.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 7. Floating Settings Button */
.settings-trigger {
  position: fixed;
  bottom: 12px;
  left: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  opacity: 0.15;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.settings-trigger:hover { opacity: 1; transform: rotate(45deg); }
.settings-trigger svg { fill: var(--text-muted); width: 18px; height: 18px; }

/* 8. Settings Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  direction: rtl;
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-container {
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111528;
  border: 2px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.modal-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.2);
}

.modal-header h3 { font-family: 'Secular One', sans-serif; color: var(--accent); font-size: 1.15rem; }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }
.modal-close:hover { color: #fff; }

.modal-body {
  padding: 1.2rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 0.8rem;
}

.modal-section h4 { font-size: 0.9rem; color: var(--highlight); font-weight: 600; }
.input-group { display: flex; flex-direction: column; gap: 0.2rem; }
.input-row { display: flex; gap: 0.6rem; }
.input-row .input-group { flex: 1; }
label { font-size: 0.8rem; color: var(--text-muted); }

input[type="text"], select, textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; height: 50px; }

.toggle-group { display: flex; align-items: center; justify-content: space-between; padding: 0.2rem 0; }

/* Switch Slider */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.15);
  transition: .3s; border-radius: 24px;
}
.slider:before {
  position: absolute; content: "";
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* Theme selectors */
.theme-selector { display: flex; gap: 0.4rem; margin-top: 0.1rem; }
.theme-btn {
  flex: 1; height: 28px; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
}
.theme-btn.active { border-color: #fff; box-shadow: 0 0 5px rgba(255,255,255,0.5); }
.btn-navy { background: linear-gradient(to right, #030514, #121845); }
.btn-charcoal { background: linear-gradient(to right, #080808, #202020); }
.btn-emerald { background: linear-gradient(to right, #010603, #0d2e18); }
.btn-royal { background: linear-gradient(to right, #05020c, #251242); }
.btn-burgundy { background: linear-gradient(to right, #0b0203, #3a0d12); }

.modal-footer {
  padding: 0.8rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: rgba(0,0,0,0.2);
}
.btn {
  padding: 0.45rem 1rem; border-radius: 6px;
  font-family: inherit; font-size: 0.9rem;
  cursor: pointer; border: none; font-weight: 600;
}
.btn-primary { background: var(--accent); color: #030514; }
.btn-primary:hover { background: #fff; }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-main); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.4rem;
  border-radius: 8px;
}
.checkbox-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; }

/* Hide Kotel Behavior */
body.hide-kotel .kotel-container { display: none; }

/* Keyframes and Animations */
@keyframes blink { 0% { opacity: 0.3; } 100% { opacity: 1; } }
@keyframes pulse-border {
  0% { border-color: rgba(255, 183, 3, 0.3); box-shadow: 0 0 5px rgba(255, 183, 3, 0.05); }
  100% { border-color: rgba(255, 183, 3, 1); box-shadow: 0 0 12px rgba(255, 183, 3, 0.35); }
}
@keyframes pulse-card {
  0% { transform: scale(1.0); box-shadow: 0 0 8px rgba(255, 183, 3, 0.2); }
  100% { transform: scale(1.015); box-shadow: 0 0 16px var(--alert-glow); }
}
@keyframes gentle-glow {
  0% { box-shadow: 0 0 12px rgba(255, 195, 0, 0.2); }
  100% { box-shadow: 0 0 24px rgba(255, 195, 0, 0.55); }
}
