
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Global input and textarea styling */
input, textarea {
  color: #020305 !important; /* Filled text color */
  background-color: #fafafa !important; /* Fill color */
  border: 1px solid #E5E5E5 !important; /* Border color */
  border-radius: 2px !important; /* Border radius */
}

input::placeholder, textarea::placeholder {
  color: #6b6b6b !important; /* Placeholder text color */
}

/* Active/focused input state */
input:focus, textarea:focus {
  border: 1px solid #020305 !important; /* Focus border */
  outline: none !important; /* Remove default outline */
}

/* Global select element styling - ensures caret padding matches text padding */
select {
  padding-right: 2.5rem !important; /* Extra space for the caret */
  background-color: #fafafa !important; /* Fill color */
  background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'></polyline></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important; /* 12px from right edge, matching left padding */
  background-size: 1rem 1rem !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  color: #020305 !important; /* Filled text color for selects */
  border: 1px solid #E5E5E5 !important; /* Border color */
  border-radius: 2px !important; /* Border radius */
}

/* Active/focused select state */
select:focus {
  border: 1px solid #020305 !important; /* Focus border */
  outline: none !important; /* Remove default outline */
}

/* 1) Respect user settings */
html {
  font-size: 100%; /* 1rem = user's default (usually 16px) */
  scroll-behavior: smooth;
  /* Reserve scrollbar space permanently so mx-auto centering never shifts
     when a page gains or loses a scrollbar (scrollbar-induced layout shift fix) */
  scrollbar-gutter: stable;
}

/* 2) Set a sensible text baseline */
body {
  font-size: 1rem;          /* 16px base text */
  line-height: 1.5;         /* good readability */
  color: #343A40;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* 3) Fluid, but anchored to your exact targets
   Targets at a typical laptop (~1024–1280px):
   H1: 28px(1.75rem) H2: 22px(1.375rem) H3: 18px(1.125rem)
   H4: 16px(1rem)    H5: 14px(0.875rem) H6: 12px(0.75rem)

   clamp(min, preferred, max)
   - min is ~90–95% of your target for small screens
   - max is ~110–120% of your target for large screens
   - the middle uses a small vw slope so sizes breathe naturally
*/

h1 { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 1.9rem); /* ~25.6px → 30.4px, target ~28px */ }
h2 { font-size: clamp(1.25rem, 1.05rem + 0.7vw, 1.5rem); /* ~20px → 24px, target ~22px */ }
h3 { font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.2rem); /* ~16.8px → 19.2px, target ~18px */ }
h4 { font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.05rem); /* ~15.2px → 16.8px, target ~16px */ }
h5 { font-size: clamp(0.82rem, 0.8rem + 0.2vw, 0.9rem);  /* ~13.1px → 14.4px, target ~14px */ }
h6 { font-size: clamp(0.72rem, 0.7rem + 0.2vw, 0.8rem);  /* ~11.5px → 12.8px, target ~12px */ }

/* Optional: consistent heading rhythm */
h1,h2,h3,h4,h5,h6 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-weight: 700;
}

/* Optional cap on ultra-wide displays */
@media (min-width: 1600px) {
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.2rem; }
  h4 { font-size: 1.05rem; }
  h5 { font-size: 0.9rem; }
  h6 { font-size: 0.8rem; }
}

/* Ensure containers don't cause horizontal overflow */
.container {
  max-width: 100vw;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
  button:not([role="checkbox"]):not([role="switch"]), a[href] {
    min-width: 44px;
  }
  
  /* Better mobile scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent text zoom on orientation change */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* Prevent layout shifts */
  img, video {
    max-width: 100%;
    height: auto;
  }
  
  /* Better tap highlighting */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Ensure proper viewport behavior */
  body {
    position: relative;
    width: 100%;
    min-height: 100vh;
  }
  
  /* Fix potential width overflow issues */
  * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  html, body {
    max-width: 100vw;
  }
  
  /* Grid and flexbox mobile fixes - only target containers, not flex items */
  /* Removed [class*="flex-"] which was matching flex-shrink-0, flex-1, flex-col etc.
     and incorrectly giving them width: 100% which broke horizontal flex layouts */
  .grid {
    width: 100%;
    overflow-x: hidden;
  }
  
  /* Text and content overflow prevention */
  p, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none; /* FIXED: Changed from 'auto' to 'none' to prevent mid-word breaks */
  }

  /* Headings should never auto-hyphenate */
  h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
  }
}

