/* ============================================
   My Generations View Styles v3.0
   Global layout from layout.css
   ============================================ */

/* ============================================
   Profile Header (Instagram-style)
   ============================================ */

.profile-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================
   Profile Tabs (Фильтрация генераций)
   ============================================ */

.profile-tabs {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    justify-content: center;
    margin-bottom: var(--spacing-md);
}

.tab-btn {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    color: #FFFFFF;
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.tab-count {
    opacity: 0.75;
    font-size: 11px;
    margin-left: 4px;
}

.profile-info-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-avatar-container {
    flex-shrink: 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.profile-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.profile-username {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.profile-stats {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.profile-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-stat-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.profile-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
}

.profile-stat-label {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1;
}

/* Список генераций - прямо в view, без контейнера */
.generations-list {
    display: flex;
    flex-direction: column;
    gap: 32px;  /* Увеличен отступ между карточками (было 20px) */
    margin-top: 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: 28px; /* Еще более закругленные углы */
    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;
}

/* Контейнер для бейджей ВВЕРХУ СПРАВА */
.generation-badges {
    position: absolute;
    top: 10px;  /* Вверху */
    right: 10px;  /* Справа */
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 20;
    pointer-events: none;
}

/* Badge модели - белый glassmorphism */
.model-badge {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

/* Мини-иконка профиля (если был использован) */
.profile-badge-mini {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid rgba(88, 101, 242, 0.4);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

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

/* Кнопки действий - ниже карточки с большим отступом */
.generation-actions {
    position: absolute;
    bottom: -20px;  /* Опущены ниже для лучшей видимости */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 10px;
    z-index: 10;
}

/* Квадратные glassmorphism кнопки (яркие, заметные) */
.action-btn {
    flex: 1 1 0;
    min-width: 76px;
    height: 58px;

    /* Ярче glassmorphism для лучшей видимости */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);

    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;
}

/* Кнопка опубликовать - МАКСИМАЛЬНЫЙ акцент */
@keyframes shimmer-border {
    0% {
        border-color: rgba(0, 122, 255, 0.5);
        box-shadow: 0 0 12px rgba(0, 122, 255, 0.4);
    }
    50% {
        border-color: rgba(0, 122, 255, 0.8);
        box-shadow: 0 0 24px rgba(0, 122, 255, 0.6);
    }
    100% {
        border-color: rgba(0, 122, 255, 0.5);
        box-shadow: 0 0 12px rgba(0, 122, 255, 0.4);
    }
}

.action-btn-publish {
    background: rgba(0, 122, 255, 0.35);  /* Ярче фон */
    border-color: rgba(0, 122, 255, 0.5);
    border-width: 2px;  /* Толще бордер */
    animation: shimmer-border 2s ease-in-out infinite;
}

.action-btn-publish:hover {
    background: rgba(0, 122, 255, 0.45);
    border-color: rgba(0, 122, 255, 0.7);
    animation: none;
}

/* Красная кнопка "Не публиковать" */
.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;
}

/* Animation in animations.css */

/* ⚡ 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;
}
