/* Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html,
body {
    height: 100%;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Clean Color Palette - shadcn/ui inspired */
:root {
    /* Base Colors */
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;

    /* Card */
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;

    /* Popover */
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;

    /* Primary */
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;

    /* Secondary */
    --secondary: 210 40% 96%;
    --secondary-foreground: 222.2 84% 4.9%;

    /* Muted */
    --muted: 210 40% 96%;
    --muted-foreground: 215.4 16.3% 46.9%;

    /* Accent */
    --accent: 210 40% 96%;
    --accent-foreground: 222.2 84% 4.9%;

    /* Destructive */
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;

    /* Success */
    --success: 142.1 76.2% 36.3%;
    --success-foreground: 355.7 100% 97.3%;

    /* Warning */
    --warning: 38 92% 50%;
    --warning-foreground: 48 96% 89%;

    /* Border */
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 221.2 83.2% 53.3%;

    /* Radius */
    --radius: 0.5rem;
    --radius-sm: 0.25rem;
    --radius-lg: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode variables */
[data-theme="dark"] {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;

    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;

    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;

    --primary: 217.2 91.2% 59.8%;
    --primary-foreground: 222.2 84% 4.9%;

    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;

    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;

    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;

    --success: 142.1 70.6% 45.3%;
    --success-foreground: 144.9 80.4% 10%;

    --warning: 38 92% 50%;
    --warning-foreground: 48 96% 89%;

    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 224.3 76.3% 94.1%;
}

/* Fallback for prefers-color-scheme when no data-theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --background: 222.2 84% 4.9%;
        --foreground: 210 40% 98%;

        --card: 222.2 84% 4.9%;
        --card-foreground: 210 40% 98%;

        --popover: 222.2 84% 4.9%;
        --popover-foreground: 210 40% 98%;

        --primary: 217.2 91.2% 59.8%;
        --primary-foreground: 222.2 84% 4.9%;

        --secondary: 217.2 32.6% 17.5%;
        --secondary-foreground: 210 40% 98%;

        --muted: 217.2 32.6% 17.5%;
        --muted-foreground: 215 20.2% 65.1%;

        --accent: 217.2 32.6% 17.5%;
        --accent-foreground: 210 40% 98%;

        --destructive: 0 62.8% 30.6%;
        --destructive-foreground: 210 40% 98%;

        --success: 142.1 70.6% 45.3%;
        --success-foreground: 144.9 80.4% 10%;

        --warning: 38 92% 50%;
        --warning-foreground: 48 96% 89%;

        --border: 217.2 32.6% 17.5%;
        --input: 217.2 32.6% 17.5%;
        --ring: 224.3 76.3% 94.1%;
    }
}

/* Apply CSS custom properties */
* {
    color: hsl(var(--foreground));
    background-color: hsl(var(--background));
}

/* Smooth theme transitions */
:root {
    transition: background-color var(--transition), color var(--transition);
}

[data-theme] * {
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.app {
    min-height: 100vh;
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(var(--muted)) 100%);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
}

h1 {
    font-size: 2.25rem;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.875rem;
    letter-spacing: -0.025em;
}

h3 {
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

p {
    line-height: 1.625;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: hsl(var(--foreground));
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(var(--muted) / 0.3) 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Icon Styles */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    flex-shrink: 0;
}

.icon-sm {
    width: 0.875em;
    height: 0.875em;
}

.icon-lg {
    width: 2em;
    height: 2em;
}

/* Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    outline: none;
    position: relative;
    overflow: hidden;
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: width 0.3s ease, height 0.3s ease;
    transform: translate(-50%, -50%);
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-primary {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary)) 70%, hsl(var(--primary) / 0.8));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, hsl(var(--primary) / 0.9), hsl(var(--primary) / 0.8));
    border-color: hsl(var(--primary) / 0.9);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px hsl(var(--primary) / 0.4);
}

.btn-primary:active {
    background: hsl(var(--primary));
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px hsl(var(--primary) / 0.3);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, hsl(var(--background) / 0.95) 0%, hsl(var(--background) / 0.9) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid hsl(var(--border));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.1) inset;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    margin: 0;
}

.logo-icon svg {
    width: 2.5rem;
    height: 2.5rem;
    color: hsl(var(--foreground));
    stroke-width: 1.5;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin: 0;
}

.logo-text p {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.status-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, hsl(var(--muted) / 0.3), hsl(var(--muted) / 0.1));
    border: 1px solid hsl(var(--border));
    margin-top: 0.375rem;
    font-size: 0.6875rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.status-indicator {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: hsl(var(--muted-foreground));
    transition: var(--transition);
}

.status-indicator.healthy {
    background: hsl(var(--success));
}

.status-indicator.error {
    background: hsl(var(--destructive));
}

.status-indicator.warning {
    background: hsl(var(--warning));
}

.status-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.last-update {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
}

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.theme-btn:hover {
    background: hsl(var(--secondary) / 0.8);
    border-color: hsl(var(--border) / 0.8);
}

.theme-btn:active {
    transform: scale(0.95);
}

.theme-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.theme-icon {
    position: absolute;
    transition: var(--transition);
    opacity: 0;
    transform: scale(0.8);
}

.theme-icon.active {
    opacity: 1;
    transform: scale(1);
}

.light-icon.active {
    color: hsl(var(--warning));
}

.dark-icon.active {
    color: hsl(var(--primary));
}

/* Controls Section */
.controls-section {
    background: hsl(var(--background));
    border-bottom: 1px solid hsl(var(--border));
    padding: 0.5rem 0;
}

.controls-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.control-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 2.75rem;
    height: 1.5rem;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    transition: var(--transition);
    border-radius: 0.75rem;
}

.toggle-handle {
    position: absolute;
    content: "";
    height: 1.125rem;
    width: 1.125rem;
    left: 2px;
    bottom: 2px;
    background-color: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-switch {
    background-color: hsl(var(--primary));
    border-color: hsl(var(--primary));
}

.toggle input:checked + .toggle-switch .toggle-handle {
    transform: translateX(1.25rem);
    background-color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.toggle-label {
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    font-weight: 500;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, hsl(var(--card)) 0%, hsl(var(--muted) / 0.05) 100%);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--primary) / 0.7));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-4px) scale(1.02);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: hsl(var(--primary));
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading States */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, hsl(var(--background) / 0.8), hsl(var(--background) / 0.9));
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.3s ease-out;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.loading-spinner {
    display: flex;
    gap: 0.25rem;
}

