/*
 * main.css — Base layout, typography, and global styles.
 *
 * @copyright  2026 Karl Dyson
 * @license    Apache-2.0
 * @version    1.0.0
 */

/* ---------------------------------------------------------------------------
   CSS custom properties
   --------------------------------------------------------------------------- */

:root {
  --color-bg:           #f5f5f5;
  --color-surface:      #ffffff;
  --color-border:       #dde1e7;
  --color-text:         #1c1c1e;
  --color-text-muted:   #6e6e73;
  --color-primary:      #0071e3;
  --color-primary-dark: #0058b0;
  --color-danger:       #c0392b;
  --color-success:      #2e7d32;
  --color-warning:      #e67e22;

  /* Status colours */
  --status-maybe:      #e67e22;
  --status-volunteered:#1565c0;
  --status-offered:    #1565c0;
  --status-attending:  #2e7d32;
  --status-attended:   #388e3c;
  --status-withdrawn:  #6e6e73;
  --status-rejected:   #c0392b;
  --status-cancelled:  #9e9e9e;

  /* Clash colours */
  --clash-amber:       #ff8f00;
  --clash-orange:      #e64a19;
  --clash-red:         #b71c1c;

  --nav-height: 3.25rem;
  --panel-width: 460px;
  --radius:      6px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.12);
  --shadow-md:   0 4px 12px rgba(0,0,0,.15);

  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Consolas', monospace;
}

/* ---------------------------------------------------------------------------
   Reset / base
   --------------------------------------------------------------------------- */

/* Enforce the hidden attribute regardless of any display rule set by the
   author stylesheet — without this, display:flex/grid overrides hidden. */
[hidden] { display: none !important; }

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1rem; font-weight: 600; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Navigation bar
   --------------------------------------------------------------------------- */

#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1.5rem;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  color: var(--color-text);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
}

.nav-link.active {
  font-weight: 600;
  color: var(--color-primary);
}

.nav-admin { display: none; }
body.is-admin .nav-admin { display: inline-flex; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   App view container
   --------------------------------------------------------------------------- */

#view-app {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.app-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ---------------------------------------------------------------------------
   Login / auth screens
   --------------------------------------------------------------------------- */

#view-login,
#view-reset-request,
#view-reset-confirm {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------------
   Calendar grid
   --------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.toolbar-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.season-counters {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.season-counters strong {
  font-size: 1.1rem;
  color: var(--color-text);
}

#calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 2.5rem;
}

.cal-date {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  white-space: nowrap;
}

.cal-date.is-weekend { background: #f0f4ff; }
.cal-date.is-bankholiday { background: #fff8e1; }

.cal-date .dow { font-size: 0.7rem; color: var(--color-text-muted); }

/* Clash indicators on the date cell */
.cal-row.clash-amber .cal-date { border-left: 3px solid var(--clash-amber); }
.cal-row.clash-orange .cal-date { border-left: 3px solid var(--clash-orange); }
.cal-row.clash-red    .cal-date { border-left: 3px solid var(--clash-red); }

.cal-events {
  padding: 0.3rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.cal-event-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.1s;
}

.cal-event-chip:hover { filter: brightness(0.92); }

.cal-row-add-btn {
  opacity: 0;
  transition: opacity 0.1s;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.4rem;
  color: var(--color-text-muted);
}
.cal-row:hover .cal-row-add-btn { opacity: 1; }

/* Chip colours by status */
.chip-none         { background: #e8eaed; color: #444; border-color: #d0d0d0; }
.chip-maybe        { background: #fff3e0; color: #bf360c; border-color: var(--status-maybe); }
.chip-volunteered,
.chip-offered      { background: #e3f2fd; color: #0d47a1; border-color: var(--status-volunteered); }
.chip-attending,
.chip-attended     { background: #e8f5e9; color: #1b5e20; border-color: var(--status-attending); }
.chip-withdrawn    { background: #f5f5f5; color: #616161; border-color: #bdbdbd; }
.chip-rejected     { background: #ffebee; color: #b71c1c; border-color: var(--status-rejected); }
.chip-cancelled    { background: #f5f5f5; color: #9e9e9e; border-color: #d0d0d0; }

/* ---------------------------------------------------------------------------
   Statistics
   --------------------------------------------------------------------------- */

#stats-grid,
#admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.chart-card h3 {
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-card-full {
  grid-column: 1 / -1;
}

/* ---------------------------------------------------------------------------
   Side panel
   --------------------------------------------------------------------------- */

.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--panel-width);
  max-width: 100vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.side-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.panel-header h2 { margin: 0; font-size: 1rem; }

#panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

#panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 190;
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */

footer,
.page-footer {
  margin-top: 3rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Toast notification
   --------------------------------------------------------------------------- */

#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1e;
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: 99px;
  font-size: 0.9rem;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#toast.visible { opacity: 1; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 600px) {
  .cal-row { grid-template-columns: 80px 1fr; }
  .cal-date { font-size: 0.72rem; padding: 0.4rem; }
  .side-panel { width: 100vw; }
}
