:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e0e0e0;
  --accent-color: #2e7d32;
  --accent-light: #e8f5e9;
  --shabbat-color: #1565c0;
  --shabbat-bg: #e3f2fd;
  --holiday-color: #c62828;
  --holiday-bg: #ffebee;
  --rosh-chodesh-color: #6a1b9a;
  --rosh-chodesh-bg: #f3e5f5;
  --today-highlight: #ffd54f;
  --today-highlight-bg: #fff8e1;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --font-hebrew: 'Times New Roman', 'David', 'Arial', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1f2937;
  --text-primary: #e5e5e5;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --border-color: #374151;
  --accent-color: #4ade80;
  --accent-light: #1e3a2f;
  --shabbat-color: #60a5fa;
  --shabbat-bg: #1e3a5f;
  --holiday-color: #f87171;
  --holiday-bg: #3f1f1f;
  --rosh-chodesh-color: #c084fc;
  --rosh-chodesh-bg: #2f1f3f;
  --today-highlight: #fbbf24;
  --today-highlight-bg: #3f3020;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
}

.title-en {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.title-he {
  font-family: var(--font-hebrew);
  direction: rtl;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
}

.current-month {
  font-size: 1.25rem;
  font-weight: 600;
  min-width: 200px;
  text-align: center;
  font-family: var(--font-hebrew);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
}

.control-btn.small {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.control-btn.icon-btn {
  padding: 0.5rem;
  font-size: 1.25rem;
  min-width: 40px;
}

.location-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.location-label {
  color: var(--text-muted);
}

.location-name {
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .main {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    order: -1;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav {
    justify-content: center;
  }
  
  .controls {
    justify-content: center;
  }
  
  .location-display {
    justify-content: center;
  }
}

.calendar-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.day-header {
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.day-header:last-child {
  color: var(--shabbat-color);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-cell {
  min-height: 100px;
  padding: 0.5rem;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  transition: background-color 0.2s ease;
}

.calendar-cell:nth-child(7n) {
  border-right: none;
}

.calendar-cell:hover {
  background: var(--bg-secondary);
}

.calendar-cell.other-month {
  opacity: 0.4;
}

.calendar-cell.today {
  background: var(--today-highlight-bg);
}

.calendar-cell.today .day-number {
  background: var(--today-highlight);
  color: #000;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-cell.shabbat {
  background: var(--shabbat-bg);
}

.calendar-cell.shabbat .day-number {
  color: var(--shabbat-color);
  font-weight: 700;
}

.calendar-cell.holiday {
  background: var(--holiday-bg);
}

.calendar-cell.rosh-chodesh {
  background: var(--rosh-chodesh-bg);
}

.day-number {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.hebrew-date {
  font-family: var(--font-hebrew);
  font-size: 0.75rem;
  direction: rtl;
  color: var(--text-secondary);
  line-height: 1.3;
}

.hebrew-date .month {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.cell-events {
  margin-top: 0.25rem;
}

.cell-event {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-event.shabbat {
  background: var(--shabbat-color);
  color: white;
}

.cell-event.holiday {
  background: var(--holiday-color);
  color: white;
}

.cell-event.rosh-chodesh {
  background: var(--rosh-chodesh-color);
  color: white;
}

.cell-event.omer {
  background: #ff9800;
  color: white;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.today-card, .week-parasha {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.today-date {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.today-hebrew {
  font-family: var(--font-hebrew);
  font-size: 1.25rem;
  direction: rtl;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.today-holidays {
  margin-bottom: 1rem;
}

.today-holidays .holiday-item {
  display: inline-block;
  background: var(--holiday-bg);
  color: var(--holiday-color);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  margin: 0.125rem;
}

.today-times {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.today-times .time-item {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border-color);
}

.today-times .time-item:last-child {
  border-bottom: none;
}

.today-times .time-label {
  color: var(--text-muted);
}

.today-times .time-value {
  font-weight: 600;
}

.parasha-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.parasha-hebrew {
  font-family: var(--font-hebrew);
  font-size: 1rem;
  direction: rtl;
  color: var(--accent-color);
}

.location-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.location-modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-hover);
}

.modal-content h3 {
  margin-bottom: 1rem;
}

.modal-content input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.location-results {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.location-result {
  padding: 0.75rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.2s ease;
}

.location-result:hover {
  background: var(--bg-secondary);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent-color);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .calendar-cell {
    min-height: 70px;
    padding: 0.25rem;
  }
  
  .day-number {
    font-size: 0.75rem;
  }
  
  .hebrew-date {
    font-size: 0.625rem;
  }
  
  .cell-event {
    font-size: 0.5rem;
  }
  
  .day-header {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
}

[lang="he"] body,
[dir="rtl"] body {
  direction: rtl;
}

[lang="he"] .day-header:first-child,
[dir="rtl"] .day-header:first-child {
  color: var(--shabbat-color);
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Region Toggle */
.region-toggle {
  display: flex;
  gap: 0.25rem;
}

.region-btn {
  padding: 0.375rem 0.5rem !important;
  font-size: 0.7rem !important;
  min-width: 50px;
}

.region-btn.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* Event Indicator */
.event-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--holiday-color);
  border-radius: 50%;
}

.calendar-cell.major-event .event-indicator {
  background: var(--accent-color);
  width: 10px;
  height: 10px;
}

/* Event Modal */
.event-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.event-modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.event-modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-close:hover {
  color: var(--text-primary);
}

.event-list {
  margin-top: 1rem;
}

.event-item {
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--bg-secondary);
}

.event-item.majorholiday {
  border-left: 3px solid var(--accent-color);
}

.event-item.minorholiday {
  border-left: 3px solid var(--holiday-color);
}

.event-item.fast {
  border-left: 3px solid #ff9800;
}

.event-item.memorial {
  border-left: 3px solid #9c27b0;
}

.event-item.special {
  border-left: 3px solid #2196f3;
}

.event-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.event-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.event-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.no-events {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Calendar Cell Click */
.calendar-cell {
  cursor: pointer;
}

.calendar-cell:hover {
  background: var(--accent-light);
}

/* Android Promo Box */
.android-promo {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

[data-theme="light"] .android-promo {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.promo-icon {
  flex-shrink: 0;
}

.promo-icon svg {
  width: 40px;
  height: 40px;
}

.promo-content {
  flex: 1;
  min-width: 0;
}

.promo-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
}

[data-theme="light"] .promo-title {
  color: var(--text-primary);
}

.promo-desc {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 0.125rem;
}

[data-theme="light"] .promo-desc {
  color: var(--text-secondary);
}

.promo-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: #3DDC84;
  color: #1a1a2e;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.promo-btn:hover {
  transform: scale(1.05);
}

.promo-btn svg {
  width: 16px;
  height: 16px;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .android-promo {
    flex-wrap: wrap;
    text-align: center;
    justify-content: center;
  }
  
  .promo-content {
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
  }
  
  .promo-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Practices in Modal */
.event-practices {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.practices-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 0.75rem;
}

.practice-time-group {
  margin-bottom: 0.75rem;
}

.practice-time-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}

.practice-item {
  padding: 0.5rem;
  background: var(--bg-primary);
  border-radius: var(--radius);
  margin-bottom: 0.375rem;
  border-left: 3px solid var(--border-color);
}

.practice-item.obligatory {
  border-left-color: var(--accent-color);
}

.practice-item.customary {
  border-left-color: var(--text-muted);
}

.practice-badge {
  display: inline-block;
  font-size: 0.6rem;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.practice-badge.obligatory {
  background: var(--accent-light);
  color: var(--accent-color);
}

.practice-badge.customary {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.practice-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.practice-instruction {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.practice-applies {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-style: italic;
}
