/* =====================================================================
   Campground Calendar Widget Styles
   All selectors are scoped under .cgcal-widget and use a "cgcal-" class
   prefix to avoid collisions with host-site / theme CSS.
   ===================================================================== */

.cgcal-widget {
  --cgcal-available: #6faf5c;
  --cgcal-pending: #f0c04a;
  --cgcal-booked: #d9534f;
  --cgcal-past: #efefe9;
  --cgcal-header-bg: #2f8fa8;
  --cgcal-header-text: #ffffff;
  --cgcal-border: #e2e2e2;
  --cgcal-text: #3a3a3a;
  --cgcal-muted-text: #8a8a8a;

  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--cgcal-text);
  max-width: 900px;
  margin: 0 auto;
}

.cgcal-widget *,
.cgcal-widget *::before,
.cgcal-widget *::after {
  box-sizing: border-box;
}

/* --- Header / month navigation -------------------------------------- */

.cgcal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cgcal-header-bg);
  color: var(--cgcal-header-text);
  padding: 12px 18px;
  border-radius: 4px 4px 0 0;
}

.cgcal-header-title {
  font-size: 1.1em;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

.cgcal-nav-link {
  color: var(--cgcal-header-text);
  text-decoration: none;
  font-size: 0.95em;
  white-space: nowrap;
  opacity: 0.9;
}

.cgcal-nav-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.cgcal-nav-disabled {
  color: var(--cgcal-header-text);
  opacity: 0.35;
  font-size: 0.95em;
  white-space: nowrap;
}

.cgcal-site-title {
  padding: 10px 18px 0 18px;
  font-size: 1.15em;
  font-weight: 600;
}

/* --- Site (single-site, week-number) calendar ------------------------ */

.cgcal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.cgcal-table th,
.cgcal-table td {
  border: 1px solid var(--cgcal-border);
  padding: 0;
}

.cgcal-table thead th {
  padding: 8px 4px;
  font-weight: 500;
  font-size: 0.85em;
  color: var(--cgcal-muted-text);
  text-align: center;
  background: #fafafa;
}

.cgcal-week-num-cell {
  text-align: center;
  font-size: 0.85em;
  color: var(--cgcal-muted-text);
  background: #fafafa;
  vertical-align: middle;
}

.cgcal-day-cell {
  position: relative;
  height: 64px;
  vertical-align: top;
}

.cgcal-day-cell-empty {
  background: #fbfbf9;
}

.cgcal-day-num {
  position: relative;
  z-index: 2;
  display: inline-block;
  padding: 6px 8px;
  font-weight: 600;
  font-size: 0.95em;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.cgcal-day-num-muted {
  color: #6b6b63;
  text-shadow: none;
}

.cgcal-half {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.cgcal-half-am {
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.cgcal-half-pm {
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.cgcal-status-available { background-color: var(--cgcal-available); }
.cgcal-status-pending   { background-color: var(--cgcal-pending); }
.cgcal-status-booked    { background-color: var(--cgcal-booked); }
.cgcal-status-past      { background-color: var(--cgcal-past); }

/* --- Legend ----------------------------------------------------------- */

.cgcal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 18px;
  font-size: 0.9em;
  border-top: 1px solid var(--cgcal-border);
}

.cgcal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cgcal-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

/* --- All-sites overview grid ------------------------------------------ */

/* The single-site widget stays a comfortable reading width (900px), but
   the overview grid needs all the horizontal room it can get so every day
   column stays legible without scrolling — let it fill its container. */
.cgcal-all-sites-widget {
  max-width: none;
}

.cgcal-grid-wrap {
  overflow-x: auto; /* fallback only; table-layout:fixed below normally
                        makes this a non-issue */
  border: 1px solid var(--cgcal-border);
  border-top: none;
}

.cgcal-grid-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed; /* forces the table to fit the container; day columns
                           share whatever width is left after the site column,
                           so all days fit with no horizontal scrollbar */
}

.cgcal-grid-table th,
.cgcal-grid-table td {
  border: 1px solid var(--cgcal-border);
}

.cgcal-grid-site-header,
.cgcal-grid-site-name {
  width: 20%;
  max-width: 0; /* combined with table-layout:fixed, forces truncation to the % width above */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cgcal-grid-site-header {
  text-align: left;
  padding: 8px 8px;
  font-size: 0.8em;
  color: var(--cgcal-muted-text);
  background: #fafafa;
  position: sticky;
  left: 0;
  z-index: 3;
}

/* Day columns get no explicit width, so table-layout:fixed divides the
   remaining space after the site column equally between them, however
   many days are in the month (28-31). */
.cgcal-grid-day-header {
  text-align: center;
  padding: 5px 1px;
  font-size: 0.72em;
  font-weight: 500;
  background: var(--cgcal-header-bg);
  color: var(--cgcal-header-text);
}

.cgcal-grid-site-name {
  padding: 8px 8px;
  font-size: 0.85em;
  background: #fff;
  position: sticky;
  left: 0;
  z-index: 2;
}

.cgcal-grid-day-cell {
  position: relative;
  height: 28px;
  padding: 0;
}

/* Safety net only: if the widget is squeezed into a very narrow container
   (e.g. a small mobile screen) columns would become illegibly thin, so
   below that point we fall back to the widget's original scrolling grid
   instead of shrinking further. */
@media (max-width: 480px) {
  .cgcal-grid-table {
    table-layout: auto;
    min-width: 700px;
  }

  .cgcal-grid-site-header,
  .cgcal-grid-site-name {
    width: auto;
    max-width: 160px;
  }

  .cgcal-grid-day-header,
  .cgcal-grid-day-cell {
    min-width: 26px;
  }
}

.cgcal-grid-table .cgcal-half {
  z-index: 1;
}

/* --- Empty state -------------------------------------------------------- */

.cgcal-error {
  padding: 16px 18px;
  color: #a13a37;
  background: #fbeaea;
  border: 1px solid #eccaca;
  border-radius: 4px;
}
