/* Мои генерации - стили */

body {
    padding-top: 64px; /* Высота глобальной шапки */
    padding-bottom: 20px;
}

/* Отступ снизу когда виден нижний бар */
body.has-bottom-nav {
    padding-bottom: calc(env(safe-area-inset-bottom) + 80px);
}

/* Заголовок страницы */
.header {
    padding: 24px 16px 16px;
    text-align: center;
    background: #000000;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 8px 0;
}

.header p {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

/* Контейнер */
.generations-container {
    max-width: 590px;
    margin: 20px auto 0;
    padding: 0 16px;
}

/* Список генераций */
.generations-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Loader использует общий стиль из loader.css */

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.empty-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
}


/* Карточка генерации - без фона, максимум пространства */
.generation-card {
    overflow: visible;
    contain: layout style; /* ✅ Оптимизация: изменения внутри карточки не влияют на остальной список */
}

/* Контейнер: изображение + кнопки на нижней границе */
.card-content {
    position: relative;
    width: 100%;
}

/* Превью изображения - полная ширина, кнопки поверх */
.generation-preview {
    position: relative;
    width: 100%;
    border-radius: 24px; /* Сильнее закругление */
    overflow: hidden; /* Обрезаем изображение */
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    min-height: 200px; /* Минимальная высота для предотвращения layout shift */
}

/* ✨ Shine effect - быстрый блеск при появлении изображения */
@keyframes shine {
    0% {
        transform: translateX(-100%) skewX(-15deg);
    }
    100% {
        transform: translateX(200%) skewX(-15deg);
    }
}

.generation-preview.shine-effect::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shine 0.6s ease-out;
    pointer-events: none;
    z-index: 10;
}

.generation-preview img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    border-radius: 24px; /* Сильнее закругление */
}

/* Loading состояние изображения */
.generation-preview.loading-img {
    background: rgba(255, 255, 255, 0.05);
}

.generation-preview.loading-img img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

/* Loaded состояние */
.generation-preview:not(.loading-img) img {
    opacity: 1;
}

/* Error состояние */
.generation-preview.error-img {
    background: rgba(255, 0, 0, 0.1);
}

.generation-preview.error-img::after {
    content: '⚠️ Ошибка загрузки';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* Badge со стилем */
.style-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

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

/* Badge с названием модели - внутри карточки на изображении */
.model-badge {
    position: absolute;
    bottom: 12px;  /* Внутри карточки на изображении */
    left: 12px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.85);  /* Светлый фон */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.8);  /* Темный текст на светлом фоне */
    text-transform: uppercase;
    z-index: 5;
}

/* ❌ УДАЛЕНО: .generation-time - время не показываем */

/* Кнопки действий - горизонтально на нижней границе изображения (пересекая её) */
.generation-actions {
    position: absolute;
    bottom: -8px;  /* Пересекают нижнюю границу */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 10;
}

/* Квадратные glassmorphism кнопки (СТРОГО одинаковая ширина) */
.action-btn {
    flex: 1 1 0;  /* Базовая ширина 0 - делятся поровну */
    min-width: 72px;
    height: 56px;

    /* Темнее glassmorphism для читаемости текста */
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);

    /* Сильное закругление */
    border-radius: 18px;

    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    gap: 3px;
}

.action-btn img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    filter: brightness(0) saturate(100%) invert(100%);
    opacity: 0.9;
}

.action-btn-label {
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    line-height: 1.1;
    white-space: nowrap;
}

/* Hover эффект */
.action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.02);
}

/* Active эффект */
.action-btn:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.15);
}

.action-btn:active img {
    opacity: 1;
}

/* Кнопка опубликовать - с циклической shimmer анимацией бордера */
@keyframes shimmer-border {
    0% {
        border-color: rgba(0, 122, 255, 0.3);
        box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
    }
    50% {
        border-color: rgba(0, 122, 255, 0.6);
        box-shadow: 0 0 16px rgba(0, 122, 255, 0.5);
    }
    100% {
        border-color: rgba(0, 122, 255, 0.3);
        box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
    }
}

.action-btn-publish {
    background: rgba(0, 122, 255, 0.2);
    border-color: rgba(0, 122, 255, 0.3);
    animation: shimmer-border 2s ease-in-out infinite;
}

.action-btn-publish:hover {
    background: rgba(0, 122, 255, 0.3);
    border-color: rgba(0, 122, 255, 0.5);
    animation: none;  /* Останавливаем анимацию при hover */
}

/* Красная кнопка "Не публиковать" */
.action-btn-unpublish {
    background: rgba(255, 59, 48, 0.25);  /* Ярче */
    border-color: rgba(255, 59, 48, 0.4);  /* Ярче */
}

.action-btn-unpublish:hover {
    background: rgba(255, 59, 48, 0.35);  /* Ярче */
    border-color: rgba(255, 59, 48, 0.6);  /* Ярче */
}

/* Bottom sheet для подтверждения снятия с публикации */
.unpublish-sheet-content {
    padding: 24px;
    text-align: center;
}

.unpublish-sheet-title {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.unpublish-sheet-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
}

.unpublish-sheet-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unpublish-btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unpublish-btn-confirm {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.unpublish-btn-confirm:active {
    background: rgba(255, 59, 48, 0.25);
    transform: scale(0.98);
}

.unpublish-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.unpublish-btn-cancel:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.98);
}

/* ❌ LEGACY MODAL REMOVED - используется image-viewer.css (Portal Zone) */

/* Pending generation placeholder */
.generation-preview.pending {
    background: rgba(0, 0, 0, 0.9);
    position: relative;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    min-height: 200px;
}

/* Pixel animation canvas */
.generation-preview.pending canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.generation-preview.pending .loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1;
    display: none; /* Hide default spinner, pixel animation will be shown instead */
}

.generation-preview.pending .loading-text {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ⚡ SKELETON PREVIEW: Для генераций без preview_url */
.skeleton-preview {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    aspect-ratio: 3 / 4;
    min-height: 200px;
    border-radius: 12px;
}

/* ⚡ SHINE EFFECT: Для новых completed генераций */
.new-generation-shine {
    position: relative;
    overflow: hidden;
}

.new-generation-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.6) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shineSlide 2s ease-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes shineSlide {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Failed generation */
.generation-preview.failed {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    aspect-ratio: 3 / 4;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.generation-preview.failed .error-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    z-index: 1;
}

.generation-preview.failed .error-text {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 59, 48, 0.9);
    font-size: 13px;
    font-weight: 500;
    z-index: 1;
}

/* Fullscreen Loader */
#fullscreen-loader {
    display: none;
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    z-index: 9999;
    overflow: hidden;
}

#fullscreen-loader.active {
    display: block;
}

.animation-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.photo-stack {
    position: relative;
    width: 200px;
    height: 200px;
}

.flying-photo {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 24px;
    object-fit: cover;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
}

@keyframes flyIn {
    0% {
        opacity: 0;
        transform: translate(var(--start-x), var(--start-y)) rotate(var(--start-rotate)) scale(0.5);
    }
    40% {
        opacity: 1;
        transform: translate(0, 0) rotate(var(--mid-rotate)) scale(1);
    }
    70% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(0, -100px) scale(2) translateZ(400px);
        filter: blur(10px);
    }
}

.flying-photo.animate {
    animation: flyIn 2.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.success-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    animation: fadeInMessage 0.5s ease 2.2s forwards;
}

@keyframes fadeInMessage {
    to {
        opacity: 1;
    }
}

.success-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: bounce 0.6s ease 2.2s;
}

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

.success-text {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.success-subtext {
    font-size: 16px;
    color: #999;
}

/* ============================================
   STALE GENERATION WARNING (Зависшие генерации)
   ============================================ */

/* Затемнение фона для зависших генераций */
.generation-preview.pending.stale {
    position: relative;
    opacity: 0.7;
}

.generation-preview.pending.stale::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 152, 0, 0.1);
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Предупреждение о зависшей генерации */
.stale-warning {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(255, 152, 0, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 152, 0, 0.4);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    animation: pulseWarning 2s ease-in-out infinite;
}

@keyframes pulseWarning {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(0.98);
    }
}

.stale-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.stale-text {
    font-size: 12px;
    font-weight: 600;
    color: #ff9800;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Кнопка обновления статуса */
.stale-refresh-btn {
    background: rgba(255, 152, 0, 0.3);
    border: 1px solid rgba(255, 152, 0, 0.5);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 14px;
    color: #ff9800;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.stale-refresh-btn:hover {
    background: rgba(255, 152, 0, 0.5);
    transform: scale(1.1) rotate(180deg);
}

.stale-refresh-btn:active {
    transform: scale(0.95) rotate(180deg);
}

/* GPU Acceleration */
.stale-warning,
.stale-refresh-btn {
    will-change: transform, opacity;
    backface-visibility: hidden;
}
