/* Busy or Not? — design tokens & components */

:root {
  --background: 40 24% 97%;
  --foreground: 24 20% 12%;
  --card: 0 0% 100%;
  --card-foreground: 24 20% 12%;
  --primary: 16 85% 52%;
  --primary-foreground: 0 0% 100%;
  --secondary: 36 20% 93%;
  --secondary-foreground: 24 20% 18%;
  --muted: 36 18% 92%;
  --muted-foreground: 24 10% 42%;
  --accent: 16 70% 95%;
  --accent-foreground: 16 70% 30%;
  --destructive: 0 72% 48%;
  --destructive-foreground: 0 0% 100%;
  --border: 32 14% 88%;
  --input: 32 14% 88%;
  --ring: 16 85% 52%;
  --busy: 6 72% 54%;
  --busy-foreground: 0 0% 100%;
  --free: 152 28% 42%;
  --free-muted: 152 24% 92%;
  --shadow: 24 20% 20%;
  --radius: 1rem;
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --background: 24 12% 7%;
  --foreground: 36 20% 96%;
  --card: 24 12% 10%;
  --card-foreground: 36 20% 96%;
  --primary: 16 85% 55%;
  --primary-foreground: 0 0% 100%;
  --secondary: 24 10% 16%;
  --secondary-foreground: 36 16% 92%;
  --muted: 24 10% 15%;
  --muted-foreground: 30 10% 62%;
  --accent: 16 40% 16%;
  --accent-foreground: 16 80% 78%;
  --destructive: 0 62% 42%;
  --destructive-foreground: 0 0% 100%;
  --border: 24 10% 18%;
  --input: 24 10% 18%;
  --ring: 16 85% 55%;
  --busy: 6 68% 52%;
  --busy-foreground: 0 0% 100%;
  --free: 152 30% 48%;
  --free-muted: 152 18% 14%;
  --shadow: 0 0% 0%;
  color-scheme: dark;
}

*,
*::before,
*::after {
  border-color: hsl(var(--border));
}

html {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  min-height: 100vh;
}

/* Soft page washes */
.auth-wash {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, hsl(16 85% 52% / 0.14), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 100%, hsl(152 28% 42% / 0.08), transparent 50%),
    hsl(var(--background));
}

[data-theme="dark"] .auth-wash {
  background:
    radial-gradient(ellipse 70% 50% at 50% -5%, hsl(16 85% 52% / 0.18), transparent 55%),
    radial-gradient(ellipse 40% 35% at 90% 90%, hsl(152 28% 42% / 0.08), transparent 50%),
    hsl(var(--background));
}

.app-shell {
  background:
    radial-gradient(ellipse 60% 40% at 0% 0%, hsl(16 85% 52% / 0.06), transparent 50%),
    hsl(var(--background));
}

[data-theme="dark"] .app-shell {
  background:
    radial-gradient(ellipse 50% 35% at 0% 0%, hsl(16 85% 52% / 0.1), transparent 50%),
    hsl(var(--background));
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition: background-color 0.15s, opacity 0.15s, box-shadow 0.15s, transform 0.1s;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.35);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px hsl(var(--shadow) / 0.08), 0 4px 12px hsl(16 85% 52% / 0.2);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--muted));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}

.btn-ghost:hover:not(:disabled) {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-icon {
  width: 44px;
  padding: 0;
}

/* Form controls */
.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.2);
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 550;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

/* Cards */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 1.25rem;
  box-shadow:
    0 1px 2px hsl(var(--shadow) / 0.04),
    0 8px 24px hsl(var(--shadow) / 0.06);
}

/* Nav */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: hsl(var(--card) / 0.85);
  border-bottom: 1px solid hsl(var(--border));
}

.wordmark {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.125rem;
}

.wordmark::after {
  content: "";
  display: inline-block;
  width: 0.35em;
  height: 0.35em;
  margin-left: 0.2em;
  border-radius: 999px;
  background: hsl(var(--primary));
  vertical-align: 0.2em;
}

.wordmark-dot {
  color: hsl(var(--primary));
}

/* Chips / legend */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 550;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

.chip-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.25rem;
}

.chip-swatch-busy {
  background: hsl(var(--busy) / 0.85);
  border: 1px solid hsl(var(--busy));
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    hsl(var(--busy-foreground) / 0.15) 2px,
    hsl(var(--busy-foreground) / 0.15) 4px
  );
}

.chip-swatch-free {
  background: hsl(var(--free-muted));
  border: 1px solid hsl(var(--free) / 0.45);
}

