/* Global UI polish for desktop + mobile (applies across all templates)
   - iOS form zoom prevention
   - safer tap targets
   - dialog(modal) mobile bottom-sheet behavior
   - safe-area helpers
*/

:root {
  --app-safe-top: env(safe-area-inset-top);
  --app-safe-bottom: env(safe-area-inset-bottom);
}

/* iOS momentum scrolling for overflow containers (tables, week grids, etc.) */
:where(.overflow-x-auto, .overflow-y-auto) {
  -webkit-overflow-scrolling: touch;
}

html {
  scroll-behavior: smooth;
  /* keep anchors visible under sticky headers */
  scroll-padding-top: 5.5rem;
}

@media (max-width: 640px) {
  html {
    scroll-padding-top: 6.5rem;
  }
}

* {
  -webkit-tap-highlight-color: transparent;
}

:where(button, a, input, select, textarea) {
  touch-action: manipulation;
}

/* Prevent iOS Safari from zooming inputs on focus (requires >= 16px). */
@media (max-width: 640px) {
  :where(input, select, textarea) {
    font-size: 16px;
  }
}

/* A11y: give taps a sane minimum size without fighting Tailwind */
:where(button, a[role="button"], input[type="button"], input[type="submit"]) {
  min-height: 44px;
}

/* Dialog polish (shared pattern is class="modal") */
:where(dialog.modal) {
  border: none;
  padding: 0;
  background: transparent;
}

:where(dialog.modal)::backdrop {
  background: rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Mobile: treat modals as bottom-sheets by default */
@media (max-width: 640px) {
  :where(dialog.modal[open]) {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
  }

  :where(dialog.modal) > :first-child {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: calc(92vh - var(--app-safe-bottom));
    overflow: auto;
  }
}

/* Reduce motion when requested */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Mobile: render selected tables as stacked cards (opt-in via class) */
@media (max-width: 640px) {
  table.mobile-stack-table {
    display: block;
    width: 100%;
  }

  table.mobile-stack-table thead {
    display: none;
  }

  table.mobile-stack-table tbody {
    display: block;
  }

  table.mobile-stack-table tr {
    display: block;
    margin: 0 0 12px 0;
    border: 1px solid rgba(226, 232, 240, 1); /* slate-200 */
    border-radius: 14px;
    overflow: hidden;
    background: white;
  }

  table.mobile-stack-table td {
    display: block;
    width: 100%;
    padding: 12px 14px !important;
    border: none !important;
    white-space: normal !important;
    text-align: left !important;
  }

  table.mobile-stack-table td + td {
    border-top: 1px solid rgba(241, 245, 249, 1) !important; /* slate-100 */
  }
}

/* ------------------------------------------------------------
   Design System (light)
   - small set of reusable primitives without a framework
   - intended to reduce inline Tailwind duplication in hotspots
------------------------------------------------------------ */

:root {
  --c-brand-600: #0284c7;
  --c-brand-700: #0369a1;
  --c-slate-50: #f8fafc;
  --c-slate-100: #f1f5f9;
  --c-slate-200: #e2e8f0;
  --c-slate-600: #475569;
  --c-slate-800: #1f2937;
  --c-emerald-600: #059669;
  --c-emerald-700: #047857;
  --c-rose-600: #e11d48;
  --c-rose-700: #be123c;
  --c-amber-50: #fffbeb;
  --c-amber-200: #fde68a;
  --c-amber-800: #92400e;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  font-weight: 800;
  font-size: 0.875rem;
  line-height: 1rem;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid rgba(2, 132, 199, 0.35);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 0.375rem 0.625rem;
  border-radius: 0.625rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--c-brand-600);
  color: #fff;
  box-shadow: 0 1px 0 rgba(2, 6, 23, 0.06);
}
.btn-primary:hover { background: var(--c-brand-700); }

.btn-secondary {
  background: #fff;
  color: var(--c-slate-800);
  border-color: var(--c-slate-200);
}
.btn-secondary:hover { background: var(--c-slate-50); }

