:root {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --accent: #ef4444;
    --accent-hover: #dc2626;
    --winner-red: #991b1b;
    --success-green: #22c55e;
    --disabled-gray: #475569;
    --blue: #3b82f6;
    --warning-orange: #f59e0b;
    --toggle-on: #10b981;
    --toggle-off: #334155;
}

/* ---------------- BODY LAYOUT ---------------- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
}

/* ---------------- SIDEBAR ---------------- */
nav {
    width: 250px;
    height: 100vh;
    background: #020617;
    padding: 20px;
    box-sizing: border-box;
    border-right: 1px solid #334155;
    position: sticky;
    top: 0;
}

nav h2 {
    color: var(--accent);
    margin-bottom: 30px;
}

.nav-item {
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: 0.2s;
}

.nav-item:hover {
    background: #1e293b;
}

.nav-item.active {
    background: var(--accent);
}

/* ---------------- MAIN CONTENT ---------------- */
main {
    flex: 1;
    padding: 40px;
    height: 100vh;
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* ---------------- TAB SYSTEM ---------------- */
.tab-content {
    display: none;
    width: 100%;
}

.tab-content.active {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0; /* CRITICAL: allows children to shrink/scroll */
}

/* ---------------- MANAGEMENT LAYOUT ---------------- */
.mgmt-container {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 30px;
    max-width: 2000px;  /* increased from 1200px */
    width: 100%;
    flex: 1 1 auto;
    min-height: 0; /* CRITICAL */
}

.mgmt-column {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0; /* CRITICAL */
}

/* ---------------- CARD ---------------- */
.card {
    background: var(--card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header-label {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: block;
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
    color: var(--blue);
}

/* ---------------- FORM ---------------- */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #94a3b8;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

textarea {
    height: 120px;
    resize: vertical;
}

/* ---------------- BUTTONS ---------------- */
.btn-row {
    display: flex;
    gap: 10px;
}

button {
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    color: white;
}

button:hover:not(:disabled) {
    filter: brightness(1.1);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#launch-btn {
    background: var(--success-green);
    flex: 2;
}

#launch-btn:hover {
    background: #16a34a;
}

/* ---------------- SUB NAV ---------------- */
.sub-nav {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
}

.sub-nav span {
    cursor: pointer;
    color: #94a3b8;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.sub-nav span:hover {
    background: #1e293b;
}

.sub-nav span.active {
    color: white;
    background: var(--blue);
}

/* ---------------- DROP ZONES ---------------- */
#drop-zone,
#sup-drop-zone {
    border: 2px dashed #334155;
    border-radius: 12px;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: #0f172a;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}

#drop-zone:hover,
#sup-drop-zone:hover {
    border-color: var(--blue);
    background: #1e293b;
}

/* ---------------- IMAGE PREVIEW ---------------- */
#preview-container,
#sup-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.preview-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #334155;
}

/* ---------------- QUEUE ---------------- */
#draggable-queue {
    min-height: 200px !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    padding: 10px;
    border: 1px solid #334155;
    background: #0f172a;
    box-sizing: border-box;
    overflow-y: auto;
}

.queue-item {
    min-height: 48px !important;
    height: auto !important;
    display: flex !important;
    align-items: center;
    padding: 12px 15px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: grab;
    box-sizing: border-box;
}

.queue-item:active {
    cursor: grabbing;
}

.drag-handle {
    color: #475569;
    margin-right: 15px;
    font-size: 1.2rem;
}

.queue-ghost {
    opacity: 0.4;
    background: var(--accent) !important;
}

.queue-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.remove-btn {
    background: transparent;
    color: #ef4444;
    padding: 5px;
    cursor: pointer;
}

/* ---------------- WINNER GRID ---------------- */
.winner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.winner-btn {
    background: #334155;
    font-size: 0.85rem;
    text-align: left;
    padding: 10px;
    border-radius: 6px;
    color: white;
    border: 1px solid transparent;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.winner-btn:hover {
    background: #475569;
}

.winner-btn.selected {
    background: var(--winner-red);
    border-color: white;
    cursor: not-allowed;
    opacity: 0.8;
}

/* ---------------- STATUS TEXT ---------------- */
.status {
    margin-top: 10px;
    font-size: 0.9rem;
    text-align: center;
}

/* ---------------- TOGGLE SWITCH ---------------- */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 1rem;
    color: #e2e8f0;
}

.toggle-switch {
    position: relative;
    width: 54px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--toggle-off);
    transition: .4s;
    border-radius: 28px;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--toggle-on);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Ensure columns have equal width and can grow */
.mgmt-column {
    flex: 1 1 0;
    min-width: 400px;  /* minimum width to keep them readable */
}

/* Optional: if you want the right column to be slightly smaller */
.mgmt-column:first-child {
    flex: 1.2 1 0;  /* left column gets a bit more space */
}

/* Selected overlay (already defined in JS style, but you can adjust) */
.selected-overlay {
    background-color: rgba(128, 128, 128, 0.5);
}