/* PSS Smart Dashboard - Mobile-First Modern Design */

/* CSS Variables */
:root {
    --primary-color: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --hover-color: #4338ca;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --text-dark: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --highlight-bg: #fef3c7;
    --highlight-text: #92400e;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    --transition-fast: 0.15s;
    --transition-normal: 0.25s;
    --transition-slow: 0.4s;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --nav-height: 70px;
    --header-height: 60px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Theme Variants */
body.theme-ocean {
    --primary-color: #0ea5e9;
    --primary-light: #38bdf8;
    --primary-dark: #0284c7;
    --hover-color: #0369a1;
    --bg-light: #f0f9ff;
}

body.theme-sunset {
    --primary-color: #f97316;
    --primary-light: #fb923c;
    --primary-dark: #ea580c;
    --hover-color: #c2410c;
    --bg-light: #fff7ed;
}

body.theme-forest {
    --primary-color: #22c55e;
    --primary-light: #4ade80;
    --primary-dark: #16a34a;
    --hover-color: #15803d;
    --bg-light: #f0fdf4;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

/* Hide scrollbar but keep functionality */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    width: 50px;
    height: 50px;
    position: relative;
}

.loader-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s ease-in-out infinite;
}

.loader-circle:nth-child(2) {
    width: 70%;
    height: 70%;
    margin: 15%;
    border-top-color: rgba(255,255,255,0.5);
    animation-direction: reverse;
    animation-duration: 0.7s;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 24px;
    color: rgba(255,255,255,0.9);
    font-size: 0.95rem;
    font-weight: 500;
}

/* App Container */
.app-container {
    min-height: 100vh;
    transition: opacity 0.3s ease;
}

.app-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   HEADER - Mobile Optimized
   ============================================ */