.spinner-ring {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid hsl(var(--border));
    border-top: 2px solid hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 10px hsl(var(--primary) / 0.3);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-ring:nth-child(2) {
    animation-delay: -0.33s;
}

.spinner-ring:nth-child(3) {
    animation-delay: -0.66s;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

/* Error States */
.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 2rem;
}

.error-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 28rem;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: hsl(var(--destructive));
}

.error-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
}

.error-description {
    color: hsl(var(--muted-foreground));
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Split-Screen Layout */
.split-screen-container {
    display: flex;
    gap: 1.5rem;
    padding: 0.125rem 0 0.75rem;
    min-height: 600px;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.map-panel,
.camera-panel {
    flex: 1;
    background: linear-gradient(135deg, hsl(var(--card)) 0%, hsl(var(--muted) / 0.05) 100%);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

.camera-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--primary) / 0.7));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.camera-panel:hover::before {
    opacity: 1;
}

.camera-panel:hover {
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-4px) scale(1.01);
}


.map-panel {
    flex: 1.2;
}

.camera-panel {
    flex: 1;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: hsl(var(--muted) / 0.3);
    border-bottom: 1px solid hsl(var(--border));
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
}

.camera-count-badge {
    background: linear-gradient(135deg, hsl(var(--primary) / 0.1), hsl(var(--primary) / 0.05));
    color: hsl(var(--primary));
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid hsl(var(--primary) / 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    animation: bounce 2s ease-in-out infinite;
}

.feed-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, hsl(var(--muted) / 0.5), hsl(var(--muted) / 0.3));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: width 0.3s ease, height 0.3s ease;
    transform: translate(-50%, -50%);
}

.control-btn:hover::before {
    width: 100px;
    height: 100px;
}

.control-btn:hover {
    background: linear-gradient(135deg, hsl(var(--muted) / 0.8), hsl(var(--muted) / 0.6));
    border-color: hsl(var(--primary));
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.control-btn:active {
    transform: translateY(0) scale(0.95);
}

.camera-count-badge {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    transition: all var(--transition);
}

.camera-count-badge:hover {
    background: hsl(var(--primary) / 0.15);
    transform: scale(1.02);
}

.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, hsl(var(--muted) / 0.1), hsl(var(--muted) / 0.05));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-container:hover {
    transform: scale(1.01);
}