:root {
  --background: #E9ECEF;
  --foreground: #495057;
  --card: hsl(0deg 0% 100%);
  --card-foreground: hsl(219.23deg 46.43% 10.98%);
  --popover: hsl(0deg 0% 100%);
  --popover-foreground: hsl(219.23deg 46.43% 10.98%);
  --primary: hsl(216deg 27.78% 7.06%);
  --primary-foreground: hsl(219.23deg 46.43% 10.98%);
  --secondary: hsl(0deg 0% 100%);
  --secondary-foreground: hsl(228.89deg 34.18% 15.49%);
  --muted: hsl(0deg 0% 100%);
  --muted-foreground: hsl(0, 0%, 31%);
  --accent: hsl(48deg 23.81% 95.88%);
  --accent-foreground: hsl(220deg 42.86% 1.37%);
  --destructive: hsl(0deg 80.33% 64.12%);
  --destructive-foreground: hsl(0, 0%, 100%);
  --border: hsl(30, 21%, 66%, 0.2);
  --input: hsl(200, 23%, 97%);
  --ring: hsl(220deg 42.86% 1.37%);
  --chart-1: hsl(228.89deg 34.18% 15.49%);
  --chart-2: hsl(159, 100%, 36%);
  --chart-3: hsl(42.2deg 92.89% 55.88%);
  --chart-4: hsl(147, 79%, 42%);
  --chart-5: hsl(341, 75%, 51%);
  --sidebar: hsl(44, 62%, 96%);
  --sidebar-foreground: hsl(205, 84%, 1%);
  --sidebar-primary: hsl(87, 21%, 35%);
  --sidebar-primary-foreground: hsl(0, 0%, 100%);
  --sidebar-accent: hsl(30, 21%, 66%);
  --sidebar-accent-foreground: hsl(0, 0%, 100%);
  --sidebar-border: hsl(30, 21%, 66%, 0.2);
  --sidebar-ring: hsl(87, 21%, 35%);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: 'Inter', sans-serif;
  --radius: 0rem;
  --shadow-2xs: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
  --shadow-xs: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
  --shadow-sm: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 1px 2px -1px hsl(87, 21%, 35%, 0.00);
  --shadow: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 1px 2px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-md: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 2px 4px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-lg: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 4px 6px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-xl: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 8px 10px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-2xl: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
  --tracking-normal: 0em;
  --spacing: 0.25rem;

  /* TrainingBooker Custom Colors */
  --tb-cream: #E9ECEF;
  --tb-dark: hsl(205, 84%, 1%);
  --tb-gray-text: #343A40;
  --tb-warm-beige: hsl(30, 21%, 66%);
  --tb-sage: hsl(87, 21%, 35%);
  --tb-charcoal: hsl(0, 0%, 31%);
}

/* Custom input styling with 4px border-radius and solid border */
input, textarea {
  border-radius: 4px !important;
  border: 1px solid #E5E5E5 !important;
  background-color: #fafafa !important;
}

/* Input active/focus state styling */
input:focus, input:active, textarea:focus, textarea:active {
  border: 1px solid #020305 !important;
  outline: none !important;
}

/* Dropdown/select styling to match inputs */
select {
  border-radius: 4px !important;
  border: 1px solid #E5E5E5 !important;
  background-color: #fafafa !important;
}

select:focus, select:active {
  border: 1px solid #020305 !important;
  outline: none !important;
}

/* Filter pill select — overrides global select !important rules for pill-shaped selects */
select.filter-pill {
  border-radius: 9999px !important;
  background-color: #ffffff !important;
  background-image: none !important;
  padding-left: 0.75rem !important;
  padding-right: 1.75rem !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border: none !important;
  color: #374151 !important;
  cursor: pointer !important;
}

select.filter-pill:focus {
  border: none !important;
  outline: none !important;
}

select.filter-pill.active {
  border: none !important;
  color: #020305 !important;
  font-weight: 600 !important;
}

