/* InspectKit - Industrial/Utilitarian Design System */
/* Fire Safety, Digitized - Built for the Field */

/* ===== FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    /* Industrial color palette derived from logo */
    --ink-black: #0a0a0a;
    --steel-dark: #1a1a2e;
    --steel-mid: #16213e;
    --steel-light: #1f2937;
    --slate: #374151;
    --concrete: #4b5563;
    --ash: #9ca3af;
    --smoke: #d1d5db;
    --paper: #f3f4f6;
    --white: #ffffff;

    /* Brand colors from logo */
    --flame-orange: #f97316;
    --flame-red: #ea580c;
    --ember: #c2410c;
    --navy-deep: #1e3a5f;
    --navy-light: #2563eb;

    /* Semantic colors */
    --primary: var(--flame-orange);
    --primary-hover: var(--flame-red);
    --secondary: var(--navy-deep);
    --background: var(--paper);
    --surface: var(--white);
    --text-primary: var(--steel-dark);
    --text-secondary: var(--concrete);
    --border: #e5e7eb;

    /* Status colors */
    --status-online: #22c55e;
    --status-syncing: #f59e0b;
    --status-offline: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #3b82f6;

    /* Typography */
    --font-mono: 'IBM Plex Mono', 'Consolas', 'Monaco', monospace;
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Mobile nav height */
    --mobile-nav-height: 64px;
    --status-bar-height: 56px;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Bottom padding for mobile nav */
body {
    padding-bottom: var(--mobile-nav-height);
}

@media (min-width: 993px) {
    body {
        padding-bottom: var(--status-bar-height);
    }
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-mono);
    font-weight: 600;
    line-height: 1.2;
    color: var(--navy-deep);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.5rem, 3vw, 1.75rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.125rem; }

.page-title {
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--navy-deep);
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

/* ===== HEADER/NAVIGATION ===== */
header {
    background: var(--ink-black);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 2px solid var(--flame-orange);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 150px;
}

.logo-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo {
    height: 112px;
    width: auto;
    background: #ffffff;
    padding: 15px 30px;
    border: 3px solid var(--brand-primary, #e63946);
    border-radius: 10px;
}

.header-logo-svg,
.header-logo-img {
    height: 80px;
    max-width: 320px;
    width: auto;
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    object-fit: contain;
}

@media (max-width: 768px) {
    .header-container {
        min-height: 100px;
    }
    .header-logo {
        height: 68px;
        padding: 8px 16px;
    }
    .header-logo-svg,
    .header-logo-img {
        height: 60px;
        max-width: 220px;
        padding: 3px 6px;
    }
}

/* Desktop Navigation */
nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing-xs);
    margin: 0;
    padding: 0;
    align-items: center;
}

nav a {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--smoke);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all 0.2s ease;
    min-height: 48px;
}

nav a:hover,
nav a.active {
    color: var(--flame-orange);
    background: rgba(249, 115, 22, 0.1);
}

nav a i {
    font-size: 1rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 2px solid var(--flame-orange);
    color: var(--flame-orange);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
}

@media (max-width: 992px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    header nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--ink-black);
        padding: var(--spacing-md);
        display: none;
        border-top: 1px solid var(--slate);
        z-index: 1000;
    }

    header nav.active {
        display: block !important;
    }

    header nav ul {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    header nav a {
        padding: var(--spacing-md);
        width: 100%;
        justify-content: flex-start;
    }
}

/* Hide desktop nav on mobile (using bottom nav instead) */
@media (max-width: 992px) {
    header nav {
        display: none;
    }

    header nav.active {
        display: block !important;
    }
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */
.mobile-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--ink-black);
    border-top: 2px solid var(--flame-orange);
    z-index: 9999;
    padding: 0 var(--spacing-sm);
    padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 993px) {
    .mobile-nav {
        display: none !important;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--ash);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--spacing-sm);
    min-width: 64px;
    min-height: 48px;
    transition: all 0.2s ease;
    gap: 2px;
}

.mobile-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--flame-orange);
}

.mobile-nav-item.active {
    position: relative;
}

.mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 2px;
    background: var(--flame-orange);
}

/* Status Indicator in Mobile Nav */
.mobile-nav-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
    min-width: 56px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 4px;
    transition: all 0.3s ease;
}

.status-indicator.online {
    background: var(--status-online);
    box-shadow: 0 0 8px var(--status-online);
}

.status-indicator.syncing {
    background: var(--status-syncing);
    animation: statusPulse 1.5s ease-in-out infinite;
}

.status-indicator.offline {
    background: var(--status-offline);
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--status-syncing);
    }
    50% {
        opacity: 0.5;
        box-shadow: 0 0 16px var(--status-syncing);
    }
}

.status-label {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ash);
}

/* Sync Status Popup (Story 5.6) */
.sync-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sync-popup-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.sync-popup {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 8px);
    right: 8px;
    width: calc(100% - 16px);
    max-width: 280px;
    background: var(--charcoal);
    border: 1px solid var(--steel);
    border-radius: 8px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    transform: translateY(16px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
}

.sync-popup.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.sync-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--steel);
}

.sync-popup-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--concrete);
}

.sync-popup-close {
    background: none;
    border: none;
    color: var(--ash);
    cursor: pointer;
    padding: 4px;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -8px -8px -8px 0;
}

.sync-popup-close:hover,
.sync-popup-close:focus {
    color: var(--flame-orange);
}

.sync-popup-content {
    padding: var(--spacing-md);
}

.sync-popup-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.sync-popup-status .status-indicator {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.sync-popup-status-text {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--concrete);
}

.sync-popup-divider {
    height: 1px;
    background: var(--steel);
    margin: var(--spacing-md) 0;
}

.sync-popup-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.sync-popup-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ash);
}

.sync-popup-row i {
    width: 20px;
    text-align: center;
    color: var(--steel);
}

.sync-popup-actions {
    padding: var(--spacing-md);
    padding-top: 0;
}

.sync-popup-button {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: 48px;
    background: var(--steel);
    border: none;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--concrete);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.sync-popup-button:hover:not(:disabled),
.sync-popup-button:focus:not(:disabled) {
    background: var(--flame-orange);
    color: var(--ink-black);
}

.sync-popup-button:disabled {
    background-color: #9ca3af;
    color: #4b5563;
    cursor: not-allowed;
}

.sync-popup-button.syncing {
    position: relative;
}

.sync-popup-button.syncing::after {
    content: '';
    position: absolute;
    right: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: syncButtonSpin 0.8s linear infinite;
}

@keyframes syncButtonSpin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Hide sync popup on desktop */
@media (min-width: 993px) {
    .sync-popup,
    .sync-popup-backdrop {
        display: none;
    }
}

/* ===== MAIN CONTAINER ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--flame-orange);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy-deep);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card-title i {
    color: var(--flame-orange);
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: var(--spacing-lg);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--flame-orange);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-icon {
    font-size: 1.5rem;
    color: var(--ash);
    opacity: 0.5;
    float: right;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy-deep);
    line-height: 1;
}

/* ===== BUTTONS ===== */
.btn {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1.5rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 48px;
}

.btn-primary {
    background: var(--flame-orange);
    color: var(--ink-black);
}

.btn-primary:hover {
    background: var(--flame-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.btn-secondary {
    background: var(--navy-deep);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--navy-light);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    color: var(--navy-deep);
    border: 2px solid var(--navy-deep);
}

.btn-outline:hover {
    background: var(--navy-deep);
    color: var(--white);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    min-height: 40px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    min-height: 56px;
}

/* Button full width on mobile */
@media (max-width: 768px) {
    .btn {
        width: 100%;
    }
}

/* Disabled button states - WCAG 2.1 AA compliant (Story 8.3) */
.btn:disabled,
.btn.disabled,
button:disabled {
    background-color: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:disabled:hover,
.btn.disabled:hover,
button:disabled:hover {
    background-color: #d1d5db;
    color: #6b7280;
    transform: none;
    box-shadow: none;
}

/* ===== TABLES ===== */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

thead {
    background: var(--navy-deep);
    color: var(--white);
}

thead th {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--spacing-md);
    text-align: left;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: var(--paper);
}

tbody tr[style*="cursor: pointer"]:hover {
    background: rgba(249, 115, 22, 0.05);
}

tbody td {
    padding: var(--spacing-md);
    font-size: 0.9375rem;
}

/* Status Badges */
.status-badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.375rem 0.75rem;
    display: inline-block;
}

