@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #f0f2f5;
    color: #333;
    display: flex;
    min-height: 100vh;
    overflow: auto;
}

.container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    flex: 2;
    min-width: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar h2 {
    margin-bottom: 18px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #222;
    letter-spacing: 0.3px;
}

.input-group {
    display: flex;
    margin-bottom: 18px;
}

.input-group input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 6px 0 0 6px;
    background: #fafafa;
    color: #333;
    outline: none;
    font-size: 0.85rem;
}

.input-group input::placeholder { color: #999; }
.input-group input:focus { border-color: #667eea; }

.input-group button {
    padding: 9px 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: opacity 0.2s;
}
.input-group button:hover { opacity: 0.85; }

#programme-list {
    list-style: none;
}

#programme-list li {
    background: #f7f8fa;
    margin-bottom: 6px;
    padding: 9px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    gap: 6px;
    transition: background 0.25s;
    border: 1px solid #eee;
}

#programme-list li:hover {
    background: #eef0f4;
}

#programme-list li.assigned {
    background: #e8f5e9;
    border-color: #c8e6c9;
}

#programme-list li.highlighted {
    background: #fff3cd;
    border-color: #ffc107;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.4);
}

.prog-num {
    font-weight: 600;
    color: #888;
    font-size: 0.8rem;
    min-width: 1.5em;
}

.prog-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #444;
}

.booth-tag {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

#programme-list li button {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 3px 8px;
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: background 0.2s;
}
#programme-list li button:hover { background: #c0392b; }

/* ---- Main Content ---- */
.main-content {
    flex: 6;
    display: flex;
    padding: 20px;
    gap: 20px;
    min-width: 0;
}

/* ---- Wheel Section ---- */
.wheel-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    padding: 28px 20px;
    border-radius: 16px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    position: relative;
}

.wheel-container {
    position: relative;
    margin-bottom: 28px;
}

.pointer {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    color: #e74c3c;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(231,76,60,0.35));
}

canvas {
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 100%;
    height: auto;
}

.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.controls button {
    padding: 12px 24px;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    transition: transform 0.15s, box-shadow 0.2s;
    letter-spacing: 0.3px;
    flex: 1 1 0;
    min-width: 200px;
    text-align: center;
}
.controls button:hover { transform: translateY(-1px); }
.controls button:active { transform: translateY(0); }

#spin-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    box-shadow: 0 4px 12px rgba(40,167,69,0.25);
}

#spin-btn:disabled {
    background: #aaa;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

#next-btn {
    background: linear-gradient(135deg, #ffc107, #ff9f43);
    color: #222;
    box-shadow: 0 4px 12px rgba(255,193,7,0.25);
}

#next-btn:disabled {
    background: #aaa;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

#mute-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    font-size: 1.1rem;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}
#mute-btn:hover { background: #e0e0e0; }

.result {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    min-height: 1.5em;
}

.result.fade-in {
    animation: fadeInResult 0.4s ease;
}

@keyframes fadeInResult {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Map Section ---- */
.map-section {
    flex: 1;
    min-width: 0;
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
}

.map-section h2 {
    color: #222;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.map-controls {
    margin-bottom: 10px;
    font-size: 0.82rem;
    color: #888;
}

.svg-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.svg-map {
    width: 100%;
    height: 100%;
}

.booth {
    fill: #e9ecef;
    stroke: #bbb;
    stroke-width: 2;
    cursor: pointer;
    transition: fill 0.3s, stroke 0.3s;
}

.booth-text {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    fill: #555;
    pointer-events: none;
}

.booth.disabled {
    fill: #ddd !important;
    stroke: #bbb !important;
    opacity: 0.5;
    cursor: not-allowed;
}

.booth.active {
    fill: #fff3cd;
    stroke: #ffc107;
    animation: pulse 1.5s infinite;
}

.booth.assigned {
    fill: #d4edda;
    stroke: #28a745;
}

@keyframes pulse {
    0%   { opacity: 0.7; }
    50%  { opacity: 1; fill: #ffe8a1; }
    100% { opacity: 0.7; }
}

.assignment-list {
    margin-top: 14px;
    max-height: 180px;
    overflow-y: auto;
}

.assignment-list h3 {
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #333;
}

#assignments li {
    font-size: 0.82rem;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    color: #555;
}
#assignments li strong { color: #28a745; }

/* ---- Map Hint ---- */
.map-hint {
    font-size: 0.82rem;
    color: #888;
    margin-bottom: 10px;
}

.map-hint.hidden {
    display: none;
}

/* ---- Map Banner ---- */
.map-banner {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: #e8f4fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.78rem;
    color: #1565c0;
    text-align: center;
    z-index: 10;
    pointer-events: auto;
}

.banner-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #1565c0;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 5px;
    line-height: 1;
    opacity: 0.6;
}
.banner-close:hover {
    opacity: 1;
}

.map-banner.hidden {
    display: none;
}

/* ---- Copy Button ---- */
#copy-assignments-btn {
    margin-left: 8px;
    padding: 3px 10px;
    font-size: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f7f8fa;
    cursor: pointer;
    transition: background 0.2s;
    vertical-align: middle;
}
#copy-assignments-btn:hover {
    background: #e0e0e0;
}

/* ---- Disabled cross ---- */
.booth-cross {
    stroke: #999;
    stroke-width: 2;
    pointer-events: none;
}

/* ---- Responsive ---- */

/* Foldable inner screen & tablets (≤1024px) */
@media (max-width: 1024px) {
    .container {
        flex-direction: row;
        flex-wrap: nowrap;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        flex: 2;
        min-width: 0;
        max-height: none;
        height: 100vh;
        border-right: 1px solid #e0e0e0;
        border-bottom: none;
        padding: 14px 12px;
        overflow-y: auto;
    }

    .main-content {
        flex: 3;
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        min-width: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .wheel-section {
        flex: 0 0 auto;
        width: 100%;
        padding: 12px;
    }

    .wheel-section canvas {
        width: 220px;
        height: 220px;
    }

    .wheel-container { margin-bottom: 10px; }

    .controls button { padding: 8px 16px; font-size: 0.82rem; }

    .map-section {
        flex: 1;
        width: 100%;
        min-width: 0;
    }
}

/* When too narrow for side-by-side top (≤520px), stack all vertically */
@media (max-width: 520px) {
    .container {
        flex-direction: column;
        flex-wrap: nowrap;
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        flex: 2;
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 12px;
        overflow-y: auto;
    }

    .main-content {
        flex: 6;
        width: 100%;
        overflow-y: auto;
    }
}

/* Mobile phones (≤600px) */
@media (max-width: 600px) {
    .sidebar {
        padding: 12px;
    }

    .sidebar h2 { font-size: 1rem; margin-bottom: 10px; }

    #programme-list li { font-size: 0.78rem; padding: 7px 10px; }

    .main-content {
        padding: 10px;
        gap: 12px;
    }

    .wheel-section {
        padding: 16px 12px;
    }

    .wheel-container { margin-bottom: 16px; }

    .controls button {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .result { font-size: 0.95rem; }

    .map-section {
        padding: 14px;
    }

    .map-section h2 { font-size: 1rem; }
}

/* Foldable phones folded / very narrow (≤400px) */
@media (max-width: 400px) {
    .controls { flex-direction: column; align-items: center; }
    .controls button { width: 100%; }
}
