/* ===== DESIGN TOKENS ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #0ea5e9;
    --info-light: #e0f2fe;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;

    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255,255,255,0.07);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;

    --bg-body: #f1f5f9;
    --surface: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* ===== BASE ===== */
html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a, .btn-link { color: var(--primary); }
h1:focus { outline: none; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0);    }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0);    }
}

.animate-card { animation: fadeInUp 0.4s ease both; }
.animate-card:nth-child(1) { animation-delay: 0.05s; }
.animate-card:nth-child(2) { animation-delay: 0.10s; }
.animate-card:nth-child(3) { animation-delay: 0.15s; }
.animate-card:nth-child(4) { animation-delay: 0.20s; }
.animate-card:nth-child(5) { animation-delay: 0.25s; }
.animate-card:nth-child(6) { animation-delay: 0.30s; }
.animate-card:nth-child(7) { animation-delay: 0.35s; }
.animate-card:nth-child(8) { animation-delay: 0.40s; }
.animate-card:nth-child(n+9) { animation-delay: 0.45s; }

/* ===== STAT CARDS ===== */
.stat-card {
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    border: none;
    color: white;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: -30%; right: -10%;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    pointer-events: none;
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20%; right: 10%;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.2);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    position: relative; z-index: 1;
}
.stat-value {
    font-size: 2rem; font-weight: 700; line-height: 1;
    position: relative; z-index: 1;
}
.stat-label {
    font-size: 0.8125rem; opacity: 0.85;
    margin-top: 0.25rem;
    position: relative; z-index: 1;
}
.stat-card.stat-primary { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.stat-card.stat-success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stat-card.stat-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.stat-card.stat-info    { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); }
.stat-card.stat-purple  { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }

/* ===== SURFACE CARD ===== */
.qp-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ===== MACHINE CARD ===== */
.machine-card {
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    position: relative;
    overflow: hidden;
}
.machine-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--border-color);
    transition: background 0.2s;
}
.machine-card.pass::before { background: linear-gradient(90deg, var(--success), #34d399); }
.machine-card.fail::before { background: linear-gradient(90deg, var(--danger), #f87171); }
.machine-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

/* ===== STATUS BADGE ===== */
.status-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.6875rem; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase;
}
.status-badge.pass { background: var(--success-light); color: #065f46; }
.status-badge.fail { background: var(--danger-light);  color: #991b1b; }

/* ===== LOADING ===== */
.qp-spinner {
    width: 38px; height: 38px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

/* ===== MODAL ===== */
.qp-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
    padding: 1rem;
}
.qp-modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
    max-width: 960px; width: 100%;
    max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column;
    animation: slideInRight 0.28s ease;
}
.qp-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.qp-modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.qp-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: 0.5rem;
    flex-shrink: 0;
}

/* ===== CLOSE BUTTON ===== */
.btn-icon-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon-close:hover { background: var(--bg-body); color: var(--text-primary); }

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--primary); border-color: var(--primary); color: white;
    border-radius: var(--radius); font-weight: 500;
    transition: all 0.15s;
}
.btn-primary:hover {
    background: var(--primary-dark); border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    color: white;
}
.btn-outline-secondary {
    border-radius: var(--radius); font-weight: 500;
    transition: all 0.15s;
}

/* ===== TABLE ===== */
.qp-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.qp-table th {
    background: var(--bg-body);
    color: var(--text-secondary);
    font-size: 0.6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.qp-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem; vertical-align: middle;
}
.qp-table tbody tr:last-child td { border-bottom: none; }
.qp-table tbody tr:hover td { background: #fafbfc; }

/* ===== TEST SESSION ===== */
.test-session {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem; overflow: hidden;
}
.test-session-header {
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem;
}
.test-section-title {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 0.875rem 1.25rem 0.375rem;
    display: flex; align-items: center; gap: 0.375rem;
}

/* ===== INFO CHIP ===== */
.info-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.75rem; color: var(--text-secondary);
}

/* ===== PAGE HEADER ===== */
.page-header { margin-bottom: 1.5rem; }
.page-title {
    font-size: 1.375rem; font-weight: 700;
    color: var(--text-primary); margin: 0;
    display: flex; align-items: center; gap: 0.5rem;
}
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* ===== SIDEBAR LINKS ===== */
/* NavLink renders <a> internally so these must be global, not scoped */
a.sidebar-link {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    border: 1px solid transparent;
    color: #94a3b8;
    text-decoration: none !important;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    font-size: 0.9375rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
a.sidebar-link:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.08);
    color: #f1f5f9;
    text-decoration: none !important;
}
a.sidebar-link.active {
    background: rgba(99,102,241,0.2);
    border-color: rgba(99,102,241,0.35);
    color: #a5b4fc;
}

.link-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
    background: rgba(255,255,255,0.06);
    color: #64748b;
    transition: background 0.15s, color 0.15s;
}
a.sidebar-link:hover .link-icon {
    background: rgba(255,255,255,0.1);
    color: #cbd5e1;
}
a.sidebar-link.active .link-icon {
    background: rgba(99,102,241,0.3);
    color: #a5b4fc;
}

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: linear-gradient(263deg, #fafafa 0%, #32cd32 65%);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.login-bg-glow {\n    display: none;\n}

.login-card {
    position: relative;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.60);
    border-radius: 1.25rem;
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    color: #1e293b;
    box-shadow: 0 32px 64px rgba(0,0,0,.15);
    animation: fadeInUp 0.45s ease both;
}

.login-logo {
    width: 250px;
    height: 96px;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 .5rem;
    line-height: 1.3;
}

.login-subtitle {
    font-size: .875rem;
    color: #475569;
    margin: 0;
    line-height: 1.6;
}

.login-divider {
    height: 1px;
    background: rgba(0,0,0,.08);
    margin: 2rem 0;
}

.btn-signin-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    width: 100%;
    background: white;
    color: #1e293b;
    border-radius: .625rem;
    padding: .8rem 1.25rem;
    font-weight: 600;
    font-size: .9375rem;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.btn-signin-microsoft:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    color: #1e293b;
    text-decoration: none;
}

.btn-signin-microsoft:active {
    transform: translateY(0);
}

.ms-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.login-footer-note {
    font-size: .75rem;
    color: #94a3b8;
    margin: 1.5rem 0 0;
}

/* ===== MISC ===== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #7f1d1d;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

#blazor-error-ui {
    background: #1e293b;
    color: #e2e8f0;
    bottom: 0; left: 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    display: none;
    padding: 0.75rem 1.5rem;
    position: fixed; width: 100%;
    z-index: 9999; font-size: 0.875rem;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute; right: 1rem; top: 0.75rem;
}

.darker-border-checkbox.form-check-input { border-color: #929292; }