.status-scheduled {
    background: rgba(37, 99, 235, 0.1);
    color: var(--navy-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.status-completed,
.status-pass {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-fail,
.status-open {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--navy-deep);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--paper);
    border: 2px solid var(--border);
    transition: all 0.2s ease;
    min-height: 48px;
}

/* Form inputs - show enhanced border on all focus (needed for usability) */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--flame-orange);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Form inputs - add outline only for keyboard focus */
.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
    outline: 3px solid var(--flame-orange);
    outline-offset: 2px;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }
}

/* ===== FORM SECTIONS ===== */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--flame-orange);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
}

.form-section-title {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy-deep);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border);
}

/* ===== CHECKBOX & RADIO ===== */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--paper);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 48px;
}

.checkbox-group:hover {
    background: var(--smoke);
}

.checkbox-group input[type="checkbox"],
.checkbox-group input[type="radio"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--flame-orange);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.9);
    z-index: 10000;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--spacing-xl);
}

.modal-content {
    background: var(--surface);
    max-width: 800px;
    width: 100%;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: var(--spacing-lg);
    background: var(--navy-deep);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-title {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: none;
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: var(--spacing-lg);
}

/* Full-screen modal on mobile */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }

    .modal.active {
        padding-top: 0;
        align-items: stretch;
    }

    .modal-content {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        animation: modalSlideUp 0.3s ease-out;
    }

    @keyframes modalSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--spacing-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
    max-width: calc(100vw - 2rem);
    width: 400px;
}

@media (min-width: 993px) {
    .toast-container {
        bottom: calc(var(--status-bar-height) + var(--spacing-md));
    }
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    min-height: 48px;
    animation: toastSlideUp 0.3s ease-out;
    cursor: pointer;
}

.toast--success { background: var(--success); color: var(--white); }
.toast--info { background: var(--info); color: var(--white); }
.toast--warning { background: var(--warning); color: var(--ink-black); }
.toast--error { background: var(--danger); color: var(--white); }

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== STATUS BAR (Desktop) ===== */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--status-bar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 9998;
    background: var(--ink-black);
    color: var(--smoke);
    border-top: 1px solid var(--slate);
}

/* Hide desktop status bar on mobile (mobile nav has status) */
@media (max-width: 992px) {
    .status-bar {
        display: none;
    }
}

.status-bar--online .status-bar__indicator { color: var(--status-online); }
.status-bar--offline .status-bar__indicator { color: var(--status-offline); }
.status-bar--offline { background: var(--steel-dark); }
.status-bar--syncing .status-bar__sync { animation: statusPulse 1s infinite; }

/* ===== CALENDAR ===== */
.calendar {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: var(--spacing-lg);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--spacing-xs);
}

.calendar-day {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    padding: var(--spacing-sm);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
}

.calendar-day:hover {
    background: var(--paper);
    border-color: var(--flame-orange);
}

.calendar-day.has-inspection {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--flame-orange);
}

.calendar-day.today {
    background: rgba(249, 115, 22, 0.2);
    border-color: var(--flame-orange);
    font-weight: 700;
}

/* ===== MOBILE CARDS ===== */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--flame-orange);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-card:hover {
    box-shadow: var(--shadow-md);
}

.mobile-card:active {
    transform: scale(0.99);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.mobile-card-title {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--navy-deep);
    font-size: 0.9375rem;
}

