/* Common Stylesheet for TFMW Application */

/* ========== Design system ========== */

:root {
  /* Single accent */
  --theme-color: #4a637a;

  /* Single gray scale (zinc) for text, borders, backgrounds */
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;

  /* Spacing scale: 4, 8, 12, 16, 24 */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-6: 1.5rem;   /* 24px */

  /* Typography: limited sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
}

/* Focus ring: one consistent style for keyboard/accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px color-mix(in srgb, var(--theme-color) 30%, transparent);
}

/* Touch targets: min 44px for tap areas on mobile */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

/* Card: one style everywhere */
.card {
  border-radius: 0.375rem;
  border: 1px solid var(--zinc-300);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Section title: one level */
.section-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--theme-color);
}

/* Caption / secondary text */
.caption {
  font-size: var(--text-xs);
  color: var(--zinc-500);
}

/* Primary button base */
.btn-primary {
  padding: var(--space-2) var(--space-4);
  border-radius: 0.375rem;
  font-size: var(--text-sm);
  font-weight: 500;
  background-color: var(--theme-color);
  color: white;
  border: none;
  min-height: 44px;
  transition: opacity 0.15s;
}
.btn-primary:hover {
  opacity: 0.9;
}

/* Secondary button base */
.btn-secondary {
  padding: var(--space-2) var(--space-4);
  border-radius: 0.375rem;
  font-size: var(--text-sm);
  font-weight: 500;
  background-color: white;
  color: var(--zinc-700);
  border: 1px solid var(--zinc-300);
  min-height: 44px;
  transition: background-color 0.15s;
}
.btn-secondary:hover {
  background-color: var(--zinc-50);
}

/* Filter chips (toggle buttons): selected state — stronger than default (index) tint */
.filter-chip[aria-pressed="true"] {
  background-color: rgba(74, 99, 122, 0.35);
  border: 2px solid var(--theme-color);
  color: var(--theme-color);
}

/* Empty / loading state placeholder */
.empty-state {
  padding: var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--zinc-500);
}

/* ========== Layout ========== */

/* Phone preview: width + safe area for notches/home indicator */
@media (min-width: 640px) {
  .phone-preview {
    width: 393px;
  }
}

/* iOS Safari viewport fix: overflow:hidden on html/body is ignored by Safari's
   "root scroller" — the window still scrolls horizontally. The fix is to give
   html and body fixed height + overflow:hidden, then make #app the actual scroll
   container. Safari scrolls #app (an element-level scroller) instead of the
   window, and #app's overflow-x:hidden properly prevents horizontal panning. */
html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  overflow: hidden;
  width: 100%;
  font-family: -apple-system, "SF Pro Display", "SF Pro Text", "SF Pro", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#app {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  /* -webkit-overflow-scrolling: touch is intentionally omitted — it breaks
     position:sticky inside the scroll container on iOS Safari. Modern iOS
     (13+) provides momentum scrolling on overflow:auto without it. */
}

.phone-preview {
  /* No overflow-x:hidden here — that would make phone-preview a scroll container,
     which breaks position:sticky on the footer (sticky would constrain to
     phone-preview's content height instead of #app's viewport). #app provides
     the overflow-x clip instead. */
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  /* On mobile the header is fixed, so push content down by header height + notch.
     On desktop (640px+) the header is sticky/in-flow; override below. */
  padding-top: calc(3rem + env(safe-area-inset-top, 0px));
  /* Enough clearance so the last content row doesn't hide under the sticky footer.
     Safe-area-inset-bottom is handled by the footer itself. */
  padding-bottom: 4rem;
}
@media (min-width: 640px) {
  /* On desktop the header is sticky/in-flow, so no extra top padding needed. */
  .phone-preview {
    padding-top: env(safe-area-inset-top, 0);
  }
}

/* Page header: fixed on mobile for the same reason as the footer —
   position:sticky is unreliable inside overflow:auto on iOS Safari. */
#tfmw-page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  border-radius: 0;
  padding-top: env(safe-area-inset-top, 0px);
}
@media (min-width: 640px) {
  #tfmw-page-header {
    position: sticky;
    left: auto;
    right: auto;
    padding-top: 0;
  }
}