/* Override for instant search bar inputs - borderless inside unified container */
input.search-bar-input {
  border: none !important;
  background-color: transparent !important;
  border-radius: 0 !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

input.search-bar-input::placeholder {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #4F4F4F;
}

input.search-bar-input:focus,
input.search-bar-input:active {
  border: none !important;
  outline: none !important;
}

/* Override for main search input to be fully rounded and borderless */
input.main-search-input {
  border-radius: 9999px !important;
  border: none !important;
  caret-color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
}

/* Override for location filter input - no border, fills container */
input.location-filter-input {
  border: none !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

input.location-filter-input:focus,
input.location-filter-input:active {
  border: none !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Google Maps PlaceAutocompleteElement — host element and wrapper styling
   Shadow DOM is closed so we style the host + wrapper from outside */
.places-input-wrapper {
  border: 1px solid #E5E5E5 !important;
  border-radius: 4px !important;
  background-color: #fafafa !important;
  transition: border-color 0.15s ease;
  /* overflow must stay visible so the suggestions dropdown can extend below */
  overflow: visible;
}

/* Focus border via :focus-within (fires when internal shadow DOM input is focused) */
.places-input-wrapper:focus-within,
.places-input-focused {
  border-color: #020305 !important;
  outline: none !important;
}

/* Neutralise the host element's own border/background so the wrapper controls it.
   CSS custom properties (--gmpx-*) DO pass through closed shadow DOM — use them
   to force the internal input text and placeholder to be dark/readable. */
gmp-place-autocomplete {
  display: block !important;
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;

  /* Force light color scheme so the shadow DOM renders with light backgrounds and dark text */
  color-scheme: light;
  color: #1a1a1a !important;

  /* GMPX theme tokens — inherited by shadow DOM internals */
  --gmpx-color-surface: #ffffff;
  --gmpx-color-on-surface: #1a1a1a;
  --gmpx-color-on-surface-variant: #6b7280;
  --gmpx-color-primary: #1a1a1a;
  --gmpx-color-outline: #e5e7eb;
  --gmpx-font-family-base: inherit;
  --gmpx-font-size-base: 0.875rem;
}

/* Override react-day-picker selected date styling */
.rdp-day_selected,
.rdp-day_selected:focus,
.rdp-day_selected:hover,
.rdp-day_selected:active {
  background-color: #020305 !important;
  color: white !important;
}

/* Active tab: transparent bg, black text, 2px bottom border indicator */
[role="tablist"] button[aria-selected="true"] {
  background-color: transparent !important;
  color: #020305 !important;
  box-shadow: none !important;
  border-bottom: 2px solid #020305 !important;
  border-radius: 0 !important;
}

.dark {
  --background: hsl(0, 0%, 0%);
  --foreground: hsl(200, 7%, 91%);
  --card: hsl(228, 10%, 10%);
  --card-foreground: hsl(0, 0%, 85%);
  --popover: hsl(0, 0%, 0%);
  --popover-foreground: hsl(200, 7%, 91%);
  --primary: hsl(87, 21%, 35%);
  --primary-foreground: hsl(0, 0%, 100%);
  --secondary: hsl(195, 15%, 95%);
  --secondary-foreground: hsl(205, 84%, 1%);
  --muted: hsl(0, 0%, 9%);
  --muted-foreground: hsl(210, 3%, 46%);
  --accent: hsl(206, 70%, 8%);
  --accent-foreground: hsl(87, 21%, 35%);
  --destructive: hsl(356, 91%, 54%);
  --destructive-foreground: hsl(0, 0%, 100%);
  --border: hsl(210, 5%, 15%);
  --input: hsl(208, 28%, 18%);
  --ring: hsl(87, 21%, 35%);
  --chart-1: hsl(87, 21%, 35%);
  --chart-2: hsl(159, 100%, 36%);
  --chart-3: hsl(42, 93%, 56%);
  --chart-4: hsl(147, 79%, 42%);
  --chart-5: hsl(341, 75%, 51%);
  --sidebar: hsl(228, 10%, 10%);
  --sidebar-foreground: hsl(0, 0%, 85%);
  --sidebar-primary: hsl(87, 21%, 35%);
  --sidebar-primary-foreground: hsl(0, 0%, 100%);
  --sidebar-accent: hsl(206, 70%, 8%);
  --sidebar-accent-foreground: hsl(87, 21%, 35%);
  --sidebar-border: hsl(206, 16%, 26%);
  --sidebar-ring: hsl(87, 21%, 35%);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: Menlo, monospace;
  --radius: 0.5rem;
  --shadow-2xs: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
  --shadow-xs: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
  --shadow-sm: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 1px 2px -1px hsl(87, 21%, 35%, 0.00);
  --shadow: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 1px 2px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-md: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 2px 4px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-lg: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 4px 6px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-xl: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00), 0px 8px 10px -1px hsl(87, 21%, 35%, 0.00);
  --shadow-2xl: 0px 2px 0px 0px hsl(87, 21%, 35%, 0.00);
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply font-sans antialiased bg-tb-cream text-tb-gray-text;
  }

  h1, h2, h3, h4, h5 {
    color: #212529;
  }

  label {
    color: #495057;
  }
}

@layer utilities {
  .text-tb-dark {
    color: var(--tb-dark);
  }
  
  .text-tb-gray-text {
    color: var(--tb-gray-text);
  }
  
  .bg-tb-cream {
    background-color: var(--tb-cream);
  }
  
  .bg-tb-sage {
    background-color: var(--tb-sage);
  }
  
  .bg-tb-warm-beige {
    background-color: var(--tb-warm-beige);
  }
  
  .bg-tb-charcoal {
    background-color: var(--tb-charcoal);
  }
  
  .border-tb-warm-beige {
    border-color: var(--tb-warm-beige);
  }
  
  .hover\:bg-tb-sage\/90:hover {
    background-color: hsl(87, 21%, 35%, 0.9);
  }
  
  .animate-scroll-smooth {
    animation: scroll-smooth 60s linear infinite;
  }
}

@keyframes scroll-smooth {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-100% / 3));
  }
}