.header {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.logo {
    height: 36px;
    width: auto;
    flex-shrink: 0;
}

.header-titles {
    min-width: 0;
}

.header-titles h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Search - Mobile First */
.search-container {
    display: none;
}

/* Mobile Search Bar (shown below header) */
.mobile-search {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 44px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 1rem;
    transition: all var(--transition-fast) var(--ease-out);
    background: var(--bg-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 14px center no-repeat;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-input::placeholder {
    color: var(--text-light);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    margin-top: 8px;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
}

.search-suggestions.hidden {
    display: none;
}

.suggestion-item {
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.suggestion-item:active {
    background: var(--bg-light);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-type {
    font-size: 0.7rem;
    padding: 3px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.user-btn:active {
    transform: scale(0.95);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    overflow: hidden;
    z-index: 1000;
}

.user-dropdown.hidden {
    display: none;
}

.user-email {
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.dropdown-item:active {
    background: var(--bg-light);
}

/* Theme Switcher - Compact for mobile */
.theme-switcher {
    display: flex;
    gap: 6px;
}

.theme-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.theme-icon:active {
    transform: scale(0.9);
}

.theme-icon.selected {
    border-color: var(--text-dark);
}

.theme-icon[data-theme="default"] { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.theme-icon[data-theme="ocean"] { background: linear-gradient(135deg, #0ea5e9, #06b6d4); }
.theme-icon[data-theme="sunset"] { background: linear-gradient(135deg, #f97316, #ef4444); }
.theme-icon[data-theme="forest"] { background: linear-gradient(135deg, #22c55e, #10b981); }

/* ============================================
   STATS BANNER - Compact Horizontal Scroll
   ============================================ */
.stats-banner {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.stats-banner::-webkit-scrollbar {
    display: none;
}

.stat-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    min-width: auto;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    opacity: 0.3;
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-card.highlight-danger::before {
    background: var(--danger-color);
    opacity: 0.5;
}

.stat-card.highlight-danger {
    background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}

.stat-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Last update card same style */
.stat-card:last-child {
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
}

.stat-card:last-child .stat-icon {
    font-size: 1rem;
}

.stat-card:last-child .stat-content {
    flex-direction: column;
    gap: 0;
}

.stat-card:last-child .stat-value {
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-card:last-child .stat-label {
    font-size: 0.65rem;
}

/* ============================================
   AI INSIGHTS PANEL - Collapsed by default on mobile
   ============================================ */
.ai-insights-panel {
    margin: 0 12px 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 50%, #a855f7 100%);
    border-radius: var(--radius-lg);
    overflow: hidden;
    color: white;
    box-shadow: var(--shadow-md);
}

.ai-insights-panel .panel-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.ai-insights-panel .panel-header h2 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-icon {
    transition: transform var(--transition-normal) var(--ease-out);
    font-size: 0.75rem;
}

.ai-insights-panel.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.panel-content {
    padding: 0 14px 14px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height var(--transition-normal) var(--ease-out),
                padding var(--transition-normal) var(--ease-out),
                opacity var(--transition-normal);
}

.ai-insights-panel.collapsed .panel-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    opacity: 0;
}

.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    justify-content: center;
    font-size: 0.85rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ai-insights-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-insights-grid.hidden {
    display: none;
}

.insight-card {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.1);
}

.insight-card h4 {
    margin: 0 0 4px;
    font-size: 0.7rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.insight-card p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   FILTERS SECTION - Mobile Compact Design
   ============================================ */
.filters-section {
    margin: 0 12px 12px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    margin-bottom: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar {
    display: none;
}

.filter-group {
    flex: 0 0 auto;
    min-width: 100px;
}

.filter-group label {
    display: none; /* Hide labels on mobile for compactness */
}

.filter-group select,
.filter-group input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background-color: var(--bg-light);
    -webkit-appearance: none;
    appearance: none;
    min-height: 36px;
}

.filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Toggle Switch - Compact for mobile */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    user-select: none;
    padding: 4px 0;
    min-height: 36px;
    white-space: nowrap;
}

.toggle-label input {
    display: none;
}

.slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.toggle-label input:checked + .slider {
    background: var(--primary-color);
}

.toggle-label input:checked + .slider::before {
    transform: translateX(16px);
}

/* Level Tabs - Compact horizontal scroll */
.level-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.level-tab {
    padding: 6px 12px;
    border: 1.5px solid var(--border-color);
    background: white;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 32px;
}

.level-tab:active {
    transform: scale(0.97);
}

.level-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.tab-count {
    background: rgba(0,0,0,0.08);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

.level-tab.active .tab-count {
    background: rgba(255,255,255,0.3);
}

/* Quick Tags - Hidden on mobile by default */
.quick-tags {
    display: none; /* Hide quick tags on mobile - too much space */
}

.quick-tag {
    padding: 8px 14px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.quick-tag:active {
    transform: scale(0.97);
}

.quick-tag.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   VIEW CONTROLS - Hidden on mobile (use bottom nav instead)
   ============================================ */
.view-controls {
    display: none; /* Hidden on mobile - use bottom nav */
}

.view-tabs {
    display: flex;
    gap: 4px;
    background: white;
    padding: 4px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    flex: 1;
}

.view-tab {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 36px;
}

.view-tab:active {
    transform: scale(0.97);
}

.view-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.view-actions {
    display: none; /* Hidden on mobile */
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:active {
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

.btn-outline:active {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
}

.btn-icon:active {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    padding: 0 16px 24px;
}

.view-container.hidden {
    display: none;
}

/* Cards Grid - Mobile Single Column */
.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============================================
   INSPECTION CARD - Mobile Optimized
   ============================================ */
.inspection-card {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-normal) var(--ease-out);
    cursor: pointer;
}

.inspection-card:active {
    transform: scale(0.99);
    box-shadow: var(--shadow-md);
}

.inspection-card.hidden {
    display: none;
}

.card-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--bg-light) 0%, rgba(79, 70, 229, 0.03) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.fav-star {
    font-size: 1.4rem;
    cursor: pointer;
    transition: all var(--transition-fast) var(--ease-bounce);
    color: #d1d5db;
    padding: 4px;
}

.fav-star:active {
    transform: scale(1.3);
}

.fav-star.favorited {
    color: #fbbf24;
}

.card-body {
    padding: 14px 16px;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-thumbnail {
    height: 160px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-thumbnail .no-image {
    color: var(--text-light);
    font-size: 0.85rem;
}

.card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.severity-badge {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-high { background: #fef2f2; color: #dc2626; }
.severity-medium { background: #fffbeb; color: #d97706; }
.severity-low { background: #f0fdf4; color: #16a34a; }
.severity-good { background: #eff6ff; color: #2563eb; }

.obs-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   DATA TABLE - Mobile Responsive
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-light);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.data-table tr:active td {
    background: var(--bg-light);
}

.data-table .table-thumb {
    width: 50px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Horizontal scroll wrapper for table on mobile */
#tableView {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   ANALYTICS CHARTS
   ============================================ */
.analytics-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    min-height: 280px;
    max-height: 350px;
}

.chart-card canvas {
    max-height: 280px !important;
    width: 100% !important;
}

.chart-card h3 {
    margin: 0 0 16px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* ============================================
   MODAL - Mobile Fullscreen
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp 0.3s var(--ease-out);
    padding-bottom: calc(20px + var(--safe-area-bottom));
}

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

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.modal-close:active {
    background: var(--border-color);
}

/* Modal drag handle */
.modal-content::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
}

#modalBody {
    padding: 24px 16px 0;
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.modal-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-observations {
    margin-top: 20px;
}

.modal-observations h3 {
    font-size: 0.9rem;
    margin: 0 0 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.observation-item {
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
}

.obs-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.obs-header strong {
    font-size: 0.9rem;
}

.observation-item p {
    margin: 8px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.obs-photo {
    width: 100%;
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: pointer;
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
}

.lightbox.hidden {
    display: none;
}

.lightbox img {
    max-width: 95%;
    max-height: 85%;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: max(20px, var(--safe-area-bottom));
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
}

/* ============================================
   TOAST NOTIFICATIONS - Mobile Centered
   ============================================ */
.toast-container {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: calc(100% - 32px);
    max-width: 400px;
}

.toast {
    background: white;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideUp 0.3s var(--ease-out);
}

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

.toast.success { border-left: 4px solid var(--success-color); }
.toast.error { border-left: 4px solid var(--danger-color); }
.toast.info { border-left: 4px solid var(--info-color); }
.toast.warning { border-left: 4px solid var(--warning-color); }

.toast-icon {
    font-size: 1.1rem;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.fade-out {
    animation: toastSlideDown 0.3s var(--ease-out) forwards;
}

@keyframes toastSlideDown {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* ============================================
   BOTTOM NAVIGATION - Mobile
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 24px;
    height: 3px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast) var(--ease-out);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.nav-label {
    line-height: 1;
}

/* Badge for collected count */
.nav-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    background: var(--danger-color);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.nav-badge.hidden {
    display: none;
}

/* Hide desktop FAB on mobile */
.fab-container {
    display: none;
}

/* ============================================
   COLLECTED PANEL - Mobile Slide-up
   ============================================ */
.collected-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 500;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform var(--transition-normal) var(--ease-out);
}

.collected-panel.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.collected-panel .panel-header {
    padding: 16px 20px;
    background: var(--bg-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.collected-panel h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.collected-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.collected-item {
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
}

.collected-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.collected-header strong {
    font-size: 0.9rem;
}

.collected-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.empty-message {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
}

.panel-actions {
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.panel-actions .btn {
    flex: 1;
}

/* ============================================
   NO RESULTS
   ============================================ */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-results p {
    margin-bottom: 16px;
}

.no-results.hidden {
    display: none;
}

/* ============================================
   DESKTOP STYLES (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    /* Hide bottom nav on desktop */
    .bottom-nav {
        display: none;
    }

    /* Show FAB on desktop */
    .fab-container {
        display: block;
        position: fixed;
        bottom: 30px;
        right: 30px;
        z-index: 100;
    }

    .fab {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
        color: white;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: var(--shadow-lg);
        transition: all var(--transition-fast);
    }

    .fab:hover {
        transform: scale(1.05);
        box-shadow: var(--shadow-xl), var(--shadow-glow);
    }

    .fab.active {
        transform: rotate(45deg);
    }

    .fab-menu {
        position: absolute;
        bottom: 70px;
        right: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .fab-menu.hidden {
        display: none;
    }

    .fab-item {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: white;
        border: 2px solid var(--primary-color);
        color: var(--primary-color);
        font-size: 1.1rem;
        cursor: pointer;
        box-shadow: var(--shadow-md);
        transition: all var(--transition-fast);
    }

    .fab-item:hover {
        background: var(--primary-color);
        color: white;
    }

    /* Header - Desktop */
    .header {
        padding: 16px 24px;
    }

    .header-titles h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    /* Show search in header on desktop */
    .search-container {
        display: block;
        position: relative;
    }

    .mobile-search {
        display: none;
    }

    .search-input {
        width: 320px;
    }

    /* Stats - Desktop Grid */
    .stats-banner {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        padding: 20px 24px;
        overflow: visible;
    }

    .stat-card {
        flex: 1;
        min-width: 160px;
        flex-direction: row;
        align-items: center;
        gap: 14px;
        padding: 16px;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-card:last-child {
        flex: none;
        min-width: auto;
    }

    .stat-card:last-child .stat-value {
        font-size: 1rem;
    }

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

    /* Filters - Desktop */
    .filters-section {
        margin: 0 24px 20px;
        padding: 20px;
    }

    .filter-row {
        flex-wrap: wrap;
        overflow: visible;
    }

    .filter-group {
        min-width: 180px;
    }

    .filter-group label {
        display: block; /* Show labels on desktop */
    }

    .filter-group select,
    .filter-group input[type="text"] {
        padding: 12px 14px;
        font-size: 0.95rem;
        min-height: 44px;
    }

    .level-tabs {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .level-tab {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .quick-tags {
        display: flex; /* Show quick tags on desktop */
    }

    /* View Controls - Desktop */
    .view-controls {
        display: flex; /* Show on desktop */
        margin: 0 24px 20px;
    }

    .view-actions {
        display: flex; /* Show on desktop */
    }

    .view-tabs {
        flex: none;
    }

    .view-tab {
        flex: none;
        padding: 10px 20px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    /* Cards Grid - Desktop */
    .main-content {
        padding: 0 24px 40px;
    }

    .cards-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 20px;
    }

    .inspection-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-xl);
    }

    /* Analytics Grid - Desktop */
    .analytics-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .chart-card.wide {
        grid-column: span 2;
    }

    /* Modal - Desktop centered */
    .modal {
        align-items: center;
        padding: 24px;
    }

    .modal-content {
        border-radius: var(--radius-xl);
        max-width: 800px;
        max-height: 85vh;
        padding-bottom: 20px;
    }

    .modal-content::before {
        display: none;
    }

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

    #modalBody {
        padding: 32px 24px 0;
    }

    /* Collected Panel - Desktop Sidebar */
    .collected-panel {
        top: 0;
        left: auto;
        right: 0;
        width: 400px;
        height: 100%;
        transform: translateX(0);
        box-shadow: -5px 0 30px rgba(0,0,0,0.1);
    }

    .collected-panel.hidden {
        transform: translateX(100%);
    }

    .panel-actions {
        padding-bottom: 20px;
    }

    /* Toast - Desktop */
    .toast-container {
        bottom: 24px;
        left: auto;
        right: 24px;
        transform: none;
    }
}

/* ============================================
   LARGE DESKTOP (min-width: 1200px)
   ============================================ */
@media (min-width: 1200px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    }

    .search-input {
        width: 400px;
    }
}

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

/* Focus states for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .filters-section,
    .view-controls,
    .fab-container,
    .toast-container,
    .bottom-nav,
    .ai-insights-panel {
        display: none !important;
    }

    body {
        padding-bottom: 0;
    }

    .cards-grid {
        display: block;
    }

    .inspection-card {
        break-inside: avoid;
        margin-bottom: 20px;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