/* Toast */
.toast-host {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(22rem, calc(100vw - 2rem));
}

.toast {
  pointer-events: auto;
  padding: 0.875rem 1rem;
  border-radius: 0.875rem;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 8px 28px hsl(var(--shadow) / 0.18);
  font-size: 0.875rem;
  font-weight: 500;
  animation: toast-in 0.22s ease-out;
}

.toast-success {
  border-color: hsl(var(--free) / 0.4);
}

.toast-error {
  border-color: hsl(var(--destructive) / 0.45);
  color: hsl(var(--destructive));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Confirm dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: hsl(24 12% 7% / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 0.15s ease-out;
}

.dialog {
  width: 100%;
  max-width: 24rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 16px 48px hsl(var(--shadow) / 0.25);
}

.dialog h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.dialog p {
  color: hsl(var(--muted-foreground));
  font-size: 0.9375rem;
  margin-bottom: 1.25rem;
}

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

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Calendar grid */
.cal-week {
  display: grid;
  grid-template-columns: 3.5rem repeat(7, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .cal-week {
    grid-template-columns: 4.5rem repeat(7, minmax(0, 1fr));
  }
}

.cal-header-cell {
  padding: 0.75rem 0.25rem;
  text-align: center;
  border-bottom: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.5);
}

.cal-header-cell.is-today {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  box-shadow: inset 0 3px 0 hsl(var(--primary));
}

.cal-day-name {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

.cal-header-cell.is-today .cal-day-name {
  color: hsl(var(--primary));
}

.cal-day-num {
  font-size: 1.125rem;
  font-weight: 700;
  margin-top: 0.125rem;
}

.cal-time-label {
  font-size: 0.6875rem;
  font-weight: 550;
  color: hsl(var(--muted-foreground));
  text-align: right;
  padding: 0 0.5rem 0 0.25rem;
  transform: translateY(-0.5em);
}

.cal-body {
  position: relative;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--free-muted) / 0.55);
}

.cal-body.is-today {
  background:
    linear-gradient(hsl(var(--accent) / 0.45), hsl(var(--accent) / 0.45)),
    hsl(var(--free-muted) / 0.4);
}

.cal-body.is-past {
  opacity: 0.55;
}

.cal-hour-line {
  border-bottom: 1px solid hsl(var(--border) / 0.7);
  height: 48px;
}

@media (min-width: 640px) {
  .cal-hour-line {
    height: 56px;
  }
}

.cal-busy-block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 0.5rem;
  background: hsl(var(--busy) / 0.88);
  border: 1px solid hsl(var(--busy));
  color: hsl(var(--busy-foreground));
  font-size: 0.625rem;
  font-weight: 650;
  padding: 0.2rem 0.35rem;
  overflow: hidden;
  z-index: 2;
  box-shadow: 0 1px 3px hsl(var(--shadow) / 0.15);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    hsl(0 0% 100% / 0.08) 3px,
    hsl(0 0% 100% / 0.08) 6px
  );
  cursor: help;
}

.cal-busy-block:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
}

.cal-now-line {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  height: 2px;
  background: hsl(var(--primary));
  pointer-events: none;
}

.cal-now-line::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: hsl(var(--primary));
}

.cal-gutter {
  position: sticky;
  left: 0;
  z-index: 3;
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
}

/* Week strip (mobile) */
.week-strip {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.week-strip-day {
  flex: 1 0 auto;
  min-width: 3rem;
  padding: 0.5rem 0.35rem;
  border-radius: 0.875rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.week-strip-day:hover {
  background: hsl(var(--secondary));
}

.week-strip-day.is-selected {
  border-color: hsl(var(--primary));
  background: hsl(var(--accent));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
}

.week-strip-day.is-today .week-strip-num {
  color: hsl(var(--primary));
}

.week-strip-name {
  font-size: 0.625rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
}

.week-strip-num {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.125rem;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.9375rem;
}

/* Admin list items */
.list-item {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1rem;
  transition: box-shadow 0.15s;
}

.list-item:hover {
  box-shadow: 0 4px 16px hsl(var(--shadow) / 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 650;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.skeleton {
  background: linear-gradient(
    90deg,
    hsl(var(--muted)) 0%,
    hsl(var(--secondary)) 50%,
    hsl(var(--muted)) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 0.5rem;
}

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

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem;
  border-radius: 0.875rem;
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-size: 0.8125rem;
  line-height: 1.4;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 550;
  color: hsl(var(--muted-foreground));
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.nav-link.is-active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* Theme toggle icons */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
