* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1a1a1a;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.hdr-btn {
  display: inline-block;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ccc;
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
  border: 1px solid #555;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.hdr-btn:hover {
  background: linear-gradient(180deg, #4a4a4a 0%, #353535 100%);
  color: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
}
.hdr-btn:active {
  background: #222;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.hdr-btn-active {
  border-bottom: 2px solid #66d9ff;
  color: #fff;
}
.hdr-btn-glow {
  background: linear-gradient(180deg, #2b7042 0%, #1a4a2a 100%);
  border-color: #3a8a52;
  color: #d0ffd0;
  box-shadow: 0 0 8px rgba(43,112,66,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}
.hdr-btn-glow:hover {
  background: linear-gradient(180deg, #358a50 0%, #245a35 100%);
  color: #fff;
  box-shadow: 0 0 12px rgba(43,112,66,0.6), inset 0 1px 0 rgba(255,255,255,0.15);
}

.hdr-icon {
  cursor: pointer;
  font-size: 1.3rem;
  margin-left: 8px;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.hdr-icon:hover { opacity: 1; }

main {
  overflow: auto;
  height: calc(100vh - 60px);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
main::-webkit-scrollbar { display: none; }

.calendar-scroll {
  padding: 1rem;
  min-height: min-content;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
}

@media (max-width: 600px) {
  .hide-mobile {
    display: none;
  }
}

/* Month separator row */
.month-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  border-top: 3px solid #b8960c;
}

.month-row:first-of-type {
  margin-top: 0;
  border-top: none;
}

.month-label {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffd700;
  min-width: 140px;
}

.month-bar {
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, #b8960c 0%, transparent 100%);
  border-radius: 2px;
}

/* Month nav strip — lives inside header as 2nd row */
.month-nav {
  display: flex;
  gap: 2px;
  padding: 4px 1rem;
  background: rgba(15, 15, 15, 0.6);
  border-top: 1px solid #333;
  overflow-x: auto;
  justify-content: flex-start;
  width: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.month-nav::-webkit-scrollbar { display: none; }

/* Hide scrollbars on calendar */
.calendar-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.calendar-scroll::-webkit-scrollbar { display: none; }
.month-nav a {
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #667;
  text-decoration: none;
  border-radius: 3px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}
.month-nav a:hover { color: #aaa; background: rgba(255,255,255,0.05); }
.month-nav a.active {
  color: var(--c-month-text, #66d9ff);
  background: rgba(102, 217, 255, 0.1);
  box-shadow: 0 0 6px rgba(102, 217, 255, 0.2);
}
.month-nav a.muted { opacity: 0.5; }

/* Day cell layout */
.day-row {
  display: contents;
}

.day-cell {
  display: flex;
  flex-direction: column;
  min-height: 120px;
  min-width: 0;
}

/* Date row on top */
.date-row {
  flex-shrink: 0;
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  border-top: 1px solid #333;
  border-bottom: 1px solid #222;
  border-left: 1px solid #333;
  background: #151515;
}

.date-num {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  white-space: nowrap;
}

/* Today highlight */
.day-cell.is-today .date-row {
  background: #1a1a1a !important;
  border-bottom: 3px solid #ffd700 !important;
}
.day-cell.is-today .date-num {
  color: #ffd700 !important;
  font-weight: 800 !important;
}
.day-cell.is-today {
  box-shadow: none;
}

/* Villa areas below date row */
.villa-areas {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr 1fr minmax(0, 0.4fr);
  min-width: 0;
}
.villa-areas::after {
  content: '';
  grid-row: 4;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  border-left: 1px solid #333;
}

/* Common Villa Section Rules base */
.villa-section {
  box-sizing: border-box;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  min-height: 22px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border-left: 1px solid #333;
}

.villa-section.occupied:not(.transition-in):not(.transition-both) {
  border-left-color: transparent;
}

.villa-section.empty {
  background: transparent;
}
.villa-section.occupied {
  color: #fff;
  padding-left: 14px;
}

.label-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--c-label-size, 0.7rem);
}

.edit-icon {
  margin-left: 8px;
  font-size: 0.85em;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.villa-section:hover .edit-icon {
  opacity: 1;
}

.add-icon {
  opacity: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.2em; /* Permanent large size instead of hover size */
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.2s, background-color 0.2s;
}
.villa-section.empty:hover .add-icon {
  color: rgba(255, 255, 255, 0.8);
  background-color: #111828;
}
/* Ensure text aligns securely inside the colored halves on transition days */
.villa-section.occupied.transition-in,
.villa-section.occupied.transition-both {
  padding-left: calc(50% + 6px);
}
.villa-section.occupied.transition-out {
  padding-right: calc(50% + 6px);
}

/* z-index mgmt for spanning text */
.villa-section.z-cover { z-index: 3; }
.villa-section.z-label { z-index: 2; overflow: visible !important; }
.villa-section.z-cont { z-index: 1; color: transparent; }

/* ====================================================
   CSS VARIABLES FOR DEV THEME CONFIG
   ==================================================== */
:root {
  --c-v1-bg: #3273b3;
  --c-v1-text: #ffffff;
  --c-v1-stripe: #057e80;
  --c-v2-bg: #936a0b;
  --c-v2-text: #ffffff;
  --c-v2-stripe: #938a66;
  --c-v3-bg: #31aa52;
  --c-v3-text: #ffffff;
  --c-v3-stripe: #005726;

  --c-border: #333333;

  --c-checkout-bg: #322f2f;
  --c-checkout-text: #7e7c7c;
  --c-checkout-stripe: #857a7a;

  --c-audit-bg: #32280c;
  --c-audit-text: #928787;
  --c-audit-stripe: transparent;

  --c-inquiry-bg: #1a1a1a;
  --c-inquiry-text: #ffffff;
  --c-inquiry-stripe: #cc2222;

  --c-expired-bg: #5a2d2d;
  --c-expired-text: #aaaaaa;

  --c-benny-bg: #891f1f;
  --c-benny-text: #ffffff;
  --c-benny-stripe: #dd6482;

  --c-checkedin-bg: #45fd12;
  --c-checkedin-text: #d3f8d5;
  --c-checkedin-stripe: #c2ffce;
  --c-clash-outline: #cc2222;
  --c-month-text: #85e0ff;
  --c-month-bar: #66d9ff;
  --c-label-size: 0.75rem;
}

/* Stripe rendering via --cell-stripe var (set inline by JS) */
/* Mid cells (both z-cont AND z-label on Sundays) — no transitions */
.villa-section.occupied:not(.transition-in):not(.transition-out):not(.transition-both) {
  border-top: 3px solid var(--cell-stripe, transparent);
  border-bottom: 3px solid var(--cell-stripe, transparent);
}
/* Transition-in: stripe on the incoming (right) half */
.villa-section.occupied.transition-in::after {
  border-top: 3px solid var(--cell-stripe, transparent);
  border-bottom: 3px solid var(--cell-stripe, transparent);
}
/* Transition-out: stripe on the outgoing (left) half */
.villa-section.occupied.transition-out::before {
  border-top: 3px solid var(--left-stripe, var(--cell-stripe, transparent));
  border-bottom: 3px solid var(--left-stripe, var(--cell-stripe, transparent));
}
/* Transition-both: left half uses left-stripe, right half uses cell-stripe */
.villa-section.occupied.transition-both::before {
  border-top: 3px solid var(--left-stripe, transparent);
  border-bottom: 3px solid var(--left-stripe, transparent);
}
.villa-section.occupied.transition-both::after {
  border-top: 3px solid var(--cell-stripe, transparent);
  border-bottom: 3px solid var(--cell-stripe, transparent);
}

.day-cell { border-right: 1px solid var(--c-border); }
.day-cell:last-child { border-right: none; }

/* ====================================================
   ROUNDED PILLS STYLING (Default)
   ==================================================== */
.villa-section.occupied { margin-top: 3px; margin-bottom: 3px; border-radius: 0; }

.villa-1.occupied { --cell-bg: var(--c-v1-bg); --cell-text: var(--c-v1-text); background: var(--cell-bg); color: var(--cell-text); }
.villa-2.occupied { --cell-bg: var(--c-v2-bg); --cell-text: var(--c-v2-text); background: var(--cell-bg); color: var(--cell-text); }
.villa-3.occupied { --cell-bg: var(--c-v3-bg); --cell-text: var(--c-v3-text); background: var(--cell-bg); color: var(--cell-text); }

.villa-section.occupied.transition-in { background: transparent !important; }
.villa-section.occupied.transition-in::after {
  content: ''; position: absolute; top:0; bottom:0; left: 50%; right: 0;
  border-top-left-radius: 12px; border-bottom-left-radius: 12px;
  background: var(--right-bg, var(--cell-bg));
  z-index: -1;
}

.villa-section.occupied.transition-out { background: transparent !important; }
.villa-section.occupied.transition-out::before {
  content: ''; position: absolute; top:0; bottom:0; left: -1px; right: 50%;
  border-top-right-radius: 12px; border-bottom-right-radius: 12px;
  background: var(--left-bg, var(--cell-bg));
  z-index: -1;
}

.villa-section.occupied.transition-both { background: transparent !important; }
.villa-section.occupied.transition-both::before,
.villa-section.occupied.transition-both::after {
  content: ''; position: absolute; top:0; bottom:0; z-index: -1;
}
.villa-section.occupied.transition-both::before { left:-1px; right: 52%; border-radius: 0 12px 12px 0; background: var(--left-bg, var(--cell-bg)); }
.villa-section.occupied.transition-both::after { right:0; left: 52%; border-radius: 12px 0 0 12px; background: var(--right-bg, var(--cell-bg)); }

/* Custom Tooltip */
.custom-tooltip {
  position: fixed;
  background: #1a2540;
  color: #fff;
  padding: 8px 12px;
  border: 1px solid #2888cc;
  border-radius: 4px;
  font-size: 1.25rem;
  font-weight: 600;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.custom-tooltip.visible {
  opacity: 1;
}

/* Clash indicator in date header */
.clash-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ff0000;
  animation: clash-pulse 1.5s infinite;
  vertical-align: middle;
  margin-left: 2px;
}
.clash-villas {
  font-size: 0.6rem;
  font-weight: 700;
  color: #ff4444;
  margin-left: 1px;
}
@keyframes clash-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.login-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #111;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #222;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 3rem 2.5rem;
  text-align: center;
  min-width: 320px;
}
.login-card h2 {
  margin: 0 0 0.5rem;
  color: #2b7042;
  font-size: 1.8rem;
  letter-spacing: 2px;
}
.login-card p {
  color: #888;
  margin: 0 0 2rem;
  font-size: 0.9rem;
}

/* ====================================================
   PUBLIC CALENDAR — per-cell text display
   ==================================================== */
.pub-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default !important;
  border-radius: 0;
  margin: 1px 0;
}
.pub-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Available + pending: villa-colored bg, bright text */
.villa-1.pub-available, .villa-1.pub-pending { background: var(--c-v1-bg); color: var(--c-v1-text); }
.villa-2.pub-available, .villa-2.pub-pending { background: var(--c-v2-bg); color: var(--c-v2-text); }
.villa-3.pub-available, .villa-3.pub-pending { background: var(--c-v3-bg); color: var(--c-v3-text); }
.pub-pending { opacity: 0.6; }
/* Reserved: muted */
.pub-reserved { background: #222; }
.pub-muted { color: #444; font-weight: 400; font-size: 0.8rem; }
/* Legend pills (inline in pub-nav) */
.pub-legend-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.pub-legend-pill:hover { opacity: 1; }
