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

@layer base {
  :root {
    color-scheme: light;
  }

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

  /* Motion is a courtesy, never a requirement. */
  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  body {
    @apply bg-white text-ink antialiased;
    text-rendering: optimizeLegibility;
  }

  ::selection {
    @apply bg-primary text-white;
  }

  :focus-visible {
    outline: 2px solid theme(colors.primary.DEFAULT);
    outline-offset: 2px;
    border-radius: theme(borderRadius.md);
  }

  details > summary {
    list-style-type: none;
  }

  details summary::-webkit-details-marker {
    display: none;
  }
}

@layer components {
  /* Buttons — landing page Button.tsx variants */
  .btn {
    @apply inline-flex items-center justify-center gap-2 rounded-full font-medium tracking-tight transition-all duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 disabled:opacity-50 disabled:pointer-events-none;
  }

  .btn-primary {
    @apply btn bg-primary text-white hover:bg-primary-dark;
  }

  /* The confirming move in a row: filled ink, so the seal red stays with the one primary action of the page. */
  .btn-ink {
    @apply btn bg-ink text-white hover:bg-ink/85;
  }

  .btn-ghost {
    @apply btn border border-line bg-white text-ink hover:border-ink/20 hover:bg-surface;
  }

  .btn-white {
    @apply btn bg-white text-primary shadow-soft hover:bg-tint;
  }

  .btn-outline-white {
    @apply btn border border-white/30 text-white hover:bg-white/10;
  }

  .btn-danger {
    @apply btn border border-red-200 bg-white text-red-600 hover:bg-red-50;
  }

  .btn-sm { @apply h-9 px-4 text-sm; }
  .btn-md { @apply h-11 px-5 text-[15px]; }
  .btn-lg { @apply h-[3.25rem] px-7 text-base; }

  /* Approve / reject / check-in are pressed on a phone mid-service, and time
     slots are the guest's primary tap target. On a touch screen they grow to a
     comfortable target; on a mouse they stay compact. */
  @media (pointer: coarse) {
    .btn-sm { @apply h-11 px-5; }
    .slot-chip { @apply h-11 min-w-[4.25rem]; }
  }

  /* Cards */
  .card {
    @apply rounded-2xl border border-line bg-white;
  }

  .card-panel {
    @apply rounded-3xl border border-line bg-white shadow-panel;
  }

  /* Kicker / eyebrow label with the diamond brand dot */
  .kicker {
    @apply inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.18em] text-primary;
  }

  .kicker-dot {
    @apply inline-block h-1.5 w-1.5 rotate-45 rounded-[2px] bg-primary;
  }

  /* HQ (body.font-admin) never shows monospace digits: shared helpers and
     partials that ask for font-mono get the admin face with tabular figures. */
  .font-admin .font-mono {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
  }

  /* Status badges */
  .badge {
    @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold;
  }

  .badge-dot {
    @apply inline-block h-1.5 w-1.5 rounded-full bg-current;
  }

  .badge-pending    { @apply badge bg-amber-50 text-amber-600; }
  .badge-approved   { @apply badge bg-emerald-50 text-emerald-600; }
  .badge-checked_in { @apply badge bg-blue-50 text-blue-600; }
  .badge-completed  { @apply badge bg-emerald-50 text-emerald-700; }
  .badge-rejected   { @apply badge bg-red-50 text-red-600; }
  .badge-canceled   { @apply badge bg-surface-2 text-muted; }
  .badge-no_show    { @apply badge bg-red-50 text-red-600; }

  /* Time-slot chips (places reservation card) */
  .slot-chip {
    @apply inline-flex h-9 min-w-[3.75rem] cursor-pointer items-center justify-center rounded-full border border-line bg-white px-3 text-sm font-medium tabular-nums text-ink transition-colors duration-200 hover:border-ink/30;
  }

  .slot-chip-selected {
    @apply border-primary bg-primary text-white hover:border-primary;
  }

  .slot-chip-skeleton {
    @apply inline-flex h-9 w-[3.75rem] animate-pulse rounded-full bg-surface-2;
  }

  /* Form inputs */
  .input {
    @apply block w-full rounded-xl border-line bg-white text-[15px] text-ink shadow-none placeholder:text-muted/70 focus:border-primary focus:ring-primary;
  }

  .label {
    @apply block text-sm font-medium text-ink mb-1.5;
  }

  /* Small section label: sentence case; the heading carries its own weight. */
  .microlabel {
    @apply text-[13px] font-medium text-muted;
  }

  /* ---- Management panel: the "servis defteri" grammar ----
     Structure comes from headings, hairlines and whitespace; a sheet is the
     only container, and it never nests. Labels are sentence case, figures
     are Geist with tabular numerals; mono is reserved for clock times and
     codes. */
  .page-head {
    @apply flex flex-wrap items-end justify-between gap-x-6 gap-y-3;
  }

  .page-title {
    @apply text-2xl font-semibold tracking-tight text-ink;
  }

  .page-lede {
    @apply mt-1 max-w-prose text-sm text-muted;
  }

  .sheet {
    @apply rounded-2xl border border-line bg-white;
  }

  .sheet-head {
    @apply flex flex-wrap items-center justify-between gap-3 border-b border-line px-5 py-3.5;
  }

  .sheet-title {
    @apply text-[15px] font-semibold tracking-tight text-ink;
  }

  .section-title {
    @apply text-base font-semibold tracking-tight text-ink;
  }

  .section-hint {
    @apply mt-1 text-[13px] leading-5 text-muted;
  }

  .stat-figure {
    @apply text-[28px] font-semibold leading-none tracking-tight tabular-nums text-ink;
  }

  .stat-label {
    @apply mt-2 text-[13px] leading-4 text-muted;
  }

  /* Stat tile: a headline figure in a bordered white box, label above, hint
     below. Tiles sit in a .stat-tiles grid of 2-5 columns, carry no shadow
     and never go inside a .sheet. */
  .stat-tiles {
    @apply grid grid-cols-2 gap-3;
  }

  .stat-tile {
    @apply flex min-w-0 flex-col rounded-2xl border border-line bg-white px-5 py-4;
  }

  .stat-tile-label {
    @apply text-[13px] leading-5 text-muted;
  }

  .stat-tile-value {
    @apply mt-1 text-[26px] font-semibold leading-none tracking-tight tabular-nums text-ink;
  }

  .stat-tile-hint {
    @apply mt-2 text-xs leading-4 text-muted;
  }

  /* Segmented control: one choice among a few, drawn as a single pill. */
  .seg {
    @apply inline-flex items-center rounded-full border border-line bg-white p-0.5;
  }

  .seg-item {
    @apply inline-flex h-8 items-center rounded-full px-3.5 text-sm font-medium text-muted transition-colors hover:text-ink;
  }

  .seg-item-active {
    @apply bg-ink text-white hover:text-white;
  }

  /* Menu live preview: a drawer from lg up, a phone frame or a scaled desktop.
     The page makes room for it while it is open. */
  .menu-preview {
    display: none;
  }

  .menu-phone {
    @apply mx-auto h-[780px] max-h-full w-[390px] overflow-hidden rounded-[24px] border border-line bg-white;
  }

  .menu-preview[data-mode="desktop"] .menu-phone {
    @apply h-auto max-h-none w-full rounded-xl;
  }

  .menu-preview[data-mode="desktop"] .menu-phone iframe {
    width: 1024px;
    max-width: none;
    transform-origin: top left;
  }

  @media (min-width: 1024px) {
    .menu-preview:not([hidden]) {
      display: flex;
    }

    .menu-preview-open {
      padding-right: 456px;
    }

    /* The notifications pill moves left of the open drawer. */
    body:has(.menu-preview:not([hidden])) #panel-notifications {
      right: calc(440px + 1.5rem);
      transition: right 200ms;
    }
  }

  /* Next to the drawer the two sheets are too narrow side by side. */
  @media (min-width: 1024px) and (max-width: 1535px) {
    .menu-preview-open .menu-preview-grid {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  /* A form block whose fields show only while its "1" radio is picked. */
  .service-hours .service-hours-fields {
    display: none;
  }

  .service-hours:has(input[value="1"]:checked) .service-hours-fields {
    display: block;
  }

  /* Sidebar */
  .nav-group-label {
    @apply mb-1 px-2.5 text-[11px] font-medium text-muted/80;
  }

  /* Hand-drawn bars: a track and a fill, scaled by the caller. */
  .bar-track {
    @apply overflow-hidden rounded-full bg-surface-2;
  }

  .bar-fill {
    @apply h-full rounded-full bg-primary;
  }

  /* Rows inside a sheet */
  .row {
    @apply flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3.5 sm:px-5;
  }

  /* Choice chip: a checkbox drawn as a pill. The input stays in the form and
     the tab order (sr-only); the pill shows its state. Picked means the
     seal's tint and a check, so on and off never look alike (the owner's
     call, 2026-11-03: the second use of the red on a panel screen). */
  .choice-row {
    @apply flex flex-wrap gap-2;
  }

  .choice {
    @apply relative inline-flex;
  }

  .choice-label {
    @apply inline-flex h-9 cursor-pointer select-none items-center gap-1.5 rounded-full border border-line bg-white px-4 text-sm font-medium text-ink transition-colors hover:border-ink/20;
  }

  .choice-check {
    @apply -ml-1 hidden h-4 w-4;
  }

  .choice input:checked + .choice-label {
    @apply border-primary/40 bg-primary/15 text-primary-dark;
  }

  .choice input:checked + .choice-label .choice-check {
    @apply inline-block;
  }

  /* The restaurant's own answer: on while it is listed; the x forgets it. */
  .choice-custom {
    @apply inline-flex h-9 items-center gap-1 rounded-full border border-primary/40 bg-primary/15 pl-4 pr-1.5 text-sm font-medium text-primary-dark;
  }

  .choice-custom-remove {
    @apply inline-flex h-6 w-6 items-center justify-center rounded-full text-primary-dark/70 hover:bg-primary/15 hover:text-primary-dark;
  }

  .choice input:focus-visible + .choice-label {
    @apply ring-2 ring-primary ring-offset-2;
  }

  /* The group's wrapper carries the fade; the chip only stops inviting a tap. */
  .choice input:disabled + .choice-label {
    @apply cursor-default;
  }
}

@layer utilities {
  .no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }
}

/* The flash sheet stays white; only its dot says which kind it is. */
.flash--notice .flash-dot {
  @apply bg-emerald-500;
}

.flash--alert .flash-dot {
  @apply bg-red-500;
}
