/* ==========================================================================
   VISIBILITY & POLISH — "No Squinting" Design Override
   Purpose: Fix low-contrast text, enforce tactile buttons, crisp inputs.
   Load AFTER output.css and high-density.css so these take priority.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Text — high-contrast palette */
  --vp-text-primary:   #0f172a;  /* slate-900 */
  --vp-text-secondary: #334155;  /* slate-700 */
  --vp-text-tertiary:  #475569;  /* slate-600 — minimum for body copy */
  --vp-text-muted:     #64748b;  /* slate-500 — only for captions/timestamps */
  --vp-text-on-dark:   #f1f5f9;  /* slate-100 */

  /* Surfaces */
  --vp-input-bg:       #ffffff;
  --vp-input-border:   #cbd5e1;  /* slate-300 */
  --vp-input-focus:    #0f172a;  /* slate-900 — focus ring matches new primary */
  --vp-input-ring:     rgba(15, 23, 42, 0.15);

  /* Buttons */
  --vp-btn-primary:    #0f172a;  /* slate-900 */
  --vp-btn-primary-h:  #1e293b;  /* slate-800 */
  --vp-btn-danger:     #dc2626;
  --vp-btn-danger-bg:  #fef2f2;
  --vp-btn-danger-h:   #fee2e2;
  --vp-btn-danger-bd:  #fecaca;

  /* Shadows — tactile depth */
  --vp-shadow-btn: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.10);
  --vp-shadow-input: 0 1px 2px rgba(0,0,0,0.05);
  --vp-shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

html.dark {
  --vp-text-primary:   #f1f5f9;  /* slate-100 */
  --vp-text-secondary: #e2e8f0;
  --vp-text-tertiary:  #cbd5e1;
  --vp-text-muted:     #94a3b8;
  --vp-text-on-dark:   #f1f5f9;

  --vp-input-bg:       #1e293b;
  --vp-input-border:   #475569;
  --vp-input-focus:    #e2e8f0;
  --vp-input-ring:     rgba(226, 232, 240, 0.2);

  --vp-btn-primary:    #e2e8f0;
  --vp-btn-primary-h:  #f1f5f9;

  --vp-btn-danger-bg:  rgba(220, 38, 38, 0.1);
  --vp-btn-danger-h:   rgba(220, 38, 38, 0.2);
  --vp-btn-danger-bd:  rgba(220, 38, 38, 0.3);

  --vp-shadow-btn: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --vp-shadow-input: 0 1px 2px rgba(0,0,0,0.2);
  --vp-shadow-card: 0 2px 4px rgba(0,0,0,0.3);
}


/* --------------------------------------------------------------------------
   1. GLOBAL TEXT — The "No Squinting" Rule
   -------------------------------------------------------------------------- */

/* Body text baseline */
body {
  color: var(--vp-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Boost low-contrast Tailwind text classes used on DATA fields.
   We target these inside main content areas, NOT inside icons. */
main .text-gray-400,
main .text-neutral-400,
[role="main"] .text-gray-400,
[role="main"] .text-neutral-400 {
  color: var(--vp-text-tertiary) !important;
}

main .text-gray-500,
main .text-neutral-500,
[role="main"] .text-gray-500,
[role="main"] .text-neutral-500 {
  color: var(--vp-text-muted) !important;
}

/* Table headers — must be readable */
th,
thead th,
.hd-table thead th {
  color: var(--vp-text-secondary) !important;
  font-weight: 600;
}
html.dark th,
html.dark thead th,
html.dark .hd-table thead th {
  color: var(--vp-text-tertiary) !important;
}

/* Table body cells */
td,
.hd-table tbody td {
  color: var(--vp-text-primary);
}
html.dark td,
html.dark .hd-table tbody td {
  color: var(--vp-text-secondary);
}

/* Definition lists / detail labels  */
dt, .detail-label, .stat-label {
  color: var(--vp-text-secondary);
  font-weight: 600;
}
dd, .detail-value, .stat-value {
  color: var(--vp-text-primary);
}


/* --------------------------------------------------------------------------
   2. FORM LABELS — Prominent & Crisp
   -------------------------------------------------------------------------- */
label,
.form-label,
.hd-sidebar-label {
  font-weight: 600;
  color: var(--vp-text-secondary);
  font-size: 0.8125rem; /* 13px */
  letter-spacing: 0.01em;
}
html.dark label,
html.dark .form-label,
html.dark .hd-sidebar-label {
  color: var(--vp-text-tertiary);
}


/* --------------------------------------------------------------------------
   3. INPUT FIELDS — "Physical Fields" — Distinct Borders & Focus Ring
   -------------------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
textarea,
select {
  background-color: var(--vp-input-bg);
  border: 1px solid var(--vp-input-border);
  border-radius: 8px;
  color: var(--vp-text-primary);
  box-shadow: var(--vp-shadow-input);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

input:focus,
textarea:focus,
select:focus {
  border-color: transparent !important;
  box-shadow: 0 0 0 2px var(--vp-input-focus) !important;
  outline: none;
}

/* Placeholder text */
input::placeholder,
textarea::placeholder {
  color: #94a3b8;  /* slate-400 */
  opacity: 1;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748b;
}

/* Select arrow — ensure visible */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}
html.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Disabled variant */
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #f8fafc;
}
html.dark input:disabled,
html.dark textarea:disabled,
html.dark select:disabled {
  background-color: #0f172a;
}


/* --------------------------------------------------------------------------
   4. BUTTON HIERARCHY — The "Master Mold"
   -------------------------------------------------------------------------- */

/* --- Primary CTA — Solid, authoritative --- */
.btn-primary,
button[type="submit"]:not(.btn-secondary):not(.btn-outline):not(.btn-danger):not(.hd-action):not(.hd-row-action):not(.hd-filter-tab) {
  background-color: var(--vp-btn-primary);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  box-shadow: var(--vp-shadow-btn);
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 100ms ease;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.5;
}
.btn-primary:hover,
button[type="submit"]:not(.btn-secondary):not(.btn-outline):not(.btn-danger):not(.hd-action):not(.hd-row-action):not(.hd-filter-tab):hover {
  background-color: var(--vp-btn-primary-h);
  box-shadow: 0 2px 4px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.btn-primary:active,
button[type="submit"]:not(.btn-secondary):not(.btn-outline):not(.btn-danger):not(.hd-action):not(.hd-row-action):not(.hd-filter-tab):active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Dark mode primary inverts */
html.dark .btn-primary,
html.dark button[type="submit"]:not(.btn-secondary):not(.btn-outline):not(.btn-danger):not(.hd-action):not(.hd-row-action):not(.hd-filter-tab) {
  background-color: var(--vp-btn-primary);
  color: #0f172a;
}
html.dark .btn-primary:hover,
html.dark button[type="submit"]:not(.btn-secondary):not(.btn-outline):not(.btn-danger):not(.hd-action):not(.hd-row-action):not(.hd-filter-tab):hover {
  background-color: var(--vp-btn-primary-h);
}

/* --- Secondary Button — Clean, tactile --- */
.btn-secondary {
  background-color: #ffffff;
  color: var(--vp-text-secondary);
  font-weight: 600;
  border: 1px solid var(--vp-input-border);
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  box-shadow: var(--vp-shadow-btn);
  transition: background-color 150ms ease, box-shadow 150ms ease;
  cursor: pointer;
  font-size: 0.875rem;
}
.btn-secondary:hover {
  background-color: #f8fafc;  /* slate-50 */
  border-color: #94a3b8;
}
html.dark .btn-secondary {
  background-color: #1e293b;
  border-color: #475569;
  color: var(--vp-text-secondary);
}
html.dark .btn-secondary:hover {
  background-color: #334155;
}

/* --- Outline Button --- */
.btn-outline {
  background-color: transparent;
  color: var(--vp-text-secondary);
  font-weight: 600;
  border: 1px solid var(--vp-input-border);
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  transition: background-color 150ms ease, border-color 150ms ease;
  cursor: pointer;
  font-size: 0.875rem;
}
.btn-outline:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
}

/* --- Destructive / Danger Button --- */
.btn-danger {
  background-color: var(--vp-btn-danger-bg);
  color: var(--vp-btn-danger);
  font-weight: 600;
  border: 1px solid var(--vp-btn-danger-bd);
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  box-shadow: var(--vp-shadow-btn);
  transition: background-color 150ms ease;
  cursor: pointer;
  font-size: 0.875rem;
}
.btn-danger:hover {
  background-color: var(--vp-btn-danger-h);
}