/* Hide profession list scrollbar specifically */
.max-h-64.overflow-y-auto::-webkit-scrollbar {
  display: none;  /* Safari and Chrome */
}

/* Override mobile image rules for instructor headshot container */
@media (max-width: 768px) {
  .instructor-headshot-container {
    width: 2rem !important;
    height: 2rem !important;
    max-width: 2rem !important;
    max-height: 2rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    flex-shrink: 0 !important;
  }
}

.prism-btn:hover {
  filter: brightness(1.15);
}

.map-popup-rounded .mapboxgl-popup-content {
  border-radius: 12px !important;
  overflow: hidden;
  padding: 0 !important;
}

.listing-page-title {
  font-size: 30px !important;
}

.instructor-card-name {
  font-size: 16px !important;
}

.city-suggestion-name {
  font-size: 16px !important;
}

/* Remove uppercase and letter-spacing from all heading levels except h5 */
/* Font sizes add 10px to the base while preserving the h1 > h2 > h3 > h4 hierarchy */
h1 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: clamp(1.5rem, 2.5vw + 1rem, 40px) !important;
  color: var(--heading-override-color, #212529) !important;
}
h2 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 30px !important;
  color: var(--heading-override-color, #212529) !important;
}
.listing-editor-content h2 {
  font-size: 18px !important;
  font-weight: 700 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: #020305 !important;
}
h3 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 20px !important;
  color: var(--heading-override-color, #212529) !important;
}
h4 {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 18px !important;
  color: var(--heading-override-color, #212529) !important;
}
h5 {
  color: var(--heading-override-color, #212529) !important;
}

/* Hide scrollbar for horizontal tabs */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Global scrollbar-hide utility */
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Portal profile tab content transition */
@keyframes page-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes heroImageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes page-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.page-enter {
  animation: page-fade-in 0.22s ease-out forwards;
}

.page-exit {
  animation: page-fade-out 0.2s ease-in forwards;
  pointer-events: none;
}

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

[role="tabpanel"][data-state="active"] {
  animation: tab-fade-in 0.22s ease-out forwards;
}

/* Google Places Autocomplete dropdown — must sit above modal overlays */
.pac-container {
  z-index: 9999 !important;
  border-radius: 6px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-family: inherit;
  margin-top: 2px;
}
.pac-item {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.pac-item:hover {
  background-color: #f9fafb;
}

@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes counter-orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}
