/* ==========================================
   СТИЛИ ИНТЕРФЕЙСА 3D-МОДЕЛИ КОЛЛЕДЖА
   ========================================== */

:root {
    --bg-dark: #12151a;
    --panel-bg: rgba(18, 22, 29, 0.88);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-border-hover: rgba(255, 255, 255, 0.16);
    --accent-primary: #38bdf8;
    --accent-active: #475569;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #e2e8f0;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: grab;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

#canvas-container canvas {
    touch-action: none;
    display: block;
    width: 100%;
    height: 100%;
}

#canvas-container:active {
    cursor: grabbing;
}

/* Glassmorphism панели */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
    border-color: var(--panel-border-hover);
}

/* Стилизация скроллбара панели */
.custom-scroll::-webkit-scrollbar {
    width: 4px;
}
.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 4px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Кнопки */
.btn-interactive {
    position: relative;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-interactive:hover {
    transform: translateY(-1px);
}

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

.mode-btn.active, .bldg-btn.active, .preset-btn.active {
    background: linear-gradient(135deg, #3b4252 0%, #2e3440 100%) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    font-weight: 600;
}

/* Активное состояние кнопки раздвижки этажей - благородное, без кислотно-красного */
.explode-btn-active {
    background: linear-gradient(135deg, #3b4252 0%, #2e3440 100%) !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

/* Ползунки Range */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: rgba(51, 65, 85, 0.65);
    border-radius: 999px;
    outline: none;
    transition: background 0.2s ease;
}

input[type="range"]:hover {
    background: rgba(71, 85, 105, 0.85);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 2px solid #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

/* Кастомные переключатели (Toggle switches) */
.switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.switch-track {
    width: 32px;
    height: 18px;
    background-color: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    position: relative;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background-color: #94a3b8;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}

.switch-input:checked + .switch-track {
    background-color: #475569;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.switch-input:checked + .switch-track .switch-thumb {
    transform: translateX(14px);
    background-color: #f8fafc;
}

/* Разделители */
.panel-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    margin: 2px 0;
}

/* Скрытие интерфейса */
.ui-overlay {
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

body.ui-hidden .ui-overlay {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.98);
}

/* Убираем дефолтный маркер браузера у details/summary */
details summary::-webkit-details-marker {
    display: none;
}

/* ==========================================
   АДАПТИВНОСТЬ ДЛЯ СМАРТФОНОВ И ПЛАНШЕТОВ
   ========================================== */

.mobile-floor-btn, .mobile-bldg-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-floor-btn.active, .mobile-bldg-btn.active {
    background: linear-gradient(135deg, #3b4252 0%, #2e3440 100%) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    font-weight: 700;
}

/* Поддержка Safe Area для вырезов и домашней полоски iOS/Android */
@supports (padding: max(0px)) {
    #app-header {
        top: max(0.75rem, env(safe-area-inset-top));
        left: max(0.75rem, env(safe-area-inset-left));
        right: max(0.75rem, env(safe-area-inset-right));
    }
    #mobile-bottom-bar {
        bottom: max(0.6rem, env(safe-area-inset-bottom));
        left: max(0.6rem, env(safe-area-inset-left));
        right: max(0.6rem, env(safe-area-inset-right));
    }
    #control-panel {
        padding-bottom: max(1.25rem, calc(1rem + env(safe-area-inset-bottom)));
    }
}

@media (max-width: 768px) {
    .btn-interactive {
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    input[type="range"] {
        height: 7px;
    }
    input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }
    .switch-track {
        width: 38px;
        height: 22px;
    }
    .switch-thumb {
        width: 16px;
        height: 16px;
    }
    .switch-input:checked + .switch-track .switch-thumb {
        transform: translateX(16px);
    }
}

/* Альбомная ориентация на смартфонах */
@media (max-width: 768px) and (orientation: landscape) {
    #control-panel {
        top: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        right: 0 !important;
        width: 320px !important;
        max-height: 100vh !important;
        border-radius: 1.25rem 0 0 1.25rem !important;
        transform: translateX(100%);
    }
    #control-panel.translate-y-0 {
        transform: translateX(0) !important;
    }
    #mobile-fab-controls {
        bottom: 1.25rem !important;
    }
    #mobile-bottom-bar {
        display: none !important;
    }
}

