/* ───────────────────────────────────────────────────────────────────
   Spirit Sight — Mobile & Responsive Enhancements
   Touch-optimized controls, responsive layouts, and mobile breakpoints
   for field operations (barrel scanning, sample collection, gauging).
   ─────────────────────────────────────────────────────────────────── */

/* ── Touch-friendly tap targets (minimum 44px per WCAG 2.5.5) ───── */
@media (pointer: coarse) {
    .ss-btn,
    .ss-tab,
    button,
    a.nav-link,
    .sidebar-nav-item {
        min-height: 44px;
        min-width: 44px;
        padding: 0.625rem 1rem;
    }

    .ss-table td,
    .ss-table th {
        padding: 0.75rem 0.5rem;
    }

    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .ss-badge {
        padding: 0.375rem 0.75rem;
    }
}

/* ── Small screens (phones) ─────────────────────────────────────── */
@media screen and (max-width: 768px) {
    /* Sidebar, overlay, and main content handled by app.css */

    /* Module header stacks on mobile */
    .ss-module-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .ss-module-header__actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .ss-module-header__actions .ss-btn {
        flex: 1 1 auto;
        text-align: center;
    }

    /* Stat cards single column on narrow screens */
    .ss-metric-row {
        grid-template-columns: 1fr 1fr;
    }

    /* Tables scroll horizontally */
    .ss-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ss-table thead {
        white-space: nowrap;
    }

    /* Tabs scroll horizontally */
    .ss-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .ss-tabs::-webkit-scrollbar {
        display: none;
    }

    .ss-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Modal full-width on mobile */
    .modal-content,
    .ss-modal-content {
        width: 95vw !important;
        max-width: none !important;
        margin: 1rem auto !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Form fields full width */
    .form-group,
    .ss-form-group {
        width: 100%;
    }

    .form-row,
    .ss-form-row {
        flex-direction: column;
    }

    /* Hide non-essential columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* ── Medium screens (tablets) ────────────────────────────────────── */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .ss-metric-row {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .ss-module-header__actions {
        flex-wrap: wrap;
    }
}

/* ── PWA install banner ──────────────────────────────────────────── */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface-elevated, #2a2a4a);
    color: var(--color-text-primary);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 10000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-banner.visible {
    transform: translateY(0);
}

.pwa-install-banner__text {
    flex: 1;
}

.pwa-install-banner__text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.pwa-install-banner__text small {
    color: var(--color-text-muted);
}

/* ── Offline indicator ───────────────────────────────────────────── */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--color-warning, #f59e0b);
    color: #000;
    text-align: center;
    padding: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    z-index: 10001;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.visible {
    transform: translateY(0);
}

/* ── Landscape phone adjustments ─────────────────────────────────── */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .ss-module-header {
        padding: 0.5rem 0;
    }

    .ss-metric-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    .ss-metric {
        padding: 0.5rem;
    }
}
