/* ============================================
   Photo Sphere Tour - Main Styles
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#viewer {
    width: 100%;
    height: 100%;
    position: relative; /* Важно для позиционирования дочерних absolute элементов */
    overflow: hidden;
}

/* Стили для info-panel когда она внутри viewer */
#viewer .info-panel {
    position: absolute !important;
    z-index: 2147483647 !important;
}

/* ============================================
   Info Panel Styles
   ============================================ */
.info-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    width: 90%;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 2147483647; /* Максимальный z-index для полноэкранного режима */
    transition: opacity 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-transform: translate(-50%, -50%); /* Для Safari */
}

.info-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.9);
}

.info-panel .close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-panel .close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Стили для скроллбара всей панели */
.info-panel::-webkit-scrollbar {
    width: 8px;
}

.info-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.info-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.info-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* ============================================
   Marker Content Styles
   ============================================ */
.info-marker {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.info-marker:hover {
    transform: rotate(-45deg) scale(1.1);
}

.info-marker::after {
    content: 'i';
    transform: rotate(45deg);
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.marker-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.marker-content h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.4em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.marker-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 12px;
}

.marker-content .marker-image {
    width: 100%;
    border-radius: 8px;
    margin: 12px 0;
}

.marker-content .marker-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.marker-content .marker-tag {
    background: #ecf0f1;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    color: #7f8c8d;
}

/* ============================================
   Link Arrow Styles (Virtual Tour)
   ============================================ */
.virtual-tour-link {
    background: rgba(52, 152, 219, 0.9);
    border: 2px solid white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.virtual-tour-link:hover {
    background: rgba(41, 128, 185, 1);
    transform: scale(1.1);
}

.virtual-tour-link::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 12px solid white;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-left: 4px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .info-panel {
        max-width: 95%;
        padding: 16px;
    }
    
    .marker-content h3 {
        font-size: 1.2em;
    }
    
    /* 📱 Уменьшаем маркеры на планшетах и телефонах */
    .transition-marker {
        width: 40px;
        height: 40px;
    }
    
    .transition-marker svg {
        width: 22px;
        height: 22px;
    }
    
    .info-marker {
        width: 36px;
        height: 36px;
    }
    
    .info-marker svg {
        width: 20px;
        height: 20px;
    }
    
    .virtual-tour-link {
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   Console helper hint
   ============================================ */
.psv-panel {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

/* Custom navbar button for instructions */
.psv-navbar-button {
    transition: opacity 0.2s;
}

.psv-navbar-button:hover {
    opacity: 0.8;
}

/* 🚪 Маркер-переход */
.transition-marker {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
    border: 3px solid #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.transition-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.transition-marker svg {
    width: 24px;
    height: 24px;
}

/* ➡️ Простая белая стрелка в белом круге */
.simple-arrow {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.simple-arrow:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.simple-arrow svg {
    width: 24px;
    height: 24px;
}

/* ⬅️ Стрелка возврата (повернутая влево) */
.return-arrow {
    transform: rotate(0deg);
}

.return-arrow:hover {
    transform: scale(1.1);
}

/* 📋 Информационный маркер */
.info-marker {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
    border: 2px solid #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.info-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.6);
}

.info-marker svg {
    width: 20px;
    height: 20px;
}


/* 📋 Стили для информационной панели со схемами */
.schema-info {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.schema-info h2 {
    color: #2c3e50;
    margin-bottom: 16px;
    font-size: clamp(18px, 5vw, 24px);
    text-align: center;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.schema-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 50vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 0 auto 20px auto;
    display: block;
}

.schema-description {
    line-height: 1.5;
    color: #34495e;
    font-size: clamp(14px, 3vw, 16px);
}

.schema-description h3 {
    color: #2980b9;
    margin: 16px 0 8px 0;
    font-size: clamp(16px, 4vw, 18px);
}

.schema-description p {
    margin: 8px 0;
}

.schema-description ul {
    margin: 8px 0;
    padding-left: clamp(16px, 4vw, 20px);
}

.schema-description li {
    margin: 4px 0;
    line-height: 1.4;
}

.schema-description strong {
    color: #2c3e50;
    font-weight: 600;
}

.schema-description em {
    color: #e74c3c;
    font-style: italic;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .info-panel {
        width: 95vw;
        max-height: 85vh;
        padding: 16px;
        border-radius: 8px;
    }
    
    .schema-info h2 {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .schema-image {
        max-height: 40vh;
        margin-bottom: 16px;
    }
    
    .schema-description {
        font-size: 14px;
    }
    
    .schema-description h3 {
        font-size: 16px;
        margin: 12px 0 6px 0;
    }
    
    .schema-description ul {
        padding-left: 16px;
    }
}

@media (max-width: 480px) {
    .info-panel {
        width: 98vw;
        max-height: 90vh;
        padding: 12px;
    }
    
    .schema-info h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    /* 📱 Уменьшаем маркеры на мобильных */
    .transition-marker {
        width: 36px;
        height: 36px;
    }
    
    .transition-marker svg {
        width: 20px;
        height: 20px;
    }
    
    .info-marker {
        width: 32px;
        height: 32px;
    }
    
    .info-marker svg {
        width: 18px;
        height: 18px;
    }
    
    .simple-arrow {
        width: 36px;
        height: 36px;
    }
    
    .simple-arrow svg {
        width: 20px;
        height: 20px;
    }
    
    .schema-image {
        max-height: 35vh;
        margin-bottom: 12px;
    }
    
    .schema-description {
        font-size: 13px;
        line-height: 1.4;
    }
    
    .schema-description h3 {
        font-size: 15px;
        margin: 10px 0 5px 0;
    }
    
    .schema-description ul {
        padding-left: 14px;
    }
    
    .schema-description li {
        margin: 3px 0;
    }
}

/* 🎨 Курсор в режиме рисования */
body.drawing-polygon {
    cursor: crosshair !important;
}

/* ✨ Анимация появления вершин */
.psv-marker[polygon] {
    animation: polygon-appear 0.3s ease-out;
}

@keyframes polygon-appear {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* 💡 Подсветка полигона при наведении */
.psv-marker[polygon]:hover {
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.6)) !important;
}

/* ============================================
   Tour Container (для полноэкранного режима)
   ============================================ */
.tour-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Стили при полноэкранном режиме */
.tour-container:fullscreen,
.tour-container:-webkit-full-screen,
.tour-container:-moz-full-screen {
    width: 100vw;
    height: 100vh;
}

/* ============================================
   Полноэкранный режим - фикс для мобильных
   ============================================ */

/* Стили для info-panel в полноэкранном режиме */
:fullscreen .info-panel,
:-webkit-full-screen .info-panel,
:-moz-full-screen .info-panel,
:-ms-fullscreen .info-panel {
    z-index: 2147483647 !important;
    position: fixed !important;
}

/* Для iOS Safari */
@supports (-webkit-touch-callout: none) {
    .info-panel {
        /* Фикс для iOS полноэкранного режима */
        position: fixed;
        z-index: 2147483647;
    }
}

/* ============================================
   Галерея схем
   ============================================ */
.schemes-gallery {
    text-align: center;
}

.gallery-description {
    color: #666;
    margin-bottom: 20px;
    font-style: italic;
}

.gallery-container {
    position: relative;
    margin-bottom: 20px;
}

.gallery-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.gallery-btn {
    background: #2196F3;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-btn:hover {
    background: #1976D2;
}

.slide-counter {
    color: #666;
    font-weight: bold;
    font-size: 14px;
}

.gallery-slide {
    position: relative;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gallery-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    object-fit: contain;
}

.image-caption {
    margin-top: 10px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.gallery-thumbnails {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    opacity: 0.7;
}

.thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.thumbnail.active {
    border-color: #2196F3;
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail .error {
    width: 100%;
    height: 100%;
    background: #f44336;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

/* ============================================
   Индикаторы прогресса
   ============================================ */
.marker-visited {
    position: relative;
}

.marker-visited::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #4CAF50;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    animation: visitedPulse 2s ease-in-out;
    z-index: 1000;
}

@keyframes visitedPulse {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.progress-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.progress-indicator.hidden {
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.image-error {
    color: #e74c3c;
    padding: 20px;
    border: 2px dashed #e74c3c;
    border-radius: 8px;
    text-align: center;
    background: #fee;
}

/* Мобильная адаптация галереи */
@media (max-width: 768px) {
    .gallery-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .gallery-image {
        max-height: 300px;
    }
    
    .thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .gallery-thumbnails {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .gallery-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .gallery-image {
        max-height: 250px;
    }
    
    .thumbnail {
        width: 45px;
        height: 45px;
    }
    
    .gallery-thumbnails {
        gap: 4px;
    }
    
    .slide-counter {
        font-size: 12px;
    }
}