/* ============================================
   Base / Reset
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f6fa;
    color: #2c3e50;
    line-height: 1.5;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
    background: #2c3e50;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links a {
    color: #ecf0f1;
    text-decoration: none;
}

.nav-links a:hover {
    text-decoration: underline;
}

.nav-user {
    color: #bdc3c7;
    font-size: 0.9rem;
}

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

/* ============================================
   Flash messages
   ============================================ */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.flash-error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #e74c3c;
}

.flash-success {
    background: #eafaf1;
    color: #27ae60;
    border: 1px solid #27ae60;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: filter 0.15s, transform 0.1s;
}

.btn:hover {
    filter: brightness(1.1);
}

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

.btn-primary {
    background: #3498db;
    color: #fff;
}

/* ============================================
   Login
   ============================================ */
.login-container {
    max-width: 380px;
    margin: 4rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.login-container h1 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* ============================================
   Labeling page
   ============================================ */
.labeling-page {
    max-width: 900px;
    margin: 0 auto;
}

/* Progress */
.progress-section {
    margin-bottom: 1rem;
}

.progress-text {
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.progress-bar {
    background: #dfe6e9;
    border-radius: 8px;
    height: 14px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #27ae60;
    border-radius: 8px;
    transition: width 0.3s;
}

/* Camera info */
.camera-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.yolo-count {
    color: #7f8c8d;
}

/* Image display */
.image-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 65vh;
    margin-bottom: 1rem;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Label buttons */
.label-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.btn-label {
    flex: 1 1 0;
    min-width: 130px;
    max-width: 200px;
    padding: 0.75rem 0.5rem;
    color: #fff;
    font-size: 0.95rem;
    text-align: center;
    position: relative;
}

.btn-no-traffic    { background: #27ae60; }
.btn-low-traffic   { background: #f1c40f; color: #2c3e50; }
.btn-moderate-traffic { background: #e67e22; }
.btn-high-traffic  { background: #e74c3c; }
.btn-unknown       { background: #95a5a6; }

.key-hint {
    display: inline-block;
    background: rgba(255,255,255,0.3);
    width: 1.6em;
    height: 1.6em;
    line-height: 1.6em;
    border-radius: 4px;
    font-weight: 700;
    margin-right: 0.3rem;
    text-align: center;
}

.btn-label.active-press {
    transform: scale(0.93);
    filter: brightness(0.85);
}

/* Current label badge */
.current-label-status {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.label-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.label-none             { background: #ecf0f1; color: #7f8c8d; }
.label-no_traffic       { background: #27ae60; color: #fff; }
.label-low_traffic      { background: #f1c40f; color: #2c3e50; }
.label-moderate_traffic { background: #e67e22; color: #fff; }
.label-high_traffic     { background: #e74c3c; color: #fff; }
.label-unknown          { background: #95a5a6; color: #fff; }

/* Navigation controls */
.nav-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-nav {
    background: #34495e;
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-nav:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    filter: none;
}

.btn-nav:disabled:hover {
    filter: none;
}

.btn-jump {
    background: #8e44ad;
}

.nav-position {
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

/* Image error state */
.image-container {
    position: relative;
}

.image-error-msg {
    display: none;
    color: #e74c3c;
    font-size: 1.1rem;
    text-align: center;
    padding: 2rem;
}

.image-container.image-error img {
    display: none;
}

.image-container.image-error .image-error-msg {
    display: block;
}

/* Reference panel */
.reference-panel {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.reference-panel h3 {
    margin-bottom: 0.75rem;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.ref-item {
    text-align: center;
}

.ref-item img {
    width: 100%;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.ref-item span {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
}

/* Camera filter */
.filter-section {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-section select {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.95rem;
}

/* Keyboard shortcut legend */
.shortcut-legend {
    font-size: 0.85rem;
    color: #7f8c8d;
    text-align: center;
}

.shortcut-legend span {
    margin: 0 0.4rem;
}

kbd {
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-family: monospace;
    font-size: 0.85em;
}

/* ============================================
   Done page
   ============================================ */
.done-page {
    text-align: center;
    margin-top: 4rem;
}

.done-page h1 {
    margin-bottom: 1rem;
    color: #27ae60;
}

.done-page .btn {
    margin-top: 1.5rem;
}

/* ============================================
   Admin dashboard
   ============================================ */
.admin-dashboard h1 {
    margin-bottom: 1.5rem;
}

.admin-dashboard h2 {
    margin: 1.5rem 0 0.75rem;
}

/* Stat cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

/* Distribution bars */
.distribution {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.dist-label {
    width: 160px;
    font-size: 0.9rem;
    text-align: right;
    flex-shrink: 0;
}

.dist-bar-bg {
    flex: 1;
    background: #ecf0f1;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.dist-count {
    width: 50px;
    font-size: 0.9rem;
    text-align: right;
    flex-shrink: 0;
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

/* Export section */
.export-section {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.export-section h2 {
    margin: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
    .reference-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .label-buttons {
        flex-direction: column;
    }

    .btn-label {
        max-width: none;
    }

    .camera-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}