.mobile-card-body {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

.mobile-card-body i {
    width: 16px;
    margin-right: var(--spacing-sm);
    color: var(--ash);
}

.mobile-card-actions {
    display: flex;
    gap: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.mobile-card-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: var(--spacing-sm);
}

@media (max-width: 768px) {
    .mobile-cards {
        display: block;
    }

    .desktop-table {
        display: none;
    }
}

/* ===== COLLAPSIBLE CARDS ===== */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapse-icon {
    transition: transform 0.3s ease;
}

.card-body {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* ===== QUICK ACTIONS ===== */
.quick-actions {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }
}

/* ===== FOOTER ===== */
footer {
    background: var(--ink-black);
    color: var(--smoke);
    padding: var(--spacing-xl) 0 var(--spacing-lg);
    margin-top: var(--spacing-2xl);
    border-top: 2px solid var(--flame-orange);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.footer-section h4 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--flame-orange);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-md);
}

.footer-section a {
    color: var(--ash);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.2s ease;
}

.footer-section a:hover {
    color: var(--flame-orange);
}

.footer-bottom {
    border-top: 1px solid var(--slate);
    padding-top: var(--spacing-lg);
    text-align: center;
}

.footer-bottom p {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--concrete);
}

/* ===== ACCESSIBILITY ===== */
/* Focus states for keyboard navigation (Story 8.1, enhanced in 8.4) */
/* Use :focus-visible to show focus only for keyboard, not mouse clicks */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible,
summary:focus-visible {
    outline: 3px solid var(--flame-orange);
    outline-offset: 2px;
}

/* Remove focus ring for mouse users (via :focus-visible) */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
[tabindex]:not([tabindex="-1"]):focus:not(:focus-visible),
summary:focus:not(:focus-visible) {
    outline: none;
}

/* Fallback for browsers without :focus-visible support */
@supports not selector(:focus-visible) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    [role="button"]:focus,
    [tabindex]:not([tabindex="-1"]):focus,
    summary:focus {
        outline: 3px solid var(--flame-orange);
        outline-offset: 2px;
    }
}

/* Enhanced focus visibility on dark backgrounds (Story 8.4) */
/* Header, mobile nav, modal headers, and footer have dark backgrounds */
header a:focus-visible,
header button:focus-visible,
.mobile-nav a:focus-visible,
.mobile-nav button:focus-visible,
.mobile-nav-item:focus-visible,
.modal-header button:focus-visible,
.modal-close:focus-visible,
footer a:focus-visible,
footer button:focus-visible,
.status-bar button:focus-visible,
thead th:focus-visible,
.sync-popup-close:focus-visible {
    outline: 3px solid var(--flame-orange);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25);
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--spacing-md);
    background: var(--flame-orange);
    color: var(--ink-black);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: var(--font-mono);
    font-weight: 600;
    z-index: 10001;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: var(--spacing-md);
}

.skip-link:focus-visible {
    outline: 3px solid var(--white);
    outline-offset: 2px;
}

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

/* ===== PRINT STYLES ===== */
@media print {
    header,
    nav,
    .mobile-nav,
    .status-bar,
    .btn,
    footer {
        display: none !important;
    }

    body {
        padding-bottom: 0;
    }

    .container {
        max-width: 100%;
    }
}

/* ===== DEMO BANNER ===== */
.demo-banner {
    background: var(--flame-orange);
    color: var(--ink-black);
    padding: 0.625rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.demo-banner i {
    margin-right: var(--spacing-sm);
}

/* ===== CONTEXTUAL HELP ICONS ===== */
/* Story 8.6: In-app help icons linking to documentation */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 8px; /* Combined: 32px + 16px padding = 48px touch target */
    margin: 0 var(--spacing-sm);
    color: var(--concrete);
    font-size: 1rem;
    text-decoration: none;
    border-radius: 50%;
    transition: color 0.2s ease, background-color 0.2s ease;
    vertical-align: middle;
}

.help-icon:hover {
    color: var(--flame-orange);
    background-color: rgba(249, 115, 22, 0.1);
}

.help-icon:focus-visible {
    outline: 3px solid var(--flame-orange);
    outline-offset: 2px;
    color: var(--flame-orange);
}

/* Ensure touch target is 48px minimum */
@media (pointer: coarse) {
    .help-icon {
        min-width: 48px;
        min-height: 48px;
    }
}

/* ===== ACCESSIBILITY UTILITIES ===== */
/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
