:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --primary: #f43f5e;
    --primary-hover: #e11d48;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --green: #10b981;
    --yellow: #f59e0b;
    --input-bg: #020617;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }

/* ============================
   CUSTOM SCROLLBAR STYLING
   ============================ */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-dark);
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background-color: var(--border); /* Dark Slate Grey */
    border-radius: 6px;
    border: 2px solid var(--bg-dark); /* Creates a padding effect around the bar */
}

::-webkit-scrollbar-thumb:hover {
    background-color: #475569; /* Slightly lighter on hover */
}

/* ============================
   EXISTING STYLES
   ============================ */

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

/* LOADING SCREEN */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(12px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease-out;
}
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.loader-content { text-align: center; width: 300px; }
.loader-content h3 { margin: 1rem 0; font-weight: 600; color: var(--text-main); letter-spacing: 1px; }
.spin-icon { font-size: 3rem; color: var(--primary); animation: spin 2s infinite linear; }
.progress-bar-track { width: 100%; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; position: relative; }
.progress-bar-fill { width: 40%; height: 100%; background: var(--primary); position: absolute; left: 0; top: 0; border-radius: 2px; animation: loading 1.5s infinite ease-in-out; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes loading { 0% { left: -40%; width: 40%; } 50% { left: 30%; width: 60%; } 100% { left: 100%; width: 10%; } }

/* Header */
header {
    height: 60px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; flex-shrink: 0; z-index: 20;
}
.header-actions { display: flex; align-items: center; gap: 0.8rem; }
.logo { display: flex; align-items: center; gap: 0.5rem; color: var(--primary); }
.logo h1 { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.logo span { font-size: 1.4rem; }

/* Dashboard */
.dashboard { display: flex; flex: 1; height: calc(100vh - 60px); overflow: hidden; }
.panel { padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; }

/* Left Panel */
.left-panel { width: 25%; min-width: 300px; border-right: 1px solid var(--border); background: #162032; }
.column-col { flex-direction: column; align-items: flex-start !important; gap: 0.5rem; }
.header-top { display: flex; justify-content: space-between; width: 100%; align-items: center; }

.genre-select {
    background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border);
    padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 0.85rem; outline: none; cursor: pointer; max-width: 120px;
}

/* Bulk Controls */
.bulk-controls { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.2rem; }
.text-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 700; padding: 0; font-size: 0.8rem; letter-spacing: 0.5px; transition: color 0.2s; }
.text-btn:hover { color: var(--primary-hover); text-decoration: underline; }
.separator { color: var(--border); font-size: 0.8rem; }

.movie-grid { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; padding-bottom: 2rem; }

.movie-btn {
    background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-muted);
    padding: 0.8rem; text-align: left; border-radius: 0.5rem; cursor: pointer; transition: all 0.2s;
    display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 0.3rem 0.5rem;
}
.movie-btn:hover { border-color: var(--text-muted); }
.movie-info { grid-column: 1 / 2; grid-row: 1 / 2; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags-row { grid-column: 1 / 2; grid-row: 2 / 3; display: flex; gap: 4px; flex-wrap: wrap; }
.genre-tag-mini { font-size: 0.6rem; background: var(--border); padding: 1px 5px; border-radius: 4px; color: var(--text-muted); text-transform: uppercase; }
.delete-btn {
    grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; justify-self: end; background: transparent;
    border: none; color: var(--border); cursor: pointer; padding: 8px; border-radius: 4px;
}
.delete-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.movie-btn.active { background: rgba(16, 185, 129, 0.05); border-color: var(--green); color: var(--text-main); }
.movie-btn.active .genre-tag-mini { background: rgba(16, 185, 129, 0.2); color: var(--green); }

/* Center Panel */
.center-panel {
    width: 50%; align-items: center; justify-content: center; position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%); display: flex; flex-direction: column;
}
.wheel-wrapper { position: relative; width: 90%; max-width: 500px; aspect-ratio: 1/1; margin-bottom: 2rem; }
canvas { width: 100%; height: 100%; filter: drop-shadow(0 0 15px rgba(0,0,0,0.5)); transition: transform 4s cubic-bezier(0.25, 1, 0.5, 1); }
.pointer {
    position: absolute; right: -3%; top: 50%; transform: translateY(-50%);
    border-top: 20px solid transparent; border-bottom: 20px solid transparent; border-right: 40px solid #ffffff;
    z-index: 10; filter: drop-shadow(-2px 0 2px rgba(0,0,0,0.3));
}
.big-spin-btn {
    background: var(--primary); color: white; border: none; font-size: 1.5rem; font-weight: 800;
    padding: 1rem 4rem; border-radius: 50px; cursor: pointer;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.4); transition: transform 0.1s, box-shadow 0.2s; letter-spacing: 2px;
}
.big-spin-btn:hover { box-shadow: 0 0 30px rgba(244, 63, 94, 0.6); transform: scale(1.05); }
.big-spin-btn:disabled { background: var(--border); cursor: not-allowed; box-shadow: none; transform: none; }

