/* CSS Variables for Premium Theme */
:root {
  --primary-color: #1e3a8a;       /* Elegant Royal Blue */
  --primary-hover: #1d4ed8;
  --secondary-color: #2563eb;
  --bg-color: #f8fafc;            /* Soft slate background */
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  --holiday-bg: #fef2f2;          /* Soft red */
  --holiday-text: #dc2626;
  --holiday-border: #fca5a5;
  
  --event-bg: #eff6ff;            /* Soft blue */
  --event-text: #2563eb;
  --event-border: #93c5fd;
  
  --holy-gold: #d97706;           /* Amber/Gold for Thgai Seil */
  
  --selected-bg: #dbeafe;         /* Light blue for selection */
  --selected-text: #1e40af;
  --selected-border: #3b82f6;
  
  --data-available-bg: #f0f9ff;   /* Very light blue for data available */
  --data-available-text: #0369a1;
  --data-available-border: #0ea5e9;
  
  --font-title: 'Moul', 'Hanuman', serif;
  --font-body: 'Nokora', 'Hanuman', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-dark);
  line-height: 1.5;
  padding-bottom: 2rem;
}

a {
  text-decoration: none;
  color: inherit;
}

button, select {
  font-family: inherit;
  cursor: pointer;
}

/* Header & Navigation */
header {
  background: var(--card-bg);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

@media(min-width: 768px) {
  .nav-container {
    flex-direction: row;
  }
}

.logo-section h1 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--primary-color);
  font-weight: bold;
  letter-spacing: 0.5px;
  text-align: center;
}

@media(min-width: 768px) {
  .logo-section h1 {
    font-size: 1.5rem;
    text-align: left;
  }
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}

.nav-links li {
  font-weight: bold;
}

.nav-links button {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: all 0.2s ease-in-out;
}

.nav-links button:hover {
  background-color: #f1f5f9;
  color: var(--primary-color);
}

.nav-links button.active {
  background-color: var(--primary-color);
  color: #ffffff;
}

/* Main Layout Grid */
.main-wrapper {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.dashboard-layout {
  display: flex;
  flex-direction: column-reverse;
  gap: 1.5rem;
}

@media(min-width: 1024px) {
  .dashboard-layout {
    flex-direction: row;
    align-items: flex-start;
  }
}

.left-panel {
  width: 100%;
}

@media(min-width: 1024px) {
  .left-panel {
    width: 66.666%;
    flex-shrink: 0;
  }
}

.right-panel {
  width: 100%;
}

/* Dropdown Filters */
.filters-bar {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

@media(min-width: 640px) {
  .filters-bar {
    flex-direction: row;
    justify-content: center;
  }
}

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

.filter-group label {
  font-weight: bold;
  color: var(--text-dark);
  font-size: 0.95rem;
}

.filter-group select {
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  border-radius: 0.375rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.25em;
}

.filter-group select:focus {
  border-color: var(--primary-color);
}

.btn-nav-arrow {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.375rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-nav-arrow:hover {
  background-color: #e2e8f0;
  color: var(--text-dark);
}

.btn-nav-arrow svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

/* Calendar Card Container */
.calendar-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}

/* Header Info (Traditional + Solar Month Titles) */
.calendar-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.khmer-era-info {
  text-align: left;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--primary-color);
  line-height: 1.3;
}

.month-year-titles {
  text-align: center;
  flex-grow: 1;
}

.month-year-titles h2.kh-month-title {
  font-size: 1.15rem;
  font-family: var(--font-title);
  color: var(--text-dark);
  font-weight: bold;
}

.month-year-titles h3.solar-month-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.month-reset-section {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-reset-dot {
  width: 0.75rem;
  height: 0.75rem;
  background-color: #cbd5e1;
  border: none;
  border-radius: 9999px;
  transition: all 0.2s;
}

.btn-reset-dot:hover {
  background-color: var(--primary-color);
  transform: scale(1.2);
}

/* Weekday Grid */
.weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.weekday-cell {
  font-family: var(--font-body);
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--text-dark);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.weekday-cell:first-child {
  color: #dc2626; /* Sunday highlight */
  background-color: var(--holiday-bg);
  border-color: var(--holiday-border);
  border-radius: 0.375rem;
}

/* Calendar Days Grid */
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.day-cell {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  aspect-ratio: 10 / 8.5;
  padding: 0.375rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.02);
}

.day-cell:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 10;
}

.day-cell.day-padding {
  opacity: 0.3;
  background-color: #f1f5f9;
  cursor: default;
}

.day-cell.day-padding:hover {
  transform: none;
  box-shadow: none;
}

.day-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.solar-day-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
}

@media(min-width: 768px) {
  .solar-day-num {
    font-size: 1.5rem;
  }
}

.lunar-day-info {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.2;
}

@media(min-width: 768px) {
  .lunar-day-info {
    font-size: 0.8rem;
  }
}

.day-cell-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  margin-top: auto;
}

.lunar-month-name-indicator {
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--secondary-color);
}

.holy-day-badge {
  display: flex;
  align-items: center;
  justify-content: center;
}

.holy-day-icon {
  width: 1rem;
  height: 1rem;
  object-fit: contain;
}

