/* ============================================================
   carPython 车牌识别系统 — 样式表
   ============================================================ */

/* --- CSS Variables / Reset --- */
:root {
    --sidebar-width: 350px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --sidebar-accent: #38bdf8;
    --main-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --red-500: #ef4444;
    --orange-500: #f97316;
    --radius: 8px;
    --transition: 200ms ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", sans-serif;
    background: var(--main-bg);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* --- Layout --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    z-index: 10;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.main-area {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Sidebar Components --- */

.sidebar-header {
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
.logo-icon { font-size: 24px; }
.logo-subtitle {
    font-size: 12px;
    color: var(--sidebar-accent);
    margin-top: 4px;
}

/* Upload Area */
.upload-area {
    background: rgba(255,255,255,0.05);
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--sidebar-accent);
    background: rgba(56,189,248,0.1);
    box-shadow: 0 0 12px rgba(56,189,248,0.2);
}
.upload-icon { font-size: 28px; margin-bottom: 4px; }
.upload-text {
    font-size: 13px;
    color: #cbd5e1;
    margin: 4px 0;
}
.upload-hint {
    font-size: 11px;
    color: #94a3b8;
    margin: 4px 0;
}
.btn-upload {
    margin-top: 8px;
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
}
.btn-upload:hover { background: rgba(255,255,255,0.2); }

.upload-buttons {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.upload-buttons .btn-upload {
    flex: 1;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 4px;
}
.file-count {
    font-size: 11px;
    color: #94a3b8;
}
.btn-clear-all {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,0.3);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all var(--transition);
}
.btn-clear-all:hover {
    background: rgba(239,68,68,0.3);
    color: #fecaca;
    border-color: rgba(239,68,68,0.5);
}

.file-list {
    margin-top: 8px;
    max-height: 100px;
    overflow-y: auto;
}
.file-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.08);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.file-tag:hover {
    background: rgba(255,255,255,0.14);
}
.file-tag.active {
    background: rgba(56,189,248,0.15);
    border-color: var(--sidebar-accent);
}
.file-tag .remove-file {
    margin-left: auto;
    cursor: pointer;
    color: var(--red-500);
    font-weight: bold;
    font-size: 14px;
}
.file-tag .remove-file:hover {
    color: #ff6b6b;
}

/* Sections */
.section {
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius);
    padding: 12px;
}
.section-title {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 6px;
}
.mode-tab {
    flex: 1;
    padding: 8px 6px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all var(--transition);
}
.mode-tab.active {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: #fff;
    font-weight: 600;
}
.mode-tab:hover:not(.active) {
    background: rgba(255,255,255,0.08);
}

/* Parameter Controls */
.param-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.param-item { }
.param-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 4px;
}
.param-value {
    font-weight: 600;
    color: var(--sidebar-accent);
    min-width: 28px;
    text-align: right;
}
.param-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--sidebar-accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(56,189,248,0.5);
}

.param-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-reset {
    flex: 1;
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.15);
}
.btn-reset:hover { background: rgba(255,255,255,0.15); }
.btn-run {
    flex: 1.5;
    background: var(--blue-600);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.btn-run:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 16px rgba(37,99,235,0.5);
}
.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Sample Images */
.samples-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.sample-thumb {
    aspect-ratio: 4/3;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
}
.sample-thumb:hover { border-color: var(--sidebar-accent); }
.sample-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.samples-loading {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    grid-column: 1/-1;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stat-label { font-size: 12px; color: #94a3b8; }
.stat-number {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

/* --- Viewer --- */
.viewer-toolbar {
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.video-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.vc-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
}
.vc-btn:hover { border-color: var(--blue-500); color: var(--blue-600); }
.vc-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.vc-separator { color: var(--border-color); font-size: 14px; }
.vc-label { font-size: 12px; color: var(--text-secondary); }
.vc-select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    max-width: 180px;
}
.vc-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}

/* Viewer Panes */
.viewer-panel {
    flex: 1;
    display: flex;
    gap: 2px;
    background: var(--border-color);
    min-height: 0;
}

.viewer-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    overflow: hidden;
}

.pane-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.pane-header h2 {
    font-size: 14px;
    font-weight: 600;
}
.pane-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--main-bg);
    color: var(--text-secondary);
}

.pane-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.pane-content img,
.pane-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.pane-content img {
    transition: opacity 0.3s ease;
}
.pane-content img.highlight-flash {
    animation: highlightPulse 0.6s ease-out;
}
@keyframes highlightPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.6); }
    50%  { box-shadow: 0 0 24px 4px rgba(37,99,235,0.3); }
    100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}
.pane-placeholder {
    text-align: center;
    color: var(--text-secondary);
}
.placeholder-icon { font-size: 48px; margin-bottom: 8px; }
.pane-placeholder p { font-size: 14px; }

/* BBox hover tooltip */
.bbox-info-popup {
    position: absolute;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 20;
}

/* --- Results Panel --- */
.results-panel {
    flex-shrink: 0;
    background: var(--card-bg);
    border-top: 2px solid var(--border-color);
    max-height: 35vh;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.results-header h2 { font-size: 14px; font-weight: 600; }
.results-actions { display: flex; gap: 6px; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.btn-export {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-export:hover { border-color: var(--blue-500); color: var(--blue-600); }
.btn-export:disabled { opacity: 0.4; cursor: not-allowed; }

.results-table-wrapper {
    flex: 1;
    overflow-y: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.results-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}
.results-table th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.results-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
}
.results-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}
.results-table tbody tr:hover {
    background: #f0f9ff;
}
.results-table tbody tr.selected {
    background: #dbeafe;
}
.table-empty td {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 12px !important;
    cursor: default !important;
}
.table-empty td:hover { background: transparent !important; }

/* Confidence bar in table */
.conf-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}
.conf-bar-bg {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    max-width: 100px;
}
.conf-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 500ms ease;
}
.conf-bar-fill.high { background: var(--green-500); }
.conf-bar-fill.medium { background: var(--orange-500); }
.conf-bar-fill.low { background: var(--red-500); }
.conf-bar-text {
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: right;
}

/* Plate type badge */
.plate-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.plate-badge.green {
    background: #dcfce7;
    color: var(--green-600);
}
.plate-badge.blue {
    background: #dbeafe;
    color: var(--blue-600);
}

/* --- Spinner Overlay --- */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.spinner-box {
    background: var(--card-bg);
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    min-width: 280px;
}
.spinner-circle {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* Progress bar in spinner */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}
.progress-bar-fill {
    height: 100%;
    background: var(--blue-600);
    border-radius: 3px;
    transition: width 300ms ease;
    width: 0%;
}
.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}
.toast {
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 300ms ease, fadeOut 300ms ease 3.7s forwards;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { background: #dcfce7; color: var(--green-600); border-left: 4px solid var(--green-500); }
.toast.error { background: #fef2f2; color: var(--red-500); border-left: 4px solid var(--red-500); }
.toast.info { background: #dbeafe; color: var(--blue-600); border-left: 4px solid var(--blue-500); }
.toast.warning { background: #fff7ed; color: #c2410c; border-left: 4px solid var(--orange-500); }
.toast .toast-close {
    margin-left: auto;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
}
.toast .toast-close:hover { opacity: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 40vh;
        flex-shrink: 0;
    }
    .viewer-panel { flex-direction: column; }
    .results-panel { max-height: 30vh; }
}
