:root {
    --bg-app: #09090b;
    --bg-panel: #18181b;
    --bg-card: #27272a;
    --bg-hover: #3f3f46;
    --bg-input: #09090b;

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.3);

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 6px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.hidden {
    display: none !important;
}

.clickable {
    cursor: pointer;
    user-select: none;
}

/* Sidebar */
.sidebar {
    width: 300px;
    min-width: 200px;
    max-width: 600px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    overflow: hidden;
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.video-list {
    list-style: none;
    padding: 0.5rem;
}

.video-item {
    padding: 0.6rem 0.75rem;
    margin-bottom: 2px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.video-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.video-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.2);
}

.video-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-top h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #000;
    min-width: 0;
}

.show-sidebar-btn {
    position: sticky;
    top: 1rem;
    left: 1rem;
    z-index: 30;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 0.5rem;
    color: var(--text-main);
    transition: background 0.2s;
}

.show-sidebar-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.main-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    background-color: var(--bg-app);
}

.main-empty-state h1 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.labeling-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-height: 0;
}

/* Video Section */
.video-section {
    background-color: #000;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.video-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

video {
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
    background: #000;
}

.video-controls {
    background: var(--bg-panel);
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.progress-bar-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: 0.75rem;
    position: relative;
    transition: height 0.2s;
}

.progress-bar-container:hover {
    height: 6px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
    box-shadow: 0 0 8px var(--primary-glow);
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 36px;
}

.left-controls,
.center-controls,
.right-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.time-display,
.frame-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.speed-select {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

/* Right Panel */
.right-panel {
    width: 400px;
    min-width: 300px;
    max-width: 600px;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 15;
    overflow: hidden;
    position: relative;
}

.right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-left: none !important;
    pointer-events: none;
}

.resizer-right-panel {
    width: 6px;
    cursor: col-resize;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    background: transparent;
    transition: background 0.2s;
}

.resizer-right-panel:hover,
.resizer-right-panel.resizing {
    background: var(--primary);
}

.right-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.right-panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 40px);
}

.right-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-actions-top {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.card h4 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.input-group {
    margin-bottom: 0.75rem;
}

.input-group.compact {
    margin-bottom: 0.5rem;
}

.input-group.no-margin {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.input-group input,
.input-group select,
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus,
.input-group select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.tight-row {
    display: flex;
    gap: 0.5rem;
}

.separator {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

/* Initial Conditions Radio Groups */
.ic-group {
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.ic-group:hover {
    border-color: var(--border);
}

.ic-group h5 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
}

.ic-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.radio-item input[type="radio"] {
    accent-color: var(--primary);
    cursor: pointer;
}

.radio-item label {
    cursor: pointer;
    color: var(--text-main);
}

/* Transitions */
.transitions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0;
}

#transitionsCard.collapsed .transitions-list,
#transitionsCard.collapsed #addTransitionBtn {
    display: none;
}

#transitionsCard.collapsed {
    height: auto;
    min-height: auto;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

#transitionsToggleIcon {
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--text-muted);
}

#transitionsCard.collapsed #transitionsToggleIcon {
    transform: rotate(-90deg);
}