/* --------------------------------------------------------------------------
   5. CARDS — Tactile Depth
   -------------------------------------------------------------------------- */
.card,
.hd-card,
.hd-stat-card {
  box-shadow: var(--vp-shadow-card);
  border-color: var(--vp-input-border);
}
.hd-stat-card .hd-stat-label {
  color: var(--vp-text-secondary) !important;
  font-weight: 600;
}
html.dark .hd-stat-card .hd-stat-label {
  color: var(--vp-text-muted) !important;
}
.hd-stat-card .hd-stat-value {
  color: var(--vp-text-primary) !important;
}


/* --------------------------------------------------------------------------
   6. ICON STANDARDS — Consistent Size & Weight (1.5-2px engineered feel)
   -------------------------------------------------------------------------- */

/* Standardize sidebar/nav icons */
nav svg,
.sidebar-link svg,
aside nav svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

/* Control/action icons */
button svg,
a svg,
.hd-action svg {
  stroke-width: 1.5;
}

/* Metadata/badge icons — smaller */
.badge svg,
.hd-status svg,
.text-xs svg,
.text-sm svg:not(button svg) {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}


/* --------------------------------------------------------------------------
   7. SIDEBAR POLISH
   -------------------------------------------------------------------------- */
aside nav a,
.sidebar-link {
  color: var(--vp-text-secondary);
  font-weight: 500;
}
aside nav a:hover,
.sidebar-link:hover {
  color: var(--vp-text-primary);
}
aside nav a svg,
.sidebar-link svg {
  color: var(--vp-text-muted);
  transition: color 150ms ease;
}
aside nav a:hover svg,
.sidebar-link:hover svg {
  color: var(--vp-text-secondary);
}

/* Active sidebar link — boost icon color */
aside nav a.bg-primary-50 svg,
aside nav a[class*="text-primary-700"] svg {
  color: #2563eb;
}
html.dark aside nav a.bg-primary-50 svg,
html.dark aside nav a[class*="text-primary-300"] svg {
  color: #60a5fa;
}


/* --------------------------------------------------------------------------
   8. RESPONSIVE INPUT TOUCH TARGETS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  textarea,
  select {
    font-size: 1rem;    /* prevent iOS zoom */
    padding: 0.625rem 0.875rem;
    min-height: 44px;   /* Apple HIG touch target */
  }

  .btn-primary,
  .btn-secondary,
  .btn-outline,
  .btn-danger,
  button[type="submit"] {
    min-height: 44px;
    font-size: 1rem;
    padding: 0.625rem 1.5rem;
  }
}


/* --------------------------------------------------------------------------
   9. GRADIENT KILL — Enforce Visibility on Body Text & Inputs
   --------------------------------------------------------------------------
   Removes bg-clip-text / text-transparent from standard content areas.
   Hero section (inside .relative.min-h-screen) is intentionally excluded.
   -------------------------------------------------------------------------- */

/* Kill invisible gradient text on body content, headers, inputs */
main h1, main h2, main h3, main h4, main h5, main h6,
main p, main span, main a, main li, main td, main th,
main label, main dt, main dd,
[role="main"] h1, [role="main"] h2, [role="main"] h3,
[role="main"] h4, [role="main"] h5, [role="main"] h6,
[role="main"] p, [role="main"] span, [role="main"] a {
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: unset !important;
}

/* Enforce high-contrast text on light backgrounds */
main h1, main h2, main h3, main h4,
[role="main"] h1, [role="main"] h2, [role="main"] h3, [role="main"] h4 {
  color: var(--vp-text-primary);
}
main p, main li, main td,
[role="main"] p, [role="main"] li, [role="main"] td {
  color: var(--vp-text-secondary);
}

/* Dark mode contrast enforcement */
html.dark main h1, html.dark main h2, html.dark main h3, html.dark main h4,
html.dark [role="main"] h1, html.dark [role="main"] h2,
html.dark [role="main"] h3, html.dark [role="main"] h4 {
  color: var(--vp-text-on-dark);
}
html.dark main p, html.dark main li, html.dark main td,
html.dark [role="main"] p, html.dark [role="main"] li,
html.dark [role="main"] td {
  color: var(--vp-text-tertiary);
}
