/* ============================================
   COSMIC FANTASY IMAGE MODAL MOBILE
   Компактное и удобное модальное окно для мобильных
   ============================================ */

/* ========== МОДАЛЬНОЕ ОКНО ========== */
@media (max-width: 768px) {
    /* Модальное окно */
    .image-modal {
        padding: 0 !important;
        align-items: flex-end !important;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
    }
    
    /* Контент модального окна */
    .image-modal-content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 95vh !important;
        border-radius: 20px 20px 0 0 !important;
        margin: 0;
        display: flex;
        flex-direction: column;
        animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Кнопка закрытия - компактная */
    .image-modal-close {
        top: 12px !important;
        right: 12px !important;
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px;
        background: rgba(15, 15, 25, 0.9) !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        z-index: 10;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .image-modal-close i {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.95) !important;
    }
    
    .image-modal-close:active {
        transform: scale(0.9);
        background: rgba(139, 92, 246, 0.3) !important;
    }
    
    /* Тело модального окна - вертикальная компоновка */
    .image-modal-body {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        max-height: calc(95vh - 60px);
        overflow: hidden;
    }
    
    /* Изображение - компактное */
    .image-modal-image {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: 50vh !important;
        border-radius: 0 !important;
        padding: 12px;
        background: rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .image-modal-image img {
        max-width: 100% !important;
        max-height: 50vh !important;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 8px;
    }
    
    /* Детали - компактные с прокруткой */
    .image-modal-details {
        padding: 16px !important;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: calc(95vh - 50vh - 60px);
        flex: 1;
        display: flex;
        flex-direction: column;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
    }
    
    .image-modal-details::-webkit-scrollbar {
        width: 4px;
    }
    
    .image-modal-details::-webkit-scrollbar-thumb {
        background: rgba(139, 92, 246, 0.3);
        border-radius: 2px;
    }
    
    /* Заголовок деталей */
    .image-modal-details h3 {
        font-size: 16px !important;
        font-weight: 700;
        margin: 0 0 16px 0 !important;
        color: rgba(255, 255, 255, 0.95);
        padding-bottom: 12px;
        border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    }
    
    /* Элементы деталей - компактные */
    .modal-detail-item {
        margin-bottom: 14px !important;
    }
    
    .modal-detail-item:last-of-type {
        margin-bottom: 0;
    }
    
    /* Лейблы - компактные */
    .modal-detail-item label {
        font-size: 10px !important;
        font-weight: 700;
        color: rgba(255, 255, 255, 0.7);
        margin-bottom: 6px !important;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: block;
    }
    
    /* Текст деталей - компактный */
    .modal-detail-item p {
        font-size: 12px !important;
        color: rgba(255, 255, 255, 0.9);
        margin: 0;
        line-height: 1.5;
        word-break: break-word;
        padding: 8px 12px;
        background: rgba(139, 92, 246, 0.05);
        border: 1px solid rgba(139, 92, 246, 0.1);
        border-radius: 6px;
    }

    .modal-username {
        display: flex !important;
        align-items: center;
        gap: 10px;
        font-size: 14px !important;
        color: rgba(255, 255, 255, 0.95) !important;
        margin: 0;
        font-weight: 500;
        padding: 8px 12px;
        background: rgba(139, 92, 246, 0.15) !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        border-radius: 6px;
    }

    .modal-username i {
        color: var(--primary) !important;
        font-size: 16px !important;
        opacity: 1 !important;
        filter: brightness(1.3);
        min-width: 16px;
        text-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
    }

    .modal-username span {
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.95) !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
    
    /* Промпт - специальная обработка */
    .modal-detail-item:first-of-type p {
        max-height: 120px;
        overflow-y: auto;
        font-size: 11px !important;
        line-height: 1.4;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Действия - компактные кнопки */
    .image-modal-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        margin-top: 16px !important;
        padding-top: 16px !important;
        border-top: 1px solid rgba(139, 92, 246, 0.2);
        flex-shrink: 0;
    }
    
    /* Кнопки действий */
    .modal-action-btn {
        flex: 1 !important;
        padding: 12px 16px !important;
        font-size: 12px !important;
        font-weight: 600;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        background: rgba(139, 92, 246, 0.15) !important;
        border: 1px solid rgba(139, 92, 246, 0.3) !important;
        color: rgba(255, 255, 255, 0.95) !important;
        text-decoration: none;
        transition: all 0.3s ease;
        min-height: 44px; /* Минимальная высота для удобного нажатия */
    }
    
    .modal-action-btn i {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.95) !important;
    }
    
    .modal-action-btn span {
        font-size: 12px;
    }
    
    .modal-action-btn:active {
        transform: scale(0.98);
        background: rgba(139, 92, 246, 0.25) !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    /* Убираем hover эффекты на мобильных */
    .modal-action-btn:hover {
        transform: none;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .image-modal-content {
        max-height: 98vh !important;
        border-radius: 16px 16px 0 0 !important;
    }
    
    .image-modal-close {
        top: 10px !important;
        right: 10px !important;
        width: 28px !important;
        height: 28px !important;
    }
    
    .image-modal-close i {
        font-size: 12px;
    }
    
    .image-modal-image {
        max-height: 45vh !important;
        padding: 10px;
    }
    
    .image-modal-image img {
        max-height: 45vh !important;
    }
    
    .image-modal-details {
        padding: 12px !important;
        max-height: calc(98vh - 45vh - 50px);
    }
    
    .image-modal-details h3 {
        font-size: 14px !important;
        margin-bottom: 12px !important;
        padding-bottom: 10px;
    }
    
    .modal-detail-item {
        margin-bottom: 12px !important;
    }
    
    .modal-detail-item label {
        font-size: 9px !important;
        margin-bottom: 5px !important;
    }
    
    .modal-detail-item p {
        font-size: 11px !important;
        padding: 6px 10px;
    }
    
    .modal-detail-item:first-of-type p {
        max-height: 100px;
        font-size: 10px !important;
    }
    
    .image-modal-actions {
        gap: 6px !important;
        margin-top: 12px !important;
        padding-top: 12px !important;
    }
    
    .modal-action-btn {
        padding: 10px 12px !important;
        font-size: 11px !important;
        min-height: 40px;
        gap: 5px;
    }
    
    .modal-action-btn i {
        font-size: 12px;
    }
    
    .modal-action-btn span {
        font-size: 11px;
    }
}

/* Очень-очень маленькие экраны */
@media (max-width: 360px) {
    .image-modal-image {
        max-height: 40vh !important;
        padding: 8px;
    }
    
    .image-modal-image img {
        max-height: 40vh !important;
    }
    
    .image-modal-details {
        padding: 10px !important;
        max-height: calc(98vh - 40vh - 45px);
    }
    
    .image-modal-details h3 {
        font-size: 13px !important;
    }
    
    .modal-detail-item p {
        font-size: 10px !important;
        padding: 5px 8px;
    }
    
    .modal-action-btn {
        padding: 8px 10px !important;
        font-size: 10px !important;
        min-height: 36px;
    }
    
    .modal-action-btn span {
        display: none; /* Скрываем текст, оставляем только иконки */
    }
    
    .modal-action-btn i {
        font-size: 14px;
        margin: 0;
    }
}

/* ========== ОБЩИЕ УЛУЧШЕНИЯ ========== */
@media (max-width: 768px) {
    /* Плавные анимации */
    .image-modal-content,
    .image-modal-close,
    .modal-action-btn {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Улучшенная читаемость */
    .image-modal-details h3,
    .modal-detail-item label,
    .modal-detail-item p,
    .modal-action-btn {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Предотвращение скролла body при открытом модальном окне */
    body.modal-open {
        overflow: hidden !important;
    }
}