/* Right Panel */
.right-panel { width: 25%; min-width: 300px; border-left: 1px solid var(--border); background: #162032; }
.result-box { background: var(--bg-panel); border: 2px solid var(--primary); padding: 1.5rem; border-radius: 1rem; text-align: center; margin-bottom: 2rem; animation: popIn 0.3s ease-out; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-box.hidden { display: none; }
.label { text-transform: uppercase; letter-spacing: 1px; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.winner-title { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; line-height: 1.3; font-weight: 800; }
.winner-genre-tag { display: inline-block; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.action-buttons { display: flex; flex-direction: column; gap: 0.5rem; }
.watched-list { list-style: none; margin-top: 1rem; padding-bottom: 2rem;}
.watched-list li {
    padding: 0.8rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text-muted);
    font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem;
}
.watched-list li::before { content: 'check'; font-family: 'Material Icons Round'; color: var(--green); }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel-header h2 { font-size: 1.1rem; color: var(--text-main); }
.panel-header small { color: var(--text-muted); font-size: 0.75rem; }

/* Buttons & Utils */
.btn { border: none; padding: 0.6rem 1rem; border-radius: 0.4rem; cursor: pointer; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.9rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-panel); color: var(--text-main); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }
.btn-text { background: transparent; color: var(--text-muted); }
.btn-text:hover { color: var(--text-main); }
.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;}
.icon-btn:hover { color: var(--primary); }
.icon-btn span { font-size: 1.2rem; }
.empty-state { text-align: center; color: var(--border); margin-top: 2rem; font-style: italic; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal { background: var(--bg-panel); padding: 0; border-radius: 1rem; max-width: 90%; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.5); }
.modal-xl { width: 900px; height: 600px; }
.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); }
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.import-builder { display: flex; flex: 1; overflow: hidden; background: #162032; }
.builder-input { flex: 1; padding: 2rem; display: flex; flex-direction: column; gap: 1.5rem; }
.input-group label, .genre-selector label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--text-muted); font-size: 0.9rem; }
.builder-input input { background: var(--input-bg); border: 1px solid var(--border); padding: 1rem; border-radius: 0.5rem; color: var(--text-main); font-size: 1.1rem; width: 100%; }
.builder-input input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.chips-container { display: flex; flex-wrap: wrap; gap: 0.6rem; max-height: 200px; overflow-y: auto; }
.genre-chip { background: var(--bg-panel); border: 1px solid var(--border); padding: 0.5rem 0.8rem; border-radius: 20px; font-size: 0.8rem; cursor: pointer; color: var(--text-muted); transition: all 0.2s; user-select: none; }
.genre-chip:hover { border-color: var(--text-main); background: #334155; }
.genre-chip.selected { background: var(--primary); color: white; border-color: var(--primary); }
.builder-action { width: 60px; background: #0f172a; border-left: 1px solid var(--border); border-right: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.add-arrow-btn { width: 100%; height: 100%; background: transparent; border: none; color: var(--text-muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; font-weight: 700; font-size: 0.7rem; transition: background 0.2s, color 0.2s; }
.add-arrow-btn:hover { background: rgba(255,255,255,0.05); color: var(--primary); }
.add-arrow-btn .material-icons-round { font-size: 2rem; }
.builder-staging { width: 35%; background: var(--bg-panel); display: flex; flex-direction: column; }
.builder-staging h3 { padding: 1.5rem; margin: 0; font-size: 0.9rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.staging-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.staging-item { background: var(--bg-dark); padding: 0.8rem; border-radius: 0.5rem; display: flex; justify-content: space-between; align-items: center; border: 1px solid rgba(255,255,255,0.05); }
.staging-item small { color: var(--text-muted); display: block; margin-top: 2px; font-size: 0.75rem; }
.modal-actions { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 1rem; background: var(--bg-panel); }

/* Settings */
.settings-genre-list { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.settings-genre-item { background: var(--border); padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.settings-genre-item button { background: none; border: none; color: #ef4444; cursor: pointer; font-weight: bold; font-size: 1rem; display: flex; margin-left: 5px; }

@media (max-width: 900px) {
    body { height: auto; overflow-y: auto; }
    .dashboard { flex-direction: column; height: auto; overflow: visible; }
    .panel { width: 100%; min-width: 0; border: none; border-bottom: 1px solid var(--border); padding: 1.5rem 1rem; height: auto; overflow: visible; }
    .center-panel { order: 1; padding: 2rem 1rem; }
    .right-panel { order: 4; }
    .left-panel { order: 3; }
    .wheel-wrapper { width: 85%; }
    .big-spin-btn { width: 100%; padding: 1rem; border-radius: 12px; }
    .modal-xl { width: 100%; height: 100%; border-radius: 0; border: none; }
    .import-builder { flex-direction: column; overflow-y: auto; }
    .builder-input { width: 100%; flex: none; height: auto; padding: 1.5rem; }
    .builder-staging { width: 100%; flex: 1; min-height: 200px; }
    .builder-action { width: 100%; height: 60px; border: none; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
    .add-arrow-btn { flex-direction: row; }
    .add-arrow-btn .material-icons-round { transform: rotate(90deg); }
}