/* ===================================================================
   QA1 Inspection System - Primary Stylesheet
   Date: 2026-05-28
   Purpose: QA1 brand styles, layout, accessibility, and utility tokens.
            This is the primary stylesheet — not a Preline/Tailwind override.
   =================================================================== */

/* CSS Variables for QA1 Brand Colors */
:root {
    --qa-primary: #4CAF50;      /* Green (buttons, success) */
    --qa-secondary: #007bff;    /* Blue (dashboard, links) */
    --qa-background: #f4f6f8;   /* Light gray background */
    --qa-text-primary: #222;    /* Dark text */
    --qa-text-secondary: #666;  /* Gray text */
    --qa-border: #ddd;          /* Border gray */

    /* Semantic color tokens */
    --qa-danger: #DC2626;
    --qa-warn: #ff9800;
    --qa-info: #2196F3;
    --qa-accent: #4CAF50;
    --qa-text-muted: #6c757d;
    --qa-surface-alt: #f8f9fa;

    /* Z-index scale */
    --z-base: 0;
    --z-sticky: 100;
    --z-navbar: 1030;
    --z-modal: 2000;
    --z-overlay: 9000;
    --z-toast: 9500;
    --z-loading: 10000;
}

/* Global tap behavior (moved out of the Site.Master inline <style> so all of
   the master-page styling lives in one place). */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

/* Keep in-page anchor jumps, the #MainContent skip-link, and focus-scroll clear
   of the sticky header (otherwise the target lands behind the dark band). */
html {
    scroll-padding-top: 64px;
}

/* Body Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--qa-background);
    /* Faint technical grid so the white content card reads as a deliberate
       surface on a designed backdrop — not an unstyled default page. */
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.022) 1px, transparent 1px);
    background-size: 28px 28px;
    margin: 0;
    padding-top: 0;   /* navbar is position:sticky — it reserves its own height */
    line-height: 1.5;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;   /* no text scaling on rotation */
}

/* Main Container */
.container.body-content {
    background: white;
    padding: 15px;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;   /* prevent horizontal scroll on mobile */
}

/* Desktop Styles */
@media (min-width: 768px) {
    .container.body-content {
        padding: 30px;
        border-radius: 10px;
        box-shadow: 0 0 12px rgba(0,0,0,0.08);
        max-width: 900px;
        margin: 0 auto;
    }
}

/* Mobile Styles — full-bleed white card sits directly on white, so drop the
   grid backdrop (it would peek around the edges) and keep it clean. */
@media (max-width: 767px) {
    body {
        background-color: #fff;
        background-image: none;
    }

    .container.body-content {
        padding: 10px;   /* less padding on very small screens */
    }
}

/* Headings — Archivo display face + a real modular type scale (the app
   previously leaned on browser defaults, so hierarchy was mushy). */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    color: var(--qa-text-primary);
    line-height: 1.2;
    letter-spacing: -0.015em;
    margin-top: 0;
}
h1 { font-size: 2rem; }        /* 32px */
h2 { font-size: 1.5rem; }      /* 24px */
h3 { font-size: 1.25rem; }     /* 20px */
h4 { font-size: 1.0625rem; }   /* 17px */
h5 { font-size: 0.9375rem; }   /* 15px */
h6 {
    font-size: 0.8125rem;      /* 13px */
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--qa-text-secondary);
}

/* Buttons - QA1 colors; min-height ensures touch-target on pages without Site.Master */
.btn,
input[type="submit"],
input[type="button"],
button:not(.navbar-toggle) {
    background-color: var(--qa-primary);
    border: none;
    color: white;
    padding: 12px 24px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    margin: 5px;
    min-height: 44px;
    transition: background-color 0.2s ease;
}

.btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
button:not(.navbar-toggle):hover {
    background-color: #45a049;
}

/* Dashboard/Secondary Buttons */
.btn.dashboard-btn,
.btn-secondary {
    background-color: var(--qa-secondary);
}

.btn.dashboard-btn:hover,
.btn-secondary:hover {
    background-color: #0056b3;
}

/* Form Labels */
label,
.field-label {
    font-weight: bold;
    margin-top: 15px;
    display: block;
    color: var(--qa-text-primary);
}

/* Form Inputs — 16px minimum prevents iOS auto-zoom on focus */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 10px;
    font-family: inherit;
    font-size: 16px;
    border: 1px solid var(--qa-border);
    border-radius: 4px;
    transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--qa-primary);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Keyboard-focus visible outlines (a11y — restores removed outline).
   Page-level rules like .form-control:focus { outline: none } would otherwise
   beat these selectors on specificity; the explicit class selectors below
   match Dashboard/Profile's .form-control and .date-input usage and re-assert
   the green focus ring on equal terms. */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
