/* ============================================================================
   CaseEye — shared UX polish layer
   ----------------------------------------------------------------------------
   Loaded AFTER each page's inline <style> block, so consistent component rules
   win on equal specificity. Rules here are intentionally additive or
   self-contained (messages, empty states, focus, scrollbars) so they unify the
   look across pages without altering page-specific layout.
   ============================================================================ */

:root {
  /* Semantic-colour safety net — same hex values already used app-wide, so any
     page can reference these without redefining them. Core palette
     (--bg/--surface/--accent/--danger/--text/--muted) is left untouched. */
  --success:      #3dba7e;
  --success-soft: rgba(61, 186, 126, .12);
  --green:        #4caf7d;
  --warn:         #f5c842;
  --yellow:       #f7c96a;
  --orange:       #f7a96a;
  --purple:       #b07aff;
  --danger-soft:  rgba(224, 82, 82, .1);
  --info-soft:    rgba(79, 142, 247, .1);
  --surface3:     #242938;
  --shadow:       0 4px 20px rgba(0, 0, 0, .35);
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, .25);
  --ring:         0 0 0 3px rgba(79, 142, 247, .35);
}

/* ---- Typography polish -------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

/* ---- Accessibility: always-visible keyboard focus ----------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}
/* Don't show the focus ring for mouse users that support :focus-visible */
*:focus:not(:focus-visible) { outline: none; }

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

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

/* ---- Buttons: consistent feedback (safe properties only) ---------------- */
button,
[type="button"],
[type="submit"],
[type="reset"],
.btn, .btn-sm, a.btn {
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease,
              box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
}
button:active, .btn:active, .btn-sm:active { transform: translateY(1px); }
button:disabled,
[type="submit"]:disabled,
[type="button"]:disabled,
.btn:disabled,
.btn-sm:disabled,
[disabled],
[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: .55 !important;
  transform: none !important;
  filter: grayscale(.2);
}

/* ---- Form controls: gentle focus fallback ------------------------------- */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); cursor: pointer; }

/* ---- Unified message banners ------------------------------------------- */
/* Inline single-line banners */
.error-banner, .success-banner, .info-banner, .alert, .flash {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .8rem 1rem;
  border-radius: 10px;
  font-size: .88rem;
  line-height: 1.45;
  font-weight: 500;
  border: 1px solid transparent;
  margin-bottom: 1rem;
}
/* Richer message cards that may contain headings/multi-line content */
.error-box, .success-box {
  padding: 1rem 1.15rem;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 1rem;
  line-height: 1.5;
}
/* Colour variants */
.error-banner, .error-box, .alert-error, .alert-danger, .flash-error, .flash-danger {
  background: var(--danger-soft);
  border-color: rgba(224, 82, 82, .32);
  color: #f0a8a8;
}
.success-banner, .success-box, .alert-success, .flash-success {
  background: var(--success-soft);
  border-color: rgba(61, 186, 126, .32);
  color: #84e3b4;
}
.info-banner, .alert-info, .flash-info, .flash {
  background: var(--info-soft);
  border-color: rgba(79, 142, 247, .32);
  color: #9fc6ff;
}
.alert { background: rgba(79, 142, 247, .08); border-color: rgba(79, 142, 247, .22); }

/* ---- Unified empty states ---------------------------------------------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius, 10px);
  padding: 2.6rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.empty-state .icon,
.empty-state-icon {
  font-size: 2.2rem;
  margin-bottom: .6rem;
  opacity: .75;
  line-height: 1;
}
.empty-state-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
}
.empty-state p,
.empty-state-hint {
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
}

/* ---- Loading spinner utility (opt-in) ----------------------------------- */
.ce-spinner {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: ce-spin .6s linear infinite;
}
.ce-spinner-lg { width: 2rem; height: 2rem; border-width: 3px; }
@keyframes ce-spin { to { transform: rotate(360deg); } }
.is-loading { position: relative; pointer-events: none; opacity: .65; cursor: wait; }

/* ---- Custom scrollbars -------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--surface3); }

/* ---- Selection ---------------------------------------------------------- */
::selection { background: rgba(79, 142, 247, .35); color: #fff; }

/* ---- Responsive guards -------------------------------------------------- */
img, svg, video, canvas { max-width: 100%; }
@media (max-width: 600px) {
  /* Comfortable tap targets on touch screens */
  button, .btn, a.btn, .btn-sm,
  input[type="submit"], input[type="button"] { min-height: 40px; }
}