/* Multi-line transition item */
.transition-item.multi-line {
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, background-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transition-item.multi-line:hover {
    border-color: var(--border-hover);
}

/* Color coding for occlusion labels */
.transition-item.occlusion-start {
    background: rgba(204, 52, 51, 0.5);
    border-color: rgba(204, 52, 51, 1);
}

.transition-item.occlusion-start:hover {
    border-color: rgba(204, 52, 51, 0.8);
}

.transition-item.occlusion-end {
    background: rgba(49, 108, 92, 0.5);
    border-color: rgba(49, 108, 92, 1);
}

.transition-item.occlusion-end:hover {
    border-color: rgba(49, 108, 92, 0.8);
}

.transition-item.partial-occlusion-start {
    background: rgba(217, 119, 6, 0.5);
    border-color: rgba(217, 119, 6, 1);
}

.transition-item.partial-occlusion-start:hover {
    border-color: rgba(217, 119, 6, 0.8);
}

.transition-item.partial-occlusion-end {
    background: rgba(217, 119, 6, 0.25);
    border-color: rgba(217, 119, 6, 0.5);
}

.transition-item.partial-occlusion-end:hover {
    border-color: rgba(217, 119, 6, 0.7);
}

/* Color coding for discard labels */
.transition-item.discard-on {
    background: rgba(107, 114, 128, 0.5);
    border-color: rgba(107, 114, 128, 1);
}

.transition-item.discard-on:hover {
    border-color: rgba(107, 114, 128, 0.8);
}

.transition-item.discard-off {
    background: rgba(75, 85, 99, 0.3);
    border-color: rgba(75, 85, 99, 0.6);
}

.transition-item.discard-off:hover {
    border-color: rgba(75, 85, 99, 0.8);
}

.transition-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.transition-row .input-group {
    margin-bottom: 0;
}

.trans-original-time-group {
    min-width: 5.5rem;
}

.trans-original-time {
    display: block;
    padding: 0.35rem 0;
    line-height: 1.2;
}

.transition-item.single-line {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-direction: row;
    flex-wrap: nowrap;
    transition: border-color 0.2s;
}

.transition-item.single-line:hover {
    border-color: var(--border-hover);
}

.transition-item.single-line .input-group {
    margin-bottom: 0;
}

.transition-item.single-line .input-group.grow {
    flex: 1;
}

.delete-btn {
    color: var(--text-muted);
    transition: color 0.2s;
    padding: 4px;
}

.delete-btn:hover {
    color: var(--danger);
}

.input-with-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.input-with-btn input {
    flex: 1;
    min-width: 0;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

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

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

.btn-danger:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.btn-icon.small {
    font-size: 1rem;
    padding: 0.25rem;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.7rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-xs:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.resizer-sidebar:hover,
.resizer-sidebar.resizing {
    background: var(--primary);
}

/* Multi-select Dropdown */
.multi-select-dropdown {
    position: relative;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.multi-select-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.select-trigger {
    padding: 0.5rem 0.75rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 34px;
    display: flex;
    align-items: center;
}

.select-options {
    display: none;
    position: sticky;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 100;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.multi-select-dropdown.show .select-options {
    display: block;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
}

.option-item:hover {
    background: var(--bg-hover);
}

.option-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: auto;
    margin: 0;
}

/* Tree Structure & Scroll Fixes */
.folder-container { padding-left: 10px; margin: 4px 0; }
.folder-item { display: flex; align-items: center; cursor: pointer; padding: 4px; border-radius: 4px; }
.folder-item:hover { background: var(--bg-hover); }
.folder-icon { margin-right: 8px; }
.folder-name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-item { display: flex; align-items: center; justify-content: space-between; padding: 8px; margin: 2px 0; cursor: pointer; border-radius: 4px; border: 1px solid transparent; }
.video-item:hover { background: var(--bg-hover); }
.video-item.active { background: rgba(59,130,246,0.1); border-color: var(--primary); }
.video-item-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.video-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.video-assigned-tag { font-size: 0.7rem; background: rgba(59,130,246,0.2); color: var(--primary); padding: 1px 4px; border-radius: 4px; border: 1px solid rgba(59,130,246,0.3); }
.video-assigned-tag.reviewer { background: rgba(245,158,11,0.2); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.video-item-actions { display: flex; align-items: center; gap: 8px; }
.status-icon { font-size: 1.1rem; }
.assign-btn { background: none; border: none; cursor: pointer; opacity: 0.5; padding: 2px; }
.video-item:hover .assign-btn { opacity: 1; }
.assign-btn:hover { transform: scale(1.1); }
.batch-assign-btn { margin-left: 8px; }

/* Modal Styles */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; width: 400px; max-width: 90vw; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Login Overlay */
.login-overlay { position: fixed; inset: 0; background: var(--bg-app); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.login-box { background: var(--bg-panel); padding: 32px; border-radius: 8px; border: 1px solid var(--border); width: 100%; max-width: 400px; text-align: center; }
.login-box h2 { margin-bottom: 24px; color: white; }
.login-box form { display: flex; flex-direction: column; gap: 16px; }
.login-box input { padding: 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-app); color: white; }
.error-msg { color: #ef4444; font-size: 0.9rem; margin-top: 8px; }

/* Scrollbar Force Fix */
::-webkit-scrollbar { width: 14px !important; height: 14px !important; display: block !important; }
::-webkit-scrollbar-thumb { background: #4b5563 !important; border: 3px solid #18181b !important; border-radius: 10px !important; min-height: 40px !important; }
::-webkit-scrollbar-track { background: #09090b !important; display: block !important; }
.video-list-container { overflow-y: scroll !important; }

/* Status Filters Styling */
.status-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.filter-btn { background: var(--bg-panel); color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s ease; outline: none; }
.filter-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.filter-btn.active { background: var(--primary); color: #ffffff; border-color: var(--primary); box-shadow: 0 0 8px rgba(59, 130, 246, 0.4); }