.image-display-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, hsl(var(--muted) / 0.1), hsl(var(--muted) / 0.05));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-display-container:hover {
    transform: scale(1.005);
}

/* Fullscreen Mode */
.camera-panel.fullscreen {
    position: fixed;
    top: 80px; /* Account for header */
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 900;
    max-height: calc(100vh - 100px);
}

/* Mobile adjustments for fullscreen */
@media (max-width: 768px) {
    .camera-panel.fullscreen {
        top: 70px;
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        max-height: calc(100vh - 80px);
    }
}

.camera-panel.fullscreen .image-display-container {
    height: 100%;
}

.camera-panel.fullscreen .selected-camera-image,
.camera-panel.fullscreen .image-placeholder {
    height: 100%;
    max-height: none;
}

/* Grid View Styles */
.grid-view .selected-camera-image {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-template-rows: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
    height: 100%;
    overflow-y: auto;
}

.grid-view .selected-camera-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform var(--transition);
}

.grid-view .selected-camera-image img:hover {
    transform: scale(1.02);
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
}

.section-subtitle {
    font-size: 1rem;
    color: hsl(var(--muted-foreground));
    max-width: 32rem;
    margin: 0 auto;
}

/* Map Container */
.map-container {
    margin: 2rem 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
}

.singapore-map {
    height: 600px;
    width: 100%;
    background: transparent;
}

/* Leaflet Custom Styles */
.leaflet-container {
    background: transparent;
    border-radius: var(--radius-lg);
    z-index: 1;
}

.leaflet-tile-pane {
    background: transparent !important;
}

.leaflet-popup-content-wrapper {
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-tip {
    background: hsl(var(--card));
}

.leaflet-popup-content {
    margin: 0;
    font-family: inherit;
}

/* Custom emoji marker styles */
.camera-emoji-marker {
    background: transparent !important;
    border: none !important;
    pointer-events: none;
}

.camera-emoji-marker div {
    background: transparent !important;
    border: none !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Ensure emoji renders properly with transparency */
.camera-emoji-marker::before,
.camera-emoji-marker::after {
    display: none;
}

/* Override any default Leaflet marker styles */
.camera-emoji-marker.leaflet-marker-icon {
    margin-left: -16px !important;
    margin-top: -32px !important;
}

/* Ensure emoji renders with proper font rendering */
.camera-emoji-marker div {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: none;
}

/* Additional transparency and rendering fixes */
.leaflet-marker-icon.camera-emoji-marker {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.leaflet-marker-icon.camera-emoji-marker::before,
.leaflet-marker-icon.camera-emoji-marker::after {
    display: none !important;
}

.camera-popup {
    max-width: 400px;
    background: hsl(var(--card));
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.popup-image-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: hsl(var(--muted));
}

.camera-popup img {
    transition: var(--transition);
}

/* Large Image Display */
.image-display-container {
    margin-top: 2rem;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.image-placeholder {
    width: 100%;
    height: 440px;
    background: hsl(var(--card));
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.selected-camera-image {
    width: 100%;
    height: 440px;
    background: hsl(var(--background));
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.image-placeholder:hover {
    border-color: hsl(var(--primary));
    background: hsl(var(--card) / 0.8);
}

.placeholder-content {
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.placeholder-icon {
    margin-bottom: 1rem;
    opacity: 0.6;
}

.placeholder-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: hsl(var(--foreground));
}

.placeholder-subtitle {
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}


.selected-camera-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.02);
    display: block;
    margin: 0;
    padding: 0;
}

.camera-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 2rem 1.5rem 1.5rem;
    color: white;
}

.camera-info-overlay .traffic-status,
.camera-info-overlay .incident-status {
    margin-bottom: 0.75rem;
}

.camera-info-overlay .traffic-status:last-child,
.camera-info-overlay .incident-status:last-child {
    margin-bottom: 0;
}

/* Enhanced Toggle Styles */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform var(--transition);
}

.toggle-wrapper:hover {
    transform: translateY(-1px);
}

.toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    margin-right: 0.25rem;
}

.toggle-icon {
    font-size: 1rem;
    transition: var(--transition);
}

.toggle-icon.light-icon {
    color: hsl(var(--warning));
}

.toggle-icon.dark-icon {
    color: hsl(var(--primary));
}

.toggle-switch {
    position: relative;
    width: 2.5rem;
    height: 1.25rem;
    background: hsl(var(--muted));
    border-radius: 0.625rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-handle {
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1rem;
    height: 1rem;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: translateX(0);
}

.toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle input[type="checkbox"]:checked + .toggle-switch {
    background: hsl(var(--primary));
}

.toggle input[type="checkbox"]:checked + .toggle-switch .toggle-handle {
    transform: translateX(1.25rem);
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
}

.popup-content {
    padding: 1rem;
}

.popup-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0 0 0.375rem 0;
    line-height: 1.3;
}

.popup-location {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0 0 0.75rem 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.popup-location::before {
    content: '';
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: hsl(var(--primary));
    flex-shrink: 0;
}

.popup-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid hsl(var(--border));
}

.camera-id {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

.accuracy-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.image-dimensions {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: hsl(var(--muted) / 0.1);
    color: hsl(var(--muted-foreground));
    margin-left: 0.5rem;
}

.accuracy-high {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.2);
}

.accuracy-medium {
    background: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.2);
}

.accuracy-low {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.2);
}

.accuracy-estimated {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    border: 1px solid hsl(var(--border));
}

/* Responsive Split-Screen Layout */
@media (max-width: 1024px) {
    .split-screen-container {
        flex-direction: column;
        gap: 1rem;
    }

    .map-panel,
    .camera-panel {
        flex: none;
        min-height: 400px;
    }

    .map-panel {
        flex: 1;
    }

    .panel-header {
        padding: 0.75rem 1rem;
    }

    .feed-controls {
        gap: 0.25rem;
    }

    .control-btn {
        width: 1.75rem;
        height: 1.75rem;
    }
}

@media (max-width: 768px) {
    .singapore-map {
        height: 360px;
    }

    .image-placeholder,
    .selected-camera-image {
        height: 384px;
    }

    .map-panel,
    .camera-panel {
        min-height: 350px;
    }

    .panel-title {
        font-size: 0.9rem;
    }

    .camera-count-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

    .camera-popup {
        max-width: 280px;
    }

    .popup-image-container {
        height: 140px;
    }

    .popup-content {
        padding: 0.875rem;
    }

    .popup-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .singapore-map {
        height: 300px;
    }

    .image-placeholder,
    .selected-camera-image {
        height: 320px;
    }

    .camera-popup {
        max-width: 240px;
    }

    .popup-image-container {
        height: 120px;
    }

    .popup-content {
        padding: 0.75rem;
    }

    .popup-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }
}

/* Cameras Grid */
.cameras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.camera-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}

.camera-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: hsl(var(--border) / 0.8);
}

.camera-image-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: hsl(var(--muted));
    border-radius: var(--radius) var(--radius) 0 0;
}

.camera-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-fast);
}

.camera-image.loading {
    opacity: 0.6;
    filter: blur(1px);
}

.image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--background) / 0.8);
    backdrop-filter: blur(4px);
    color: hsl(var(--foreground));
    opacity: 1;
    transition: var(--transition);
}

.image-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.camera-card:hover .image-overlay:not(.fade-out) {
    opacity: 0.9;
}

.camera-info {
    padding: 1.25rem;
}

.camera-header {
    margin-bottom: 1rem;
}

.camera-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.camera-location {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.camera-location::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: hsl(var(--primary));
    flex-shrink: 0;
}

.camera-id {
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--secondary));
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid hsl(var(--border));
    display: inline-block;
    margin-bottom: 0.25rem;
}

.camera-timestamp {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    text-align: right;
    line-height: 1.2;
}

.camera-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.meta-item i {
    color: hsl(var(--primary));
    flex-shrink: 0;
}

.meta-item a {
    color: hsl(var(--primary));
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.meta-item a:hover {
    color: hsl(var(--primary) / 0.8);
    text-decoration: underline;
}

/* Geolocation and Map Links */
.map-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    padding: 0.125rem;
    border-radius: var(--radius-sm);
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    transition: var(--transition);
    text-decoration: none;
}

.map-link:hover {
    background: hsl(var(--primary) / 0.8);
    transform: scale(1.1);
}

.map-link i {
    width: 0.75rem;
    height: 0.75rem;
}

/* Geolocation accuracy indicators */
.meta-item .accuracy-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.accuracy-high {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.2);
}

.accuracy-medium {
    background: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.2);
}

.accuracy-low {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.2);
}

.accuracy-estimated {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    border: 1px solid hsl(var(--border));
}

/* Traffic Status */
.traffic-status {
    margin-top: 1rem;
    padding: 0.75rem;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
}

.status-item.congestion-light {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.2);
}

.status-item.congestion-moderate {
    background: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.2);
}

.status-item.congestion-heavy {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.2);
}

.status-item.congestion-severe {
    background: hsl(var(--destructive) / 0.15);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.3);
    font-weight: 600;
}

.status-item.incident {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.2);
}

.status-item.vms {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--primary) / 0.2);
}

.vms-text {
    font-size: 0.8125rem;
    line-height: 1.2;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-item i {
    flex-shrink: 0;
    opacity: 0.8;
}

/* Mobile adjustments for traffic status */
@media (max-width: 480px) {
    .traffic-status {
        padding: 0.5rem;
        margin-top: 0.75rem;
    }

    .status-item {
        padding: 0.25rem 0.5rem;
        font-size: 0.8125rem;
    }

    .vms-text {
        max-width: 150px;
    }
}


/* Pulse Animation for Interactive Elements */
@keyframes pulse-subtle {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.loading-pulse {
    animation: pulse-subtle 2s ease-in-out infinite;
}

/* Enhanced Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid hsl(var(--muted));
    border-radius: 50%;
    border-top-color: hsl(var(--primary));
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

/* Selected Camera Image Styles */
.selected-camera-image {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(135deg, hsl(var(--muted) / 0.1), hsl(var(--muted) / 0.05));
}

.selected-camera-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: hsl(var(--background));
    transition: all 0.3s ease;
    border-radius: var(--radius-lg);
}

/* Image Loading States */
.camera-image.loading {
    opacity: 0.5;
    filter: blur(2px);
}

.camera-image.loaded {
    opacity: 1;
    filter: none;
    animation: imageFadeIn 0.5s ease-out;
}

.camera-image.error {
    opacity: 0.8;
    filter: grayscale(100%);
}

@keyframes imageFadeIn {
    from {
        opacity: 0;
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Image Loading Spinner */
.camera-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid hsl(var(--border));
    border-top: 3px solid hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    z-index: 1;
}

.camera-image.loading::before {
    opacity: 1;
}

/* Maximize Button */
.maximize-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    backdrop-filter: blur(8px);
}

.selected-camera-image:hover .maximize-btn {
    opacity: 1;
    transform: scale(1);
}

.maximize-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.maximize-btn:active {
    transform: scale(0.95);
}

/* Fullscreen Image Overlay */
.image-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.fullscreen-image-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    background: hsl(var(--background));
    animation: zoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fullscreen Close Button */
.fullscreen-close-btn {
    position: absolute;
    top: -3rem;
    right: 0;
    width: 3rem;
    height: 3rem;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
    backdrop-filter: blur(8px);
}

.fullscreen-close-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.fullscreen-close-btn:active {
    transform: scale(0.95);
}

/* Fullscreen Info Overlay */
.fullscreen-info-overlay {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    animation: slideUp 0.4s ease-out 0.2s both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive Fullscreen */
@media (max-width: 768px) {
    .fullscreen-image-container {
        max-width: 95vw;
        max-height: 95vh;
    }

    .fullscreen-close-btn {
        top: -4rem;
        width: 2.5rem;
        height: 2.5rem;
    }

    .fullscreen-info-overlay {
        bottom: 1rem;
        max-width: 90vw;
    }
}


/* Accessibility and Focus Styles */
.focus-visible:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}

.control-btn:focus-visible,
.toggle:focus-visible,
.map-panel:focus-visible,
.camera-panel:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}

/* Skip Link for Screen Readers */
.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 9999;
    padding: 0.5rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .toggle-switch {
        border: 2px solid hsl(var(--foreground));
    }

    .control-btn {
        border: 2px solid hsl(var(--foreground));
    }

    .panel-header {
        border-bottom: 2px solid hsl(var(--foreground));
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation: none;
    }

    .skeleton {
        animation: none;
        background: hsl(var(--muted));
    }
}