.form-control:focus-visible,
.date-input:focus-visible {
    outline: 2px solid var(--qa-accent, #4CAF50);
    outline-offset: 2px;
}

/* Skip link — visually hidden until KEYBOARD focus (a11y).
   Uses the "clip" pattern (1px clipped box) so mouse/touch users never see
   it. It reveals ONLY on :focus-visible (keyboard Tab), not plain :focus —
   so if anything programmatically focuses it on load (a focus-trap, a script,
   browser focus restoration) it stays hidden. Pressing Tab reveals a clean
   button. !important guards against page-level rules resetting position. */
.skip-link {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap;
    border: 0;
    background: var(--qa-accent, #4CAF50);
    color: #fff;
    text-decoration: none;
}
.skip-link:focus-visible {
    position: fixed !important;
    top: 8px !important;
    left: 8px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 12px 16px !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
    z-index: var(--z-loading, 10000);
    border-radius: 4px;
}

/* Progress Bar */
.progress-bar-container {
    background-color: #e0e0e0;
    border-radius: 20px;
    height: 20px;
    overflow: hidden;
    margin-top: 10px;
}

#ProgressBar {
    background-color: var(--qa-primary);
    height: 100%;
    width: 0%;
    text-align: center;
    color: white;
    font-size: 12px;
    transition: width 0.4s ease;
}

/* Image Display */
.image-box img {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid var(--qa-border);
    padding: 5px;
    border-radius: 5px;
    background: #fafafa;
}

/* Navigation Bar — dark steel header with a brand-green accent stripe. */
.navbar {
    background-color: #1c1f22;
    border-color: #080808;
}

/* Sticky (not fixed): the dark header reserves its own height in normal flow,
   so it can never overlap page content no matter how many rows the nav wraps
   to on tablets — while still staying pinned to the top on scroll. This
   replaces the old fixed-navbar + body padding-top + JS height-measure hack. */
.navbar.navbar-fixed-top {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: var(--z-navbar, 1030);
    border-bottom: 3px solid var(--qa-accent, #4CAF50);   /* brand accent stripe */
}

/* Wordmark: Archivo, uppercase, with a green "mark" chip for identity. */
.navbar-brand {
    color: #fff !important;
    font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    height: auto;
    padding: 12px 15px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
}
.navbar-brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--qa-accent, #4CAF50);
    color: #fff;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    flex: 0 0 auto;
}
.navbar-brand .brand-soft {
    font-weight: 500;
    opacity: 0.82;
}

.navbar-nav > li > a {
    color: #fff !important;
}

.navbar-nav > li > a:hover {
    background-color: #444 !important;
}

/* Active nav indicator */
.navbar-nav > li.active > a,
.nav > li.active > a {
    color: var(--qa-accent, #4CAF50) !important;
    border-bottom: 3px solid var(--qa-accent, #4CAF50);
}

/* GridView / Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

table th {
    background-color: var(--qa-secondary);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

table td {
    padding: 10px;
    border-bottom: 1px solid var(--qa-border);
}

table tr:hover {
    background-color: #f9f9f9;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
}

.badge.bg-success,
.badge-success {
    background-color: var(--qa-primary);
    color: white;
}

.badge.bg-danger,
.badge-danger {
    background-color: #f44336;
    color: white;
}

.badge.bg-warning,
.badge-warning {
    background-color: #ff9800;
    color: white;
}

.badge.bg-secondary,
.badge-secondary {
    background-color: var(--qa-border);
    color: var(--qa-text-primary);
}

/* Alerts */
.alert {
    padding: 12px;
    border-radius: 4px;
    margin: 15px 0;
}

.alert-success {
    background-color: #e8f5e8;
    border: 1px solid var(--qa-primary);
    color: #2e7d32;
}

.alert-danger {
    background-color: #ffebee;
    border: 1px solid #f44336;
    color: #c62828;
}

.alert-warning {
    background-color: #fff3e0;
    border: 1px solid #ff9800;
    color: #e65100;
}

.alert-info {
    background-color: #e3f2fd;
    border: 1px solid var(--qa-secondary);
    color: #01579b;
}

/* Footer */
footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--qa-border);
    color: var(--qa-text-secondary);
    text-align: center;
}

/* Mobile Responsive (ported from the Site.Master inline <style> so all
   master-page styling lives in the stylesheet). */
@media screen and (max-width: 767px) {
    .image-section {
        flex-direction: column;
    }

    /* Full-width, easy-to-tap actions on phones/small tablets. */
    .btn,
    input[type="submit"],
    input[type="button"],
    button:not(.navbar-toggle) {
        width: 100%;
        margin-bottom: 10px;
        padding: 16px 24px;
        font-size: 18px;
    }

    label,
    .field-label {
        margin-top: 20px;
        margin-bottom: 8px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    textarea,
    select {
        margin-bottom: 15px;
    }

    /* Let wide GridView tables scroll horizontally instead of breaking layout. */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Bigger checkbox / radio hit targets. */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
        margin-right: 10px;
    }

    /* Breathing room for the collapsed nav menu. */
    .navbar-nav {
        margin-top: 10px;
        margin-bottom: 10px;
    }
    .navbar-nav > li > a {
        padding: 12px 15px;
    }
}

/* Text Utilities */
.text-muted {
    color: var(--qa-text-secondary);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Card/Panel Styling */
.panel,
.card {
    background: white;
    border: 1px solid var(--qa-border);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.panel-heading,
.card-header {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--qa-border);
}

/* Loading Spinner (for async operations) */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--qa-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Override background-image reset for ASP.NET Web Forms button compatibility */
input[type='button'],
input[type='submit'],
button {
    background-image: none;
}

/* Ensure form elements don't get unexpected resets */
form {
    margin: 0;
}

/* Reduced-motion: disable decorative animations for users who prefer it.
   Elements with data-keep-motion="true" are exempt — used for the loading
   spinner / progress indicators, which are the user's only signal that a
   long-running postback (image upload, inspection submit) is in flight. */
@media (prefers-reduced-motion: reduce) {
    *:not([data-keep-motion="true"]),
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ──────────────────────────────────────────────────────────────────────────
   Bootstrap-4/5 utility shims.
   Settings.aspx and QuestionChangelog.aspx still use these classes; they
   were silently provided by the Tailwind CDN before it was stripped, and
   Bootstrap 3 (the version actually loaded site-wide) doesn't ship them.
   Keeping these as a back-compat layer until those pages are refactored.
   ────────────────────────────────────────────────────────────────────── */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-block { display: block; }
.d-inline-block { display: inline-block; }
.d-none { display: none; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-content-start { justify-content: flex-start; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.text-center { text-align: center; }
.text-start { text-align: left; }
.text-end { text-align: right; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