.btn-danger {
  background: var(--c-rose-600);
  color: #fff;
  box-shadow: 0 1px 0 rgba(2, 6, 23, 0.06);
}
.btn-danger:hover { background: var(--c-rose-700); }

.btn-ghost {
  background: transparent;
  color: var(--c-slate-600);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(2, 6, 23, 0.04); color: var(--c-slate-800); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--c-slate-200);
  background: var(--c-slate-50);
  color: var(--c-slate-600);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-scheduled { background: rgba(2, 132, 199, 0.08); border-color: rgba(2, 132, 199, 0.22); color: var(--c-brand-700); }
.badge-open { background: var(--c-amber-50); border-color: var(--c-amber-200); color: var(--c-amber-800); }
.badge-offered { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.22); color: #5b21b6; }
.badge-sick { background: rgba(225, 29, 72, 0.08); border-color: rgba(225, 29, 72, 0.22); color: var(--c-rose-700); }
.badge-pending { background: rgba(100, 116, 139, 0.08); border-color: rgba(100, 116, 139, 0.22); color: #334155; }

/* Alerts */
.alert {
  border: 1px solid var(--c-slate-200);
  background: #fff;
  color: var(--c-slate-800);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.alert strong { font-weight: 900; }

.alert-info { background: rgba(2, 132, 199, 0.06); border-color: rgba(2, 132, 199, 0.18); }
.alert-success { background: rgba(5, 150, 105, 0.07); border-color: rgba(5, 150, 105, 0.2); }
.alert-error { background: rgba(225, 29, 72, 0.06); border-color: rgba(225, 29, 72, 0.18); }

/* Empty / Loading */
.ui-empty {
  border: 1px dashed var(--c-slate-200);
  background: var(--c-slate-50);
  border-radius: 1rem;
  padding: 1.25rem;
  text-align: center;
  color: var(--c-slate-600);
}

.ui-empty-title {
  font-weight: 900;
  color: var(--c-slate-800);
  margin-bottom: 0.25rem;
}

.ui-empty-hint {
  font-size: 0.875rem;
  opacity: 0.9;
}
/* Global UI polish for desktop + mobile (applies across all templates)
   - iOS form zoom prevention
   - safer tap targets
   - dialog(modal) mobile bottom-sheet behavior
   - safe-area helpers
*/

:root {
  --app-safe-top: env(safe-area-inset-top);
  --app-safe-bottom: env(safe-area-inset-bottom);
}

/* iOS momentum scrolling for overflow containers (tables, week grids, etc.) */
:where(.overflow-x-auto, .overflow-y-auto) {
  -webkit-overflow-scrolling: touch;
}

html {
  scroll-behavior: smooth;
  /* keep anchors visible under sticky headers */
  scroll-padding-top: 5.5rem;
}

@media (max-width: 640px) {
  html {
    scroll-padding-top: 6.5rem;
  }
}

* {
  -webkit-tap-highlight-color: transparent;
}

:where(button, a, input, select, textarea) {
  touch-action: manipulation;
}

/* Prevent iOS Safari from zooming inputs on focus (requires >= 16px). */
@media (max-width: 640px) {
  :where(input, select, textarea) {
    font-size: 16px;
  }
}

/* A11y: give taps a sane minimum size without fighting Tailwind */
:where(button, a[role="button"], input[type="button"], input[type="submit"]) {
  min-height: 44px;
}

/* Dialog polish (shared pattern is class="modal") */
:where(dialog.modal) {
  border: none;
  padding: 0;
  background: transparent;
}

:where(dialog.modal)::backdrop {
  background: rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Mobile: treat modals as bottom-sheets by default */
@media (max-width: 640px) {
  :where(dialog.modal[open]) {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
  }

  :where(dialog.modal) > :first-child {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: calc(92vh - var(--app-safe-bottom));
    overflow: auto;
  }
}

/* Reduce motion when requested */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