/* Footer */
.footer {
    background: hsl(var(--card));
    border-top: 1px solid hsl(var(--border));
    padding: 2rem 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.footer-info {
    text-align: center;
}

.footer-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.footer-note {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    line-height: 1.5;
}

.footer-note a {
    color: hsl(var(--primary));
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer-note a:hover {
    color: hsl(var(--primary) / 0.8);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cameras-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .header-left {
        justify-content: center;
    }

    .header-right {
        justify-content: space-between;
        gap: 0.75rem;
    }

    .logo {
        justify-content: center;
    }

    .logo-text {
        text-align: center;
    }

    .theme-toggle {
        order: -1;
        align-self: flex-end;
    }

    .control-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .toggle-wrapper {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .cameras-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .camera-card {
        margin: 0 -0.5rem;
    }

    .camera-info {
        padding: 1rem;
    }

    .main-content {
        padding: 1.5rem 1rem 2rem;
    }
}

@media (max-width: 640px) {
    .logo-icon {
        width: 2.25rem;
        height: 2.25rem;
    }

    .logo-icon svg {
        width: 2.25rem;
        height: 2.25rem;
    }

    .cameras-grid {
        grid-template-columns: 1fr;
    }

    .camera-image-container {
        height: 160px;
    }

    .camera-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .camera-timestamp {
        text-align: left;
    }

    .status-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0.5rem 0.75rem;
    }

    .logo-icon {
        width: 2.25rem;
        height: 2.25rem;
    }

    .logo-icon svg {
        width: 2.25rem;
        height: 2.25rem;
    }

    .logo-text h1 {
        font-size: 1rem;
    }

    .logo-text p {
        font-size: 0.625rem;
    }

    .theme-btn {
        width: 2rem;
        height: 2rem;
    }

    .theme-icon {
        width: 1rem;
        height: 1rem;
    }

    .control-actions {
        gap: 0.75rem;
    }

    .stats-grid {
        gap: 0.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .error-card {
        padding: 1.5rem;
        margin: 0 1rem;
    }

    .cameras-section {
        padding: 0.0625rem 0 0.5rem;
    }

    .main-content {
        padding: 1.25rem 0.75rem 1.5rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border: 222.2 84% 4.9%;
        --primary: 0 0% 0%;
        --primary-foreground: 0 0% 100%;
    }
}

/* Print styles */
@media print {
    .controls-section,
    .footer {
        display: none !important;
    }

    .cameras-grid {
        display: block !important;
    }

    .camera-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #000;
    }

    .app {
        background: white;
    }
}

/* Focus visible for keyboard navigation */
.btn:focus-visible,
.toggle input:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Skip to main content for screen readers */
.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 0.5rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    text-decoration: none;
    border-radius: var(--radius);
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* Utility classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-balance {
    text-wrap: balance;
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Status indicator pulse animation */
.status-indicator.healthy,
.status-indicator.error,
.status-indicator.warning {
    animation: pulse 2s infinite;
}

/* Card entrance animations */
.camera-card {
    animation: fadeIn 0.3s ease-out;
}

.camera-card:nth-child(2) { animation-delay: 0.05s; }
.camera-card:nth-child(3) { animation-delay: 0.1s; }
.camera-card:nth-child(4) { animation-delay: 0.15s; }
.camera-card:nth-child(5) { animation-delay: 0.2s; }
.camera-card:nth-child(6) { animation-delay: 0.25s; }

/* Button hover effects */
.btn:active {
    transform: scale(0.98);
}

/* Loading spinner enhancement */
.spinner-ring {
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(1) { animation-delay: -0.45s; }
.spinner-ring:nth-child(2) { animation-delay: -0.3s; }
.spinner-ring:nth-child(3) { animation-delay: -0.15s; }

/* Smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
}

/* Container queries for better responsive design */
@container (min-width: 768px) {
    .camera-meta {
        grid-template-columns: 1fr 1fr;
    }
}

/* Performance optimizations */
.camera-image {
    will-change: opacity, filter;
}

.camera-card {
    will-change: transform, box-shadow;
}

/* Focus enhancements */
.btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Selection styling */
::selection {
    background: hsl(var(--primary) / 0.2);
    color: hsl(var(--primary));
}
