* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Navbar */
.navbar {
    background-color: var(--card-background);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 1.25rem;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* Header */
.header {
    margin-bottom: 1.5rem;
}

.header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.last-updated {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 1.75rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--background);
    flex-shrink: 0;
}

.stat-card.available .stat-icon {
    background: #d1fae5;
    color: var(--success-color);
}

.stat-card.occupied .stat-icon {
    background: #fee2e2;
    color: var(--danger-color);
}

.stat-card.total .stat-icon {
    background: #dbeafe;
    color: var(--primary-color);
}

.stat-card.occupancy .stat-icon {
    background: #fef3c7;
    color: var(--warning-color);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-content h3 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

/* Content Section */
.content-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.content-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.indicator-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.indicator-dot.green {
    background-color: var(--success-color);
}

.indicator-dot.yellow {
    background-color: var(--warning-color);
}

.indicator-dot.red {
    background-color: var(--danger-color);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

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

.btn-secondary:hover {
    background-color: #e2e8f0;
    transform: translateY(-1px);
}

/* Admin specific styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Canvas for calibration */
#calibrationCanvas {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    max-width: 100%;
    cursor: crosshair;
}

/* Live View Styles */
.live-view-container {
    position: relative;
    display: inline-block;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#liveFeed {
    display: block;
    width: 100%;
    height: auto;
}

#detectionCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.detection-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    border-radius: 6px;
    color: white;
    min-width: 150px;
    max-width: 200px;
}

.detection-overlay h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #10b981;
}

.detection-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.detection-stat span:first-child {
    color: #94a3b8;
}

.detection-stat span:last-child {
    font-weight: 600;
}

.legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-box.available {
    background: rgba(16, 185, 129, 0.3);
    border-color: #10b981;
}

.legend-box.occupied {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

.fullscreen-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.space-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.space-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.space-cell.available {
    background: #d1fae5;
    color: #059669;
}

.space-cell.occupied {
    background: #fee2e2;
    color: #dc2626;
}

.space-cell:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.status-banner {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.status-banner.alert {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
}

.status-banner.warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
    }
    
    .navbar h1 {
        font-size: 1.1rem;
    }
    
    .nav-links {
        gap: 0.75rem;
    }
    
    .nav-links a {
        font-size: 0.875rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .stat-content h3 {
        font-size: 0.7rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }
    
    .header h2 {
        font-size: 1.5rem;
    }
    
    .content-section {
        padding: 1rem;
        border-radius: 8px;
    }
    
    .content-section h3 {
        font-size: 1.1rem;
    }
    
    .detection-overlay {
        top: 0.25rem;
        right: 0.25rem;
        padding: 0.5rem;
        min-width: 120px;
        font-size: 0.85rem;
    }
    
    .detection-overlay h4 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .detection-stat {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }
    
    .legend {
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .legend-item {
        font-size: 0.85rem;
    }
    
    .legend-box {
        width: 20px;
        height: 20px;
    }
    
    .space-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.35rem;
        padding: 0.75rem;
    }
    
    .space-cell {
        font-size: 0.75rem;
    }
    
    .button-group {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .fullscreen-btn {
        bottom: 0.5rem;
        right: 0.5rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-links {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }
    
    .stat-card {
        flex-direction: row;
        text-align: left;
    }
    
    .space-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}
