/* ==========================================================================
   HOTEZO DESIGN SYSTEM
   Tokens, resets, typography, and the core .glass primitive.
   Dark-mode-first, with a [data-theme="light"] override.
   ========================================================================== */

:root {
  /* Brand gradient — "Boutique Gold": bronze to champagne */
  --gradient-primary: linear-gradient(135deg, #C9A227 0%, #E8C97A 100%);
  --gradient-primary-soft: linear-gradient(135deg, rgba(201, 162, 39, 0.16) 0%, rgba(232, 201, 122, 0.16) 100%);
  --color-primary: #C9A227;
  --color-primary-2: #D4AF37;
  --color-primary-3: #E8C97A;
  --color-cyan: #06B6D4;
  --color-amber: #E8720F;
  --color-emerald: #10B981;
  --color-rose: #EF4444;
  /* Dark ink for text/icons drawn on top of --gradient-primary — white text
     fails contrast on gold, dark-on-gold is also the recognized luxury/award convention. */
  --on-gradient: #1C1710;

  /* Fonts */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Shadows */
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(248, 246, 240, 0.10);
  --shadow-lift: 0 16px 40px rgba(201, 162, 39, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.16);

  /* Motion */
  --ease-out-3: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 0.15s;
  --dur-base: 0.25s;
  --dur-slow: 0.4s;

  /* z-index scale */
  --z-nav: 100;
  --z-dropdown: 500;
  --z-modal: 1000;
  --z-toast: 1100;
}

/* -------------------------- Theme: dark (default) ------------------------ */
:root,
[data-theme='dark'] {
  --bg: #0B0B0F;
  --surface: #16151C;
  --surface-2: #1F1C24;
  --glass: rgba(248, 246, 240, 0.10);
  --glass-border: rgba(232, 201, 122, 0.18);
  --border: rgba(248, 246, 240, 0.09);
  --text-high: #F8F6F0;
  --text-med: #ADA79C;
  --text-low: #746B60;
  --scrollbar: rgba(248, 246, 240, 0.18);
  --overlay: rgba(6, 5, 4, 0.74);
  --accent-hover-border: rgba(232, 201, 122, 0.5);

  /* Rates & Inventory grid cell states (Rules & Inventory screen) —
     reuse the existing emerald/amber/rose hues under semantic names
     rather than inventing new colour values, per the design system's
     own "no new colour values" convention. */
  --color-available: #10B981;
  --color-low-stock: #E8720F;
  --color-soldout: #EF4444;
}

/* -------------------------------- Theme: light ---------------------------- */
[data-theme='light'] {
  --bg: #FAF7F0;
  --surface: #FFFDF9;
  --surface-2: #F3ECDD;
  --glass: rgba(255, 250, 240, 0.65);
  --glass-border: rgba(120, 95, 20, 0.14);
  --border: rgba(40, 30, 10, 0.09);
  --text-high: #241D10;
  --text-med: #5C5346;
  --text-low: #8C8272;
  --scrollbar: rgba(40, 30, 10, 0.18);
  --overlay: rgba(250, 247, 240, 0.72);
  --accent-hover-border: rgba(180, 138, 24, 0.38);
  --color-available: #10B981;
  --color-low-stock: #E8720F;
  --color-soldout: #EF4444;
}

/* Respect system preference only when the user hasn't explicitly chosen */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #FAF7F0;
    --surface: #FFFDF9;
    --surface-2: #F3ECDD;
    --glass: rgba(255, 250, 240, 0.65);
    --glass-border: rgba(120, 95, 20, 0.14);
    --border: rgba(40, 30, 10, 0.09);
    --text-high: #241D10;
    --text-med: #5C5346;
    --text-low: #8C8272;
    --scrollbar: rgba(40, 30, 10, 0.18);
    --overlay: rgba(250, 247, 240, 0.72);
    --accent-hover-border: rgba(180, 138, 24, 0.38);
    --color-available: #10B981;
    --color-low-stock: #E8720F;
    --color-soldout: #EF4444;
  }
}

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

/*
 * The `hidden` attribute must always win over a component's own
 * `display` (flex/grid/etc.) — otherwise `el.hidden = true` in JS
 * silently does nothing on any element whose class sets `display`,
 * since an author rule of equal specificity beats the UA's default
 * `[hidden] { display: none }`. Found via real-browser testing: the
 * confirm-dialog modal and dashboard empty-states were both stuck
 * visible despite JS correctly setting `hidden`.
 */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text-high);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color var(--dur-base) var(--ease-out-3), color var(--dur-base) var(--ease-out-3);
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

ul,
ol {
  list-style: none;
}

/* ------------------------------- Typography -------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.25rem, 1.8rem + 2vw, 4rem);
}

h2 {
  font-size: clamp(1.75rem, 1.5rem + 1.2vw, 2.75rem);
}

h3 {
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.75rem);
}

h4 {
  font-size: 1.15rem;
}

p {
  color: var(--text-med);
}

.text-high {
  color: var(--text-high);
}

.text-med {
  color: var(--text-med);
}

.text-low {
  color: var(--text-low);
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ----------------------------------- Icons ----------------------------------- */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-xs {
  width: 13px;
  height: 13px;
}

.icon-lg {
  width: 32px;
  height: 32px;
}

/* --------------------------- Theme switch transition --------------------------- */
/*
 * Applied to <html> for a short window while the theme toggles, so
 * every themed element cross-fades instead of flipping instantly.
 * Scoped and temporary (removed by JS after the transition completes)
 * — the !important only needs to win for that window.
 */
.theme-transitioning,
.theme-transitioning * {
  transition:
    background-color var(--dur-slow) var(--ease-out-3) !important,
    border-color var(--dur-slow) var(--ease-out-3) !important,
    color var(--dur-slow) var(--ease-out-3) !important,
    box-shadow var(--dur-slow) var(--ease-out-3) !important;
}

/* --------------------------------- Layout ---------------------------------- */
.container {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.grid {
  display: grid;
  gap: var(--space-6);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ------------------------------- Glass primitive ---------------------------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

/* -------------------------------- Scrollbar --------------------------------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------- Focus ring -------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-primary-2);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------ Reduced motion ------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

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

/*
 * Every step the views actually use. mb-1/mb-3/mb-8, mt-1/mt-3/mt-5 and
 * ml-2 were referenced across ~90 elements but never defined, so those
 * margins silently collapsed to 0 (stacked cards touching on Settings,
 * Reports, OTAs, …). Add a step here before using a new one in a view.
 */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.ml-2 { margin-left: var(--space-2); }

.text-center { text-align: center; }
