:root {
    --bg-surface: rgba(18, 18, 18, 0.92);
    --bg-elevated: rgba(30, 30, 30, 0.95);
    --bg-input: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --text: #f0f0f0;
    --text-muted: rgba(255, 255, 255, 0.5);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --ease: all 0.2s ease;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: var(--font);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─── */

#viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#panorama {
    width: 100%;
    height: 100%;
    background: #000;
}

#ui-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    z-index: 100;
}

/* ─── Header ─── */

header {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    width: fit-content;
    align-self: center;
    box-shadow: var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-icon { display: none; }

.logo h1 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.scene-info {
    padding-left: 16px;
    border-left: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--ease);
}

.icon-btn:hover { color: var(--accent); }

/* ─── Room Selector (Bottom Nav) ─── */

#room-selector {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    width: fit-content;
    align-self: center;
    max-width: 92%;
    box-shadow: var(--shadow);
}

.nav-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-scroll::-webkit-scrollbar { display: none; }

.room-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 400;
    white-space: nowrap;
    transition: var(--ease);
}

.room-btn:hover {
    background: var(--bg-input);
    color: var(--text);
}

.room-btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

/* ─── Controls ─── */

#controls {
    position: absolute;
    right: 16px;
    bottom: 80px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: var(--shadow);
}

#controls button {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--ease);
}

#controls button:hover {
    background: var(--bg-input);
    color: var(--text);
}

/* ─── Loading ─── */

#loading-overlay {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.4s ease;
}

.loader {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-overlay p {
    margin-top: 16px;
    font-size: 0.75rem;
    font-weight: 300;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ─── Utility ─── */

.hidden { display: none !important; }

/* ─── Hide Pannellum UI ─── */

.pnlm-panorama-info,
.pnlm-compass,
.pnlm-author-span,
.pnlm-title-span,
.pnlm-about-msg {
    display: none !important;
}

/* ─── Editor Sidebar ─── */

#editor-sidebar {
    position: absolute;
    top: 64px;
    left: 16px;
    width: 300px;
    max-height: calc(100% - 140px);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 500;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

#close-editor-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: var(--ease);
}

#close-editor-btn:hover { color: var(--text); }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.editor-section {
    margin-bottom: 24px;
}

.editor-section:last-child { margin-bottom: 0; }

.editor-section h4 {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 500;
}

.edit-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-style: normal;
    line-height: 1.5;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ─── List Items (Hotspots & Rooms) ─── */

.hotspot-item {
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.hotspot-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.delete-hs-btn, .delete-room-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--ease);
}

.delete-hs-btn:hover, .delete-room-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* ─── Buttons ─── */

.primary-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--ease);
}

.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
    width: 100%;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: var(--ease);
    margin-bottom: 12px;
}

.secondary-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* ─── Modals ─── */

#hotspot-modal, #new-room-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    padding: 24px;
    pointer-events: auto;
    z-index: 1000;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

#hotspot-modal h3, #new-room-modal h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-weight: 400;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    outline: none;
    transition: var(--ease);
}

.form-group select:focus,
.form-group input:focus {
    border-color: var(--accent);
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

#cancel-hotspot-btn, #cancel-new-room-btn {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: var(--ease);
}

#cancel-hotspot-btn:hover, #cancel-new-room-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

#confirm-hotspot-btn, #confirm-new-room-btn {
    flex: 2;
}

/* ─── Mobile ─── */

@media (max-width: 768px) {
    #ui-overlay { padding: 10px; }

    header {
        width: 100%;
        padding: 8px 14px;
        border-radius: var(--radius-md);
    }

    .logo h1 { font-size: 0.85rem; }
    .scene-info { font-size: 0.75rem; }

    #room-selector {
        width: 100%;
        border-radius: var(--radius-md);
    }

    #editor-sidebar {
        top: 56px;
        left: 10px;
        width: calc(100% - 20px);
        max-height: 50%;
    }

    #controls {
        bottom: 72px;
        right: 10px;
    }
}

/* ─── Hotspot Styling ─── */

.pnlm-hotspot-base {
    background-image: none !important;
}

.pnlm-hotspot.pnlm-scene {
    width: 28px;
    height: 28px;
    background: var(--accent) !important;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.4);
    animation: pulse 2.5s ease-in-out infinite;
    background-image: none !important;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 12px rgba(59, 130, 246, 0.4); }
    50% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.pnlm-tooltip {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text) !important;
    font-family: var(--font) !important;
    font-size: 0.75rem !important;
    padding: 6px 10px !important;
    box-shadow: var(--shadow) !important;
}

.pnlm-tooltip span {
    border-color: transparent !important;
}
