/* ============================================
   COSMIC FANTASY IMAGE VIEW MOBILE
   Профессиональная мобильная версия страницы просмотра изображения
   ============================================ */

/* ========== ОСНОВНОЙ КОНТЕЙНЕР ========== */
@media (max-width: 768px) {
    .image-view-container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 12px !important;
        min-height: 100vh;
        background: linear-gradient(135deg, var(--space-dark, #0A0A0F) 0%, var(--space-darker, #050508) 100%);
    }

    /* ========== ЗАГОЛОВОК ========== */
    .image-view-header {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
        padding-bottom: 12px !important;
        border-bottom: 1px solid rgba(139, 92, 246, 0.2) !important;
        position: relative;
    }

    /* Кнопка "Назад" - компактная */
    .back-btn {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        color: var(--text-cosmic, #E0E7FF) !important;
        text-decoration: none !important;
        padding: 10px 14px !important;
        border-radius: 10px !important;
        background: rgba(139, 92, 246, 0.15) !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        transition: all 0.3s ease !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        width: fit-content;
        align-self: flex-start;
        backdrop-filter: blur(10px);
    }

    .back-btn i {
        font-size: 14px;
    }

    .back-btn:active {
        transform: scale(0.95);
        background: rgba(139, 92, 246, 0.25) !important;
    }

    /* Заголовок H1 - компактный */
    .image-view-header h1 {
        font-family: 'Orbitron', sans-serif !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        margin: 0 !important;
        color: var(--text-cosmic, #E0E7FF) !important;
        text-align: center;
        flex: 1;
        line-height: 1.2;
    }

    /* Контейнер для действий - горизонтальный */
    .image-actions {
        display: flex !important;
        gap: 8px !important;
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
    }

    /* Кнопки действий - компактные */
    .action-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(139, 92, 246, 0.15) !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        border-radius: 10px !important;
        color: var(--text-cosmic, #E0E7FF) !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .action-btn i {
        font-size: 16px;
    }

    .action-btn:active {
        transform: scale(0.9);
        background: rgba(139, 92, 246, 0.3) !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    /* ========== КОНТЕНТ ========== */
    .image-view-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        grid-template-columns: none !important;
    }

    /* ========== ОТОБРАЖЕНИЕ ИЗОБРАЖЕНИЯ ========== */
    .image-display {
        background: rgba(15, 15, 25, 0.9) !important;
        border-radius: 16px !important;
        padding: 12px !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        order: 1;
    }

    .image-display img {
        width: 100% !important;
        height: auto !important;
        border-radius: 12px !important;
        display: block !important;
        max-height: 70vh;
        object-fit: contain;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    /* SEO описание - компактное */
    .seo-description {
        margin-top: 12px !important;
        padding: 12px !important;
        background: rgba(139, 92, 246, 0.1) !important;
        border: 1px solid rgba(139, 92, 246, 0.2) !important;
        border-radius: 10px !important;
    }

    .seo-description p {
        margin: 0 !important;
        font-size: 12px !important;
        line-height: 1.5 !important;
        color: var(--text-cosmic, #E0E7FF) !important;
        text-align: center !important;
        opacity: 0.9;
    }

    /* ========== ДЕТАЛИ ИЗОБРАЖЕНИЯ ========== */
    .image-details {
        background: rgba(15, 15, 25, 0.9) !important;
        border-radius: 16px !important;
        padding: 16px !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        order: 2;
    }

    .image-details h2 {
        font-family: 'Orbitron', sans-serif !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        margin: 0 0 16px 0 !important;
        color: var(--cosmic-purple, #A855F7) !important;
        padding-bottom: 12px;
        border-bottom: 1px solid rgba(139, 92, 246, 0.2);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Элементы деталей */
    .detail-item {
        margin-bottom: 14px !important;
    }

    .detail-item:last-child {
        margin-bottom: 0 !important;
    }

    /* Лейблы - компактные */
    .detail-item label {
        display: block !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        color: var(--text-muted, #9CA3AF) !important;
        margin-bottom: 6px !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px;
        opacity: 0.8;
    }

    /* Текст деталей - компактный с прокруткой для длинных промптов */
    .detail-item p {
        font-size: 13px !important;
        color: var(--text-cosmic, #E0E7FF) !important;
        margin: 0 !important;
        word-break: break-word !important;
        line-height: 1.6 !important;
        padding: 10px 12px !important;
        background: rgba(139, 92, 246, 0.08) !important;
        border: 1px solid rgba(139, 92, 246, 0.15) !important;
        border-radius: 8px !important;
        max-height: 150px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
    }

    .detail-item p::-webkit-scrollbar {
        width: 4px;
    }

    .detail-item p::-webkit-scrollbar-thumb {
        background: rgba(139, 92, 246, 0.3);
        border-radius: 2px;
    }

    /* Специальная обработка для промпта */
    .detail-item:first-of-type p {
        max-height: 200px;
        font-size: 12px !important;
        line-height: 1.5 !important;
    }

    /* ========== FULLSCREEN МОДАЛЬНОЕ ОКНО ========== */
    .fullscreen-modal {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.98) !important;
        z-index: 10000 !important;
        cursor: pointer !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
        backdrop-filter: blur(20px);
    }

    .fullscreen-modal.active {
        display: flex !important;
    }

    .fullscreen-modal img {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    .close-fullscreen {
        position: absolute !important;
        top: 16px !important;
        right: 16px !important;
        width: 44px !important;
        height: 44px !important;
        background: rgba(139, 92, 246, 0.3) !important;
        border: 1px solid rgba(139, 92, 246, 0.5) !important;
        border-radius: 50% !important;
        color: white !important;
        font-size: 20px !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.3s ease !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10001;
    }

    .close-fullscreen:active {
        transform: scale(0.9);
        background: rgba(139, 92, 246, 0.5) !important;
    }

    .close-fullscreen i {
        font-size: 18px;
    }
}

/* ========== МАЛЕНЬКИЕ ЭКРАНЫ (до 480px) ========== */
@media (max-width: 480px) {
    .image-view-container {
        padding: 10px !important;
    }

    .image-view-header {
        gap: 10px !important;
        margin-bottom: 12px !important;
        padding-bottom: 10px !important;
    }

    .back-btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    .back-btn i {
        font-size: 13px;
    }

    .image-view-header h1 {
        font-size: 16px !important;
    }

    .image-actions {
        gap: 6px !important;
    }

    .action-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .action-btn i {
        font-size: 14px;
    }

    .image-view-content {
        gap: 12px !important;
    }

    .image-display {
        padding: 10px !important;
        border-radius: 12px !important;
    }

    .image-display img {
        border-radius: 10px !important;
        max-height: 65vh;
    }

    .seo-description {
        margin-top: 10px !important;
        padding: 10px !important;
    }

    .seo-description p {
        font-size: 11px !important;
    }

    .image-details {
        padding: 14px !important;
        border-radius: 12px !important;
    }

    .image-details h2 {
        font-size: 14px !important;
        margin-bottom: 12px !important;
        padding-bottom: 10px;
    }

    .detail-item {
        margin-bottom: 12px !important;
    }

    .detail-item label {
        font-size: 9px !important;
        margin-bottom: 5px !important;
    }

    .detail-item p {
        font-size: 12px !important;
        padding: 8px 10px !important;
        max-height: 120px;
    }

    .detail-item:first-of-type p {
        max-height: 150px;
        font-size: 11px !important;
    }

    .close-fullscreen {
        top: 12px !important;
        right: 12px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
    }

    .close-fullscreen i {
        font-size: 16px;
    }
}

/* ========== ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (до 360px) ========== */
@media (max-width: 360px) {
    .image-view-container {
        padding: 8px !important;
    }

    .image-view-header h1 {
        font-size: 14px !important;
    }

    .action-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }

    .action-btn i {
        font-size: 13px;
    }

    .image-display {
        padding: 8px !important;
    }

    .image-display img {
        max-height: 60vh;
    }

    .image-details {
        padding: 12px !important;
    }

    .image-details h2 {
        font-size: 13px !important;
    }

    .detail-item p {
        font-size: 11px !important;
        padding: 6px 8px !important;
        max-height: 100px;
    }

    .detail-item:first-of-type p {
        max-height: 120px;
        font-size: 10px !important;
    }
}

/* ========== ЛАНДШАФТНАЯ ОРИЕНТАЦИЯ ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .image-view-content {
        flex-direction: row !important;
        gap: 12px !important;
    }

    .image-display {
        flex: 1;
        order: 1;
    }

    .image-display img {
        max-height: 80vh;
    }

    .image-details {
        flex: 0 0 300px;
        order: 2;
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .seo-description {
        display: none; /* Скрываем SEO описание в ландшафтной ориентации */
    }
}

/* ========== ОБЩИЕ УЛУЧШЕНИЯ ========== */
@media (max-width: 768px) {
    /* Плавные анимации */
    .image-view-container,
    .image-view-header,
    .back-btn,
    .action-btn,
    .image-display,
    .image-details,
    .detail-item,
    .close-fullscreen {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Улучшенная читаемость */
    .image-view-header h1,
    .image-details h2,
    .detail-item label,
    .detail-item p,
    .seo-description p {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Предотвращение скролла body при открытом fullscreen */
    body.fullscreen-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
    }

    /* Улучшенная прокрутка */
    .detail-item p,
    .image-details {
        scrollbar-width: thin;
        scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
    }

    .detail-item p::-webkit-scrollbar,
    .image-details::-webkit-scrollbar {
        width: 4px;
    }

    .detail-item p::-webkit-scrollbar-thumb,
    .image-details::-webkit-scrollbar-thumb {
        background: rgba(139, 92, 246, 0.3);
        border-radius: 2px;
    }

    /* Touch-friendly элементы */
    .back-btn,
    .action-btn,
    .close-fullscreen {
        -webkit-tap-highlight-color: rgba(139, 92, 246, 0.3);
        touch-action: manipulation;
    }

    /* Оптимизация производительности */
    .image-display img {
        will-change: transform;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