/* Tab bar footer: fixed on mobile (position:sticky is unreliable inside
   overflow:auto scroll containers on iOS Safari); sticky on desktop where
   the footer lives inside a 393px phone-preview card.
   ID selector overrides the mx-4 / rounded-md Tailwind classes. */
#tfmw-footer-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 640px) {
  #tfmw-footer-container {
    position: sticky;
    left: auto;
    right: auto;
  }
}

/* ========== Typography ========== */

h1, h2, h3, p, span, button, div {
  font-family: inherit;
}

.large-title {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

/* Event status tag: Definite / Tentative (descriptive, not color-only) */
.event-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--zinc-300);
  background: var(--zinc-100);
  color: var(--zinc-800);
}
.event-status-tag svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  stroke: currentColor;
}

/* Rating stars (contractor list, etc.) */
.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.rating-stars svg {
  width: 1rem;
  height: 1rem;
  fill: #eab308;
}

/* ========== iOS Safari zoom prevention ========== */
/* iOS Safari auto-zooms the viewport when focusing any input with font-size < 16px.
   Setting a 16px floor on all form controls eliminates this without locking user zoom. */
input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
select,
textarea {
  font-size: max(1rem, 16px);
}

/* ========== Legacy / utilities ========== */

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.4) sepia(1) saturate(5) hue-rotate(180deg);
}

#profile-company-logo-wrap,
#profile-company-logo-wrap > * {
  width: 80px !important;
  height: 80px !important;
  min-width: 80px !important;
  min-height: 80px !important;
  border-radius: 50% !important;
}

#profile-company-logo-wrap > img,
#profile-company-logo-wrap > video,
#profile-company-logo-wrap > canvas {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  object-fit: cover;
  display: block;
}

#profile-company-logo-wrap > div,
#profile-company-logo-wrap > span {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 1 !important;
}

/* ========== Desktop profile layout ========== */
@media (min-width: 1024px) {
  .desktop-profile.phone-preview {
    width: 100%;
    max-width: 1100px;
  }

  .desktop-profile .desktop-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
  }

  .desktop-profile .desktop-sidebar {
    position: sticky;
    top: 80px;
  }
}

/* ========== Confirm dialog ========== */
.tfmw-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 480px) {
  .tfmw-confirm-backdrop { align-items: center; }
}
.tfmw-confirm-sheet {
  background: white;
  border-radius: 1rem 1rem 0 0;
  width: 100%;
  max-width: 28rem;
  padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}
@media (min-width: 480px) {
  .tfmw-confirm-sheet { border-radius: 1rem; padding-bottom: 1.5rem; }
}
.tfmw-confirm-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--zinc-900);
  margin-bottom: 0.5rem;
}
.tfmw-confirm-message {
  font-size: var(--text-sm);
  color: var(--zinc-600);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.tfmw-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.tfmw-confirm-actions .btn-danger {
  padding: var(--space-2) var(--space-4);
  border-radius: 0.375rem;
  font-size: var(--text-sm);
  font-weight: 500;
  background-color: #dc2626;
  color: white;
  border: none;
  min-height: 44px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tfmw-confirm-actions .btn-danger:hover { opacity: 0.9; }

.tfmw-role-switch-backdrop { z-index: 50; }
.tfmw-role-switch-sheet { max-height: min(80vh, 28rem); overflow: hidden; display: flex; flex-direction: column; }
.tfmw-role-switch-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 14rem;
  overflow-y: auto;
  margin-top: 0.5rem;
}
.tfmw-role-switch-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #d4d4d8;
  background: #fff;
  color: #18181b;
  cursor: pointer;
  transition: background 0.15s;
}
.tfmw-role-switch-option:hover { background: #fafafa; }
.tfmw-role-switch-option-logout {
  border-color: #fecaca;
  color: #991b1b;
}
.tfmw-role-switch-option-logout:hover { background: #fef2f2; }
.tfmw-role-switch-option-label { font-size: 0.9375rem; font-weight: 500; }
.tfmw-role-switch-option-sublabel { font-size: 0.75rem; color: #71717a; margin-top: 0.125rem; }
.tfmw-role-switch-actions {
  flex-direction: column;
  gap: 0.5rem;
}