/* ============================================================
   PAT Manager — Main Stylesheet
   Dark theme, professional SaaS aesthetic
   ============================================================ */

@import url('./fonts/fonts.css'); /* Self-hosted — run setup/download-fonts.sh after first deploy */

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --bg:          #080a0e;
  --bg-raised:   #0e1117;
  --surface:     #13181f;
  --surface-2:   #1a2030;
  --border:      #1e2736;
  --border-2:    #2a3547;

  --accent:      #00d68f;
  --accent-dim:  rgba(0,214,143,0.12);
  --accent-glow: rgba(0,214,143,0.06);
  --accent2:     #3b82f6;
  --accent2-dim: rgba(59,130,246,0.12);

  --pass:        #00d68f;
  --pass-dim:    rgba(0,214,143,0.12);
  --fail:        #f43f5e;
  --fail-dim:    rgba(244,63,94,0.12);
  --warn:        #f97316;
  --warn-dim:    rgba(249,115,22,0.12);
  --adv:         #eab308;
  --adv-dim:     rgba(234,179,8,0.12);

  --text:        #e2e8f4;
  --text-2:      #94a3b8;
  --muted:       #6e84a0;  /* was #4e6077 — raised to pass WCAG AA 4.5:1 */

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius:    8px;
  --radius-sm: 5px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.4);
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  background-image: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0,214,143,0.04) 0%, transparent 60%);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================ SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}
.logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); display: block; text-decoration: none; }
.logo-mark  { font-family: var(--mono); font-size: 9px; color: var(--accent); letter-spacing: 0.25em; text-transform: uppercase; }
.logo-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; margin-top: 5px; line-height: 1.2; }
.logo-sub   { font-size: 10px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section { font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; padding: 14px 18px 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--text-2); font-size: 13px; font-weight: 450; text-decoration: none; border-left: 2px solid transparent; transition: all 0.12s ease; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); border-left-color: var(--border-2); }
.nav-item.active { color: var(--accent); background: var(--accent-glow); border-left-color: var(--accent); font-weight: 500; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }

.sidebar-user { padding: 14px 18px; border-top: 1px solid var(--border); background: var(--bg-raised); }
.sidebar-user-name  { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-family: var(--mono); font-size: 9px; font-weight: 500; margin-top: 2px; letter-spacing: 0.05em; }
.sidebar-user-email { font-size: 10px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); text-decoration: none; letter-spacing: 0.08em; text-transform: uppercase; transition: color 0.12s; }
.sidebar-logout:hover { color: var(--fail); }
.sidebar-footer { padding: 10px 18px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 9px; color: var(--muted); line-height: 1.6; }
.dot-online { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 4px; box-shadow: 0 0 6px var(--accent); }

/* ============================================================ MAIN */
#main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--topbar-h); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 28px; gap: 14px; background: rgba(8,10,14,0.85); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 40; }
.topbar h1 { font-size: 14px; font-weight: 600; flex: 1; color: var(--text); letter-spacing: -0.01em; }
.topbar-badge { font-family: var(--mono); font-size: 9px; font-weight: 500; padding: 3px 9px; border-radius: var(--radius-sm); background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,214,143,0.2); letter-spacing: 0.1em; text-transform: uppercase; }
.content { flex: 1; padding: 28px 32px; }

/* ============================================================ STAT CARDS */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.stat-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); opacity: 0.8; }
.stat-card.warn::before { background: var(--warn); }
.stat-card.fail::before { background: var(--fail); }
.stat-card.info::before { background: var(--accent2); }
.stat-label { font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--text); }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.fail .stat-value { color: var(--fail); }
.stat-card.info .stat-value { color: var(--accent2); }

/* ============================================================ TABLES */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.table-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg-raised); }
.table-title { font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; }
table { width: 100%; border-collapse: collapse; }
th { font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; padding: 10px 20px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-raised); }
td { padding: 11px 20px; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 13px; color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: rgba(255,255,255,0.025); }

/* ============================================================ BADGES */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.badge-pass { background: var(--pass-dim); color: var(--pass); }
.badge-fail { background: var(--fail-dim); color: var(--fail); }
.badge-adv  { background: var(--adv-dim);  color: var(--adv); }
.badge-info { background: var(--accent2-dim); color: var(--accent2); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.asset-tag  { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-dim); padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid rgba(0,214,143,0.15); letter-spacing: 0.03em; }

/* ============================================================ BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: var(--sans); font-size: 13px; font-weight: 500; text-decoration: none; transition: all 0.12s ease; white-space: nowrap; letter-spacing: -0.01em; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #021a0f; font-weight: 600; box-shadow: 0 1px 3px rgba(0,214,143,0.3); }
.btn-primary:hover { background: #00eea0; box-shadow: 0 2px 8px rgba(0,214,143,0.4); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); background: rgba(255,255,255,0.04); }
.btn-danger { background: var(--fail-dim); color: var(--fail); border: 1px solid rgba(244,63,94,0.2); }
.btn-danger:hover { background: rgba(244,63,94,0.2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ============================================================ FORMS */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.form-title { font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: span 3; }
label { font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
input, select, textarea { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--sans); font-size: 13px; padding: 9px 12px; outline: none; width: 100%; transition: border-color 0.12s, box-shadow 0.12s; -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,214,143,0.1); }
input::placeholder { color: var(--muted); }
select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ============================================================ SECTION HEADER */
.section-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.section-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }

/* ============================================================ FILTER BAR */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { max-width: 220px; }

/* ============================================================ ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; }
.alert-success { background: var(--pass-dim); border: 1px solid rgba(0,214,143,0.25); color: var(--pass); }
.alert-error   { background: var(--fail-dim); border: 1px solid rgba(244,63,94,0.25);  color: var(--fail); }
.alert-warn    { background: var(--warn-dim); border: 1px solid rgba(249,115,22,0.25); color: var(--warn); }
.alert-info    { background: var(--accent2-dim); border: 1px solid rgba(59,130,246,0.25); color: var(--accent2); }

/* ============================================================ EMPTY STATES */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }
.empty p { font-size: 13px; color: var(--text-2); }

/* ============================================================ URGENCY */
.days-overdue { color: var(--fail); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.days-soon    { color: var(--warn); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.days-ok      { color: var(--pass); font-family: var(--mono); font-size: 11px; }

/* ============================================================ TRIAL BANNER */
.trial-banner { display: inline-flex; align-items: center; gap: 8px; background: var(--warn-dim); border: 1px solid rgba(249,115,22,0.25); color: var(--warn); font-family: var(--mono); font-size: 10px; font-weight: 500; padding: 4px 12px; border-radius: var(--radius-sm); white-space: nowrap; letter-spacing: 0.05em; }
.trial-banner a { color: var(--accent); text-decoration: none; font-weight: 600; }
.trial-banner a:hover { text-decoration: underline; }

/* ============================================================ UTILITIES */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.text-pass { color: var(--pass); }
.text-fail { color: var(--fail); }
.text-warn { color: var(--warn); }
.text-accent { color: var(--accent); }
code { font-family: var(--mono); font-size: 12px; background: var(--bg-raised); border: 1px solid var(--border); padding: 1px 6px; border-radius: 3px; color: var(--accent); }

/* ============================================================ PRINT */
@media print {
  #sidebar, .topbar, .filter-bar, .form-card, .section-header .btn { display: none !important; }
  #main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  body { background: white !important; color: black !important; font-size: 11px !important; }
  .table-wrap { border: 1px solid #ccc !important; box-shadow: none !important; background: white !important; }
  th, td { color: black !important; border-color: #ddd !important; }
  .badge-pass { color: #166534 !important; background: #dcfce7 !important; }
  .badge-fail { color: #991b1b !important; background: #fee2e2 !important; }
  .asset-tag  { color: #1e3a5f !important; background: #dbeafe !important; }
  table { font-size: 10px !important; }
  th, td { padding: 5px 10px !important; }
}

/* ============================================================ RESPONSIVE */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .content { padding: 20px; }
}

/* ── Skip navigation (accessibility) ────────────────────── */
.skip-nav {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 10px 16px;
  background: var(--accent);
  color: #021a0f;
  font-weight: 700;
  font-size: 13px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top 0.1s;
}
.skip-nav:focus {
  top: 0;
}

/* ── Focus visible — keyboard navigation ─────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Remove outline for mouse users, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}
/* Override for inputs — always show focus ring */
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,214,143,0.15);
  outline: none; /* outline handled by box-shadow */
}

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

/* ── Minimum text sizes ──────────────────────────────────── */
/* Ensure labels are readable (was 9px — bumped to 11px minimum) */
label,
.nav-section,
.form-title,
.table-title,
.stat-label,
.topbar-badge,
th {
  font-size: max(11px, 0.79rem);
}

/* ── Error state — not colour alone ─────────────────────── */
.alert-error::before  { content: '⚠ '; }
.alert-success::before { content: '✓ '; }
.alert-warn::before   { content: '⚠ '; }
.alert-info::before   { content: 'ℹ '; }

/* ── Badge contrast improvements ────────────────────────── */
/* Ensure fail/pass badges meet 4.5:1 against their backgrounds */
.badge-pass { color: #166534; background: #dcfce7; }
.badge-fail { color: #9b1c2e; background: #fce7eb; }
.badge-adv  { color: #854d0e;  background: #fef9c3; }
.badge-info { color: #1d4ed8; background: #dbeafe; } /* blue — dark enough on light bg */
.badge-warn { color: #92400e; background: #fef3c7; }
.days-overdue { color: #be123c; }
.days-soon    { color: #c2410c; } /* darker orange */

/* ── Muted text — improve contrast ──────────────────────── */
/* --muted was #4e6077, ratio ~3.8:1. Bump to pass AA for large text */
/* For body text contexts, use --text-2 (#94a3b8) which is ~5.3:1 */

/* ── Screen reader only utility ──────────────────────────── */
.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;
}
