/* ============================================================================
   ClickLocal — brand colours + shared UI primitives (single source of truth)
   ----------------------------------------------------------------------------
   Every colour on the site is a custom property here. Pages use var(--token)
   and hard-code no hex. To rebrand, change --brand-600 and the ramp around it.

   Loaded on every page:  <link rel="stylesheet" href="/assets/css/brand.css">

   NOTE: CSS variables do NOT work inside <meta name="theme-color">. That tag
   carries a literal #0E49A9 on each page — search for "theme-color" if you
   ever change the primary colour.
   ============================================================================ */

:root {
  /* ---- Primary: ClickLocal blue (nav, buttons, links, map pins) ---- */
  --brand-50:  #EFF4FD;
  --brand-100: #DCE7F9;
  --brand-200: #B4CCF0;
  --brand-300: #7BA5E5;
  --brand-400: #3E79D6;
  --brand-500: #1E5DC4;
  --brand-600: #0E49A9;  /* BASE — brand primary */
  --brand-700: #0C4096;
  --brand-800: #0A3781;
  --brand-900: #072A63;

  /* ---- Accent: the red from the logo. Used sparingly — never for buttons. ---- */
  --accent-500: #E8342C;
  --accent-600: #E31B23;
  --accent-700: #BE1219;

  /* ---- Neutrals ---- */
  --gray-50:  #F7F9FC;
  --gray-100: #EFF2F7;
  --gray-200: #E1E6EF;
  --gray-300: #C8D0DE;
  --gray-400: #9AA5B8;
  --gray-500: #77839A;
  --gray-600: #5A6478;
  --gray-700: #414A5C;
  --gray-800: #2A3140;
  --gray-900: #171C26;

  /* ---- Semantic ---- */
  --success:    #17914F;
  --success-bg: #E7F6EC;
  --warning:    #C97A05;
  --warning-bg: #FDF3E2;
  --danger:     #D13B3B;
  --danger-bg:  #FCECEC;

  /* ---- Surfaces ---- */
  --page-bg:   #EFF1F5;
  --card-bg:   #FFFFFF;
  --border:    #E1E6EF;
  --shadow-sm: 0 1px 2px rgba(23, 28, 38, .06);
  --shadow-md: 0 4px 14px rgba(23, 28, 38, .08);
  --shadow-lg: 0 12px 32px rgba(23, 28, 38, .14);

  --radius:    14px;
  --radius-sm: 10px;

  /* One content width for the whole site — front page, mini-page and the admin
     panel all use this, so nothing is wider or narrower than anything else.
     Change it here and every page follows. */
  --page-max: 760px;

  /* The single gutter every card sits on inside that column. Because the page
     column is white end to end, a card is only ever inset by this much — there
     is no wider background panel to make the cards look narrow. */
  --page-gutter: 20px;
}

/* ============================================================
   Reset + base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--page-bg);
  color: var(--gray-900);
  line-height: 1.5;
  /* Respects the iPhone home-indicator area when installed as a PWA. */
  padding-bottom: env(safe-area-inset-bottom);
}

img { max-width: 100%; display: block; }
a   { color: var(--brand-600); }

/* Visible focus ring for keyboard users, suppressed for mouse clicks. */
:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 20px; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }

.btn-outline { background: #fff; color: var(--brand-600); border-color: var(--brand-600); }
.btn-outline:hover { background: var(--brand-50); }

.btn-ghost { background: var(--gray-50); color: var(--gray-700); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3cfcf; }
.btn-danger:hover { background: #f8dcdc; }

.btn-sm    { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label {
  font-size: 12px; font-weight: 700; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .05em;
}
.field .hint { font-size: 12px; color: var(--gray-500); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Every text-ish input shares one look. Keep `password` in this list — it was
   missing once, and those fields silently fell back to the raw browser default
   while everything around them was styled. */
.input, .field input[type=text], .field input[type=email], .field input[type=tel],
.field input[type=url], .field input[type=date], .field input[type=time],
.field input[type=number], .field input[type=password], .field input[type=search],
.field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; color: var(--gray-900); background: #fff;
  outline: none; transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 90px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-600); }

/* File inputs get the same frame, with a themed "Choose file" button. */
.field input[type=file] {
  width: 100%; padding: 9px 11px;
  border: 1.5px dashed var(--gray-300); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--gray-600); background: var(--gray-50);
  cursor: pointer;
}
.field input[type=file]:hover { border-color: var(--brand-400); background: var(--brand-50); }
.field input[type=file]::file-selector-button {
  margin-right: 12px; padding: 7px 13px;
  border: none; border-radius: 8px;
  background: var(--brand-600); color: #fff;
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.field input[type=file]::file-selector-button:hover { background: var(--brand-700); }

/* ---- Password reveal ----------------------------------------------------
   .pw-wrap is added at runtime by assets/js/password-toggle.js, which wraps
   every password field on the page. The rules still work if JS never runs —
   the input just keeps the standard frame with no button over it. */
.pw-wrap { position: relative; display: block; }
.pw-wrap input[type=password],
.pw-wrap input[type=text] { padding-right: 46px; }

.pw-toggle {
  position: absolute; top: 0; right: 0;
  width: 44px; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0;
  color: var(--gray-400); font-size: 19px; cursor: pointer;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.pw-toggle:hover { color: var(--brand-600); }
.pw-toggle:focus-visible { outline: 3px solid var(--brand-300); outline-offset: -3px; }
.pw-toggle[aria-pressed="true"] { color: var(--brand-600); }

/* Edge and Safari draw their own reveal control — two eyes side by side. */
.pw-wrap input::-ms-reveal,
.pw-wrap input::-ms-clear { display: none; }
.pw-wrap input::-webkit-textfield-decoration-container { padding-right: 0; }
.field input:disabled, .field select:disabled { background: var(--gray-50); color: var(--gray-400); }

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }

/* ============================================================
   Cards, alerts, misc
   ============================================================ */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 15px; font-weight: 800; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.alert {
  border-radius: var(--radius-sm); padding: 12px 15px; margin-bottom: 16px;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-error { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #f3cfcf; }
.alert-ok    { background: var(--success-bg); color: var(--success); border: 1px solid #bfe5cd; }
.alert-info  { background: var(--brand-50);   color: var(--brand-700); border: 1px solid var(--brand-100); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.pill-open   { background: var(--success-bg); color: var(--success); }
.pill-closed { background: var(--gray-100);   color: var(--gray-600); }

.empty { text-align: center; padding: 34px 18px; color: var(--gray-500); font-size: 14px; }
.empty i { font-size: 38px; color: var(--gray-300); display: block; margin-bottom: 10px; }

/* ============================================================
   Image cropper  (assets/js/image-cropper.js builds this markup)
   ============================================================ */
.cropper-back {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(23, 28, 38, .72);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.cropper-back.on { display: flex; }

.cropper {
  background: #fff; border-radius: 18px; width: 100%; max-width: 460px;
  padding: 20px; box-shadow: var(--shadow-lg);
}
.cropper-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.cropper-title { font-size: 16px; font-weight: 800; }
.cropper-count { font-size: 13px; color: var(--gray-500); margin-left: auto; }

.cropper-stage {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--gray-900); display: flex; justify-content: center;
}
.cropper-canvas { display: block; touch-action: none; cursor: grab; }
.cropper-canvas:active { cursor: grabbing; }

/* Dim everything outside the crop window. The hole is a transparent box with a
   huge spread shadow, which is what darkens the surrounding area. */
.cropper-mask { position: absolute; inset: 0; pointer-events: none; }
.cropper-hole {
  position: absolute; top: 0;
  box-shadow: 0 0 0 9999px rgba(23, 28, 38, .55);
  outline: 2px solid #fff; outline-offset: -1px;
}

.cropper-zoom { display: flex; align-items: center; gap: 11px; margin-top: 16px; }
.cropper-zoom i { color: var(--gray-400); }
.cropper-zoom i:first-child { font-size: 15px; }
.cropper-zoom i:last-child  { font-size: 21px; }
.cropper-zoom input { flex: 1; accent-color: var(--brand-600); }

.cropper-hint { font-size: 12.5px; color: var(--gray-500); text-align: center; margin-top: 9px; }
.cropper-actions { display: flex; gap: 10px; margin-top: 16px; }
.cropper-actions .btn { flex: 1; }

/* The little preview + shape picker that sit next to a croppable file input. */
.crop-preview {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.crop-thumb {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--gray-50); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400); font-size: 12px; text-align: center;
}
.crop-thumb img { width: 100%; height: 100%; object-fit: cover; }
.crop-thumb.is-square { width: 74px;  height: 74px; }
.crop-thumb.is-wide   { width: 210px; height: 56px; }
.crop-thumb.is-wide img { object-fit: contain; background: #fff; }

.shape-picker { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.shape-opt { position: relative; }
.shape-opt input { position: absolute; opacity: 0; pointer-events: none; }
.shape-opt span {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200); background: #fff;
  font-size: 13px; font-weight: 700; color: var(--gray-600); cursor: pointer;
}
.shape-opt span::before {
  content: ''; display: block; background: var(--gray-300); border-radius: 3px; flex-shrink: 0;
}
.shape-opt.sq span::before { width: 17px; height: 17px; }
.shape-opt.wd span::before { width: 28px; height: 8px; }
.shape-opt input:checked + span { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
.shape-opt input:checked + span::before { background: var(--brand-600); }
.shape-opt input:focus-visible + span { outline: 3px solid var(--brand-300); outline-offset: 2px; }

.muted { color: var(--gray-500); }
.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;
}