@media(min-width: 768px) {
  .holy-day-icon {
    width: 1.25rem;
    height: 1.25rem;
  }
}

/* Day Highlight Classes */
.bg-red-light {
  background-color: var(--holiday-bg) !important;
}
.text-red-dark {
  color: var(--holiday-text) !important;
}
.border-red-medium {
  border-color: var(--holiday-border) !important;
}

.bg-blue-light {
  background-color: var(--event-bg) !important;
}
.text-blue-dark {
  color: var(--event-text) !important;
}
.border-blue-medium {
  border-color: var(--event-border) !important;
}

.bg-today {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  color: #ffffff !important;
  border-color: #1d4ed8 !important;
}

.bg-today .solar-day-num,
.bg-today .lunar-day-info,
.bg-today .lunar-month-name-indicator {
  color: #ffffff !important;
}

.day-cell-weekend:not(.day-padding):not(.bg-today) .solar-day-num {
  color: #dc2626; /* Sundays/Saturdays red color */
}

/* Sunday light red background highlight (entire column) */
.day-cell.sunday {
  background-color: var(--holiday-bg) !important;
  color: var(--holiday-text) !important;
  border-color: var(--holiday-border) !important;
}

.day-cell.sunday .solar-day-num,
.day-cell.sunday .lunar-day-info,
.day-cell.sunday .lunar-month-name-indicator {
  color: var(--holiday-text) !important;
}

/* Holidays Timeline List (Right Panel) */
.holidays-list-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}

.holidays-list-card h2 {
  font-family: var(--font-title);
  color: var(--primary-color);
  font-size: 1.2rem;
  border-bottom: 2px solid #eff6ff;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.timeline {
  position: relative;
  border-left: 2px solid var(--border-color);
  list-style: none;
  padding-left: 1rem;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
  transition: all 0.2s;
  cursor: pointer;
}

.timeline-item:hover {
  transform: translateX(4px);
}

.timeline-empty {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.timeline-empty span {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.75;
}

.timeline-dot {
  position: absolute;
  left: -1.375rem; /* center on the 2px line */
  top: 0.375rem;
  width: 0.625rem;
  height: 0.625rem;
  background-color: #cbd5e1;
  border: 2px solid #ffffff;
  border-radius: 9999px;
}

.timeline-item.holiday-red .timeline-dot {
  background-color: var(--holiday-text);
}

.timeline-item.event-blue .timeline-dot {
  background-color: var(--event-text);
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.timeline-title-kh {
  font-size: 0.95rem;
  font-weight: bold;
  font-family: var(--font-body);
}

.timeline-item.holiday-red .timeline-title-kh {
  color: var(--holiday-text);
}

.timeline-item.event-blue .timeline-title-kh {
  color: var(--event-text);
}

.timeline-title-en {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Modal Popup Window */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-content {
  background: #ffffff;
  border-radius: 1rem;
  width: 90%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.btn-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background-color: #f1f5f9;
  border: none;
  color: #dc2626;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  z-index: 10;
}

.btn-modal-close:hover {
  background-color: #fee2e2;
}

.btn-modal-close svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body h4.modal-solar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.modal-lunar-date {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--primary-color);
  font-weight: bold;
  background-color: #eff6ff;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  display: inline-block;
  margin-bottom: 1rem;
}

.modal-attributes-list {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  list-style: none;
}

.modal-attribute-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.modal-attribute-item.text-red-600 {
  color: var(--holiday-text);
  font-weight: bold;
}

.modal-attribute-bullet {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background-color: #cbd5e1;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.modal-attribute-item.text-red-600 .modal-attribute-bullet {
  background-color: var(--holiday-text);
}

/* Khmer Lunar Table Page */
.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}

.table-header-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.table-header-bar label {
  font-weight: bold;
  font-size: 1rem;
}

.table-header-bar select {
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  border-radius: 0.375rem;
  padding: 0.5rem 1.5rem 0.5rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
}

.table-responsive-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.table-responsive-container table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.9rem;
  white-space: nowrap;
}

.table-responsive-container th,
.table-responsive-container td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.table-responsive-container th {
  background-color: #f8fafc;
  color: var(--text-dark);
  font-weight: bold;
}

.table-responsive-container tbody tr:hover td {
  background-color: #f1f5f9;
}

.row-new-month td {
  background-color: #f0fdf4 !important;
  color: #15803d;
  font-weight: bold;
}

.loading-pulse-row td {
  background-color: #f1f5f9;
  color: var(--text-muted);
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Author Page */
.author-card {
  max-width: 500px;
  margin: 2rem auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
  text-align: center;
}

.author-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-dark);
}

.credits-list {
  list-style: none;
  text-align: left;
}

.credit-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.credit-item:last-child {
  border-bottom: none;
}

.credit-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.375rem;
  object-fit: contain;
  background-color: #f1f5f9;
}

.credit-info {
  flex-grow: 1;
}

.credit-info p {
  font-weight: bold;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.credit-info a {
  font-size: 0.8rem;
  color: var(--secondary-color);
  word-break: break-all;
}

.credit-info a:hover {
  text-decoration: underline;
}

/* Footer styling */
footer {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  margin-top: 3rem;
}
