:root {
    --bg-app-dark: #1e1e1e;
    --bg-panel: #2b2b2b;
    --bg-card: #383838;
    --accent: #4caf50;
    --yolo: #e91e63;
    --text-main: #ffffff;
    --border: #444;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', 'Roboto', 'Noto Sans TC', sans-serif; background: var(--bg-app-dark); color: var(--text-main); height: 100vh; overflow: hidden; }

.app-container { display: flex; height: 100%; width: 100%; }

/* 左側 */
.panel-left { flex: 1.2; background: var(--bg-app-dark); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px; overflow-y: auto; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 1.2rem; color: var(--accent); }

.mode-toggles { display: flex; gap: 15px; }
.radio-container { display: flex; align-items: center; cursor: pointer; }
.radio-container input { margin-right: 5px; accent-color: var(--accent); transform: scale(1.2); cursor: pointer; }
.radio-label { font-size: 0.95rem; }

/* 類別卡片 */
.class-container { display: flex; flex-direction: column; gap: 20px; margin-bottom: 20px; }
.class-card { background: var(--bg-card); border-radius: 8px; padding: 15px; border-left: 6px solid #666; transition: 0.2s; display: flex; flex-direction: column; gap: 10px; }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.class-name { background: transparent; border: none; border-bottom: 1px solid #555; color: #fff; font-size: 1.1rem; padding: 5px; width: 70%; }
.class-name:focus { outline: none; border-bottom-color: var(--accent); }
.btn-delete-class { background: none; border: none; cursor: pointer; opacity: 0.5; font-size: 1.2rem; color: #fff; }
.btn-delete-class:hover { opacity: 1; color: var(--yolo); }

/* 縮圖網格 */
.sample-grid { display: flex; flex-wrap: wrap; gap: 8px; min-height: 80px; max-height: 200px; overflow-y: auto; background: #222; padding: 10px; border-radius: 4px; border: 1px solid #444; }
.empty-tip { width: 100%; text-align: center; color: #666; font-size: 0.8rem; margin-top: 25px; }
.thumb-item { position: relative; width: 60px; height: 60px; border-radius: 4px; overflow: hidden; border: 1px solid #555; background: #000; }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center; cursor: pointer; }
.thumb-item:hover .thumb-overlay { display: flex; }
.thumb-overlay span { color: #ff5252; font-size: 1.5rem; font-weight: bold; }

/* Action Bar */
.action-bar { display: flex; gap: 10px; height: 45px; }
.btn-webcam, .btn-upload { flex: 1; border: none; border-radius: 4px; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; color: white; transition: 0.1s; }
.btn-webcam { background: #555; }
.btn-webcam:hover { background: #666; }
.btn-webcam:active { transform: scale(0.98); background: var(--accent); color: #000; }
.btn-webcam.recording { background: var(--yolo) !important; color: white !important; }
.btn-upload { background: #444; border: 1px dashed #666; }
.btn-upload:hover { border-color: #999; background: #555; }
.btn-add-big { width: 100%; padding: 15px; background: transparent; border: 2px dashed #555; color: #888; border-radius: 8px; cursor: pointer; }
.btn-add-big:hover { border-color: var(--accent); color: var(--accent); }

/* 右側操作面板 */
.panel-right { flex: 0.8; background: var(--bg-panel); display: flex; flex-direction: column; padding: 15px; gap: 15px; overflow-y: auto; }
.box-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.box-title { font-size: 0.85rem; color: #aaa; font-weight: bold; text-transform: uppercase; }
.box-preview { flex: 0 0 auto; background: #000; border-radius: 8px; padding: 10px; }
.cam-wrapper { position: relative; width: 100%; aspect-ratio: 4/3; background: #000; display: flex; justify-content: center; align-items: center; overflow: hidden; border: 1px solid #333; }
video { width: 100%; height: 100%; object-fit: contain; }

#roi-box { position: absolute; width: 150px; height: 150px; border: 3px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0,0,0,0.6); top: 50%; left: 50%; transform: translate(-50%, -50%); cursor: move; z-index: 10; transition: opacity 0.3s; }
#roi-box.hidden { opacity: 0; pointer-events: none; }

.roi-label { position: absolute; top: -25px; left: -3px; background: var(--accent); color: #000; padding: 2px 8px; font-weight: bold; font-size: 12px; border-radius: 4px 4px 0 0; pointer-events: none; white-space: nowrap; }
.resize-handle { position: absolute; width: 20px; height: 20px; background: var(--accent); bottom: 0; right: 0; cursor: nwse-resize; }
.float-tools { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 8px; z-index: 20; }
.float-tools button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.6); color: #fff; cursor: pointer; font-size: 1.1rem; }
#prediction-overlay { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.7); color: var(--accent); padding: 5px 15px; border-radius: 20px; font-weight: bold; pointer-events: none; border: 1px solid var(--accent); z-index: 30; }

.box-training, .box-export { background: var(--bg-card); padding: 15px; border-radius: 8px; }
.train-controls { display: flex; gap: 10px; align-items: flex-end; }
.param-group { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.param-group input { background: #222; border: 1px solid #444; color: #fff; padding: 8px; border-radius: 4px; width: 100%; text-align: center; }
.btn-train-main { flex: 2; background: var(--accent); border: none; padding: 10px; border-radius: 4px; font-weight: bold; cursor: pointer; }
.train-status { margin-top: 10px; text-align: center; color: #ccc; font-size: 0.85rem; }

.predict-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; background: #222; padding: 8px; border-radius: 4px; }
.export-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-tool { background: #444; border: 1px solid #555; color: #ddd; padding: 8px; border-radius: 4px; cursor: pointer; transition: 0.3s; }

.btn-tool.loading { opacity: 0.7; cursor: wait; background: #555; }

.toggle-switch { position: relative; width: 40px; height: 20px; }
.toggle-switch input { opacity: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #555; border-radius: 20px; transition: .4s; }
.slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px; background: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

.conf-control { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
#conf-slider { width: 100px; accent-color: var(--accent); }

.btn-train-main {
    background: linear-gradient(135deg, #043b68, #125ed1); /* 漸層綠 */
    box-shadow: 0 4px 15px rgba(48, 48, 48, 0.3); /* 發光陰影 */
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
    color: #ffffff;
}
.btn-train-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 100, 100, 0.5);
}

.class-card {
    /* 保留原有樣式 */
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.class-card:hover {
    background: #3a3a3a;
    transform: translateX(2px);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1e1e1e; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }