/* ============================================================
   rc3.1 Modern dashboard polish layer
   Loaded AFTER app.css, BEFORE theme.css.
   - Neutral, theme-safe quality pass (radius, focus, motion, type)
   - Derives brand-based tints so every theme stays on-brand.
   Nothing here hard-codes a dark or light scheme; colors come
   from each theme's CSS variables.
   ============================================================ */

/* Derived brand tints (resolve per page, following the brand color) */
body.template-user, body {
    --primary-soft: color-mix(in srgb, var(--primary, #246b61) 10%, var(--surface, #ffffff));
    --primary-sheer: color-mix(in srgb, var(--primary, #246b61) 9%, transparent);
    --primary-line: color-mix(in srgb, var(--primary, #246b61) 40%, transparent);
    --primary-ink: color-mix(in srgb, var(--primary, #246b61) 90%, #000000);
    --ring: color-mix(in srgb, var(--primary, #246b61) 32%, transparent);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---------- Typography ---------- */
body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2, h3 {
    letter-spacing: -0.015em;
}

h1 {
    font-weight: 800;
}

.eyebrow {
    letter-spacing: 0.14em;
    font-size: 0.72rem;
}

.app-body, .row-cell-link, .nav-label { white-space: normal; }

/* ---------- Topbar ---------- */
.topbar {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.topbar-title strong {
    letter-spacing: -0.01em;
}

/* ---------- Surfaces ---------- */
.panel, .login-panel {
    transition: border-color .18s ease, box-shadow .18s ease;
}

.panel:hover {
    z-index: 1;
}

.requirement-row,
.summary-list > div,
.checklist-item,
.choice,
.step,
.ticket-message {
    transition: border-color .16s ease, background .16s ease;
}

.step.is-active {
    box-shadow: inset 0 -1px 0 var(--primary-line);
}

/* ---------- Forms ---------- */
input, textarea, select {
    border-radius: 10px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-line) !important;
    box-shadow: 0 0 0 3px var(--ring);
}

label {
    letter-spacing: 0.01em;
}

input::placeholder, textarea::placeholder {
    opacity: 0.72;
}

/* ---------- Buttons ---------- */
.button {
    min-height: 44px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .05s ease;
}

.button:hover {
    background: var(--primary-ink);
    border-color: var(--primary-ink);
}

.button:active { transform: translateY(1px); }

.button-secondary {
    background: var(--surface);
    color: var(--text);
}

.button-secondary:hover {
    background: var(--surface-strong);
    border-color: var(--line);
    color: var(--text);
}

/* ---------- Links ---------- */
a { transition: color .15s ease; }
a:hover { text-decoration-color: currentColor; }

/* ---------- Tables ---------- */
.data-table th {
    border-bottom: 1px solid var(--line);
    letter-spacing: 0.07em;
    font-size: 0.72rem;
}

.data-table tr:hover td {
    background: var(--primary-sheer);
}

/* ---------- Status pills ---------- */
.status { border: 1px solid transparent; }
.status-pass { border-color: color-mix(in srgb, var(--success, #1f7a4d) 26%, transparent); }
.status-fail { border-color: color-mix(in srgb, var(--danger, #b42318) 26%, transparent); }

/* ---------- Keyboard focus everywhere ---------- */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- Selection matches the brand ---------- */
::selection {
    background: var(--primary);
    color: #fff;
}

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

/* ---------- Responsive refinement ---------- */
@media (max-width: 700px) {
    .panel, .login-panel { padding: 1.15rem; }
    .topbar { padding-top: 0.75rem; padding-bottom: 0.75rem; }
}

/* ============================================================
   SaaS dashboard (client + admin) components
   ============================================================ */

/* Friendly page lead */
.dashboard-lead {
    max-width: 620px;
    margin-bottom: 1.1rem;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.5;
}

/* Stat cards row */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.6rem 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.15rem 1.25rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 45%, transparent));
    opacity: 0.9;
}

.stat-card:hover {
    box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 14%, transparent);
    transform: translateY(-2px);
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.stat-value {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    font-size: clamp(1.35rem, 3vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.stat-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Status dot used inside stat values */
.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
}

.status-dot.is-active {
    background: var(--success, #1f7a4d);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--success, #1f7a4d) 20%, transparent);
}

.status-dot.is-inactive {
    background: var(--muted);
}

/* Quick actions */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.6rem;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 60px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.quick-action:hover {
    border-color: var(--primary-line);
    background: var(--primary-soft);
    color: var(--primary-ink);
    box-shadow: 0 10px 24px var(--primary-sheer);
    transform: translateY(-1px);
    text-decoration: none;
}

.quick-marker {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 3px;
    background: var(--primary);
}

.quick-grid .quick-action { flex: 1 1 0; }

/* Brand accent bar on auth panels */
.login-panel {
    position: relative;
    overflow: hidden;
}

.login-panel::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 45%, transparent));
}

/* Auth pages: headed brand + subtitle + action links */
.auth-head {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-head .login-logo {
    max-height: 56px;
    margin: 0 auto 1.1rem auto;
    display: block;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted, #047857);
    margin: 0 0 0.35rem 0;
}

.login-subtitle {
    text-align: center;
    color: var(--muted, #666);
    margin: 0 0 1.4rem 0;
}

.auth-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.15rem;
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid color-mix(in srgb, var(--primary, #246b61) 18%, transparent);
    font-size: 0.85rem;
}

.auth-links a {
    display: block;
    color: var(--primary, #246b61);
    font-weight: 600;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Action buttons in page heading stay balanced */
.page-heading .button-row {
    margin-top: 0;
}

/* Responsive refinement for the SaaS grids */
@media (max-width: 640px) {
    .stat-grid, .quick-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .stat-grid, .quick-grid {
        grid-template-columns: 1fr;
    }
}