/* ==========================================================================
   VIDEO.CSS
   Стили для модуля генерации видео (Veo, Grok, Kling) и галереи видео
   ========================================================================== */

/* ==========================================================================
   1. СЕТКА ВИДЕО И КАРТОЧКИ (ГАЛЕРЕЯ)
   ========================================================================== */
#video-grid {
    display: grid;
    /* Для мобильных: уменьшаем с 110px до 90px, чтобы влезало по 3-4 штуки */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    padding-bottom: 80px;
    width: 100%;
}

@media (min-width: 768px) {
    #video-grid {
        /* Для ПК: карточки компактнее */
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 10px;
    }
}

.video-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Карточка всегда квадратная */
    background-color: var(--bg-card, #141414);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.video-card:hover {
    border-color: var(--primary, #FABF3C);
    box-shadow: 0 0 15px rgba(250, 191, 60, 0.2);
    transform: translateY(-2px);
    z-index: 2;
}

.video-card video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
}

/* Кнопка Play по центру */
.video-play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease;
    z-index: 10; pointer-events: none;
}

.video-play-icon svg {
    width: 16px;
    height: 16px;
}

.video-card:hover .video-play-icon {
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(255, 215, 0, 0.9);
    border-color: transparent;
}
.video-card:hover .video-play-icon svg { fill: #000; }

/* Бейдж "VIDEO" */
.video-card-badge {
    position: absolute; top: 6px; left: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 3px 6px; border-radius: 4px;
    font-size: 9px; font-weight: 700;
    letter-spacing: 0.5px; text-transform: uppercase;
    z-index: 10; display: flex; align-items: center; gap: 4px;
}

/* Кнопка удаления */
.video-delete-btn {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%; color: #fff;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: 0.2s; z-index: 20;
}
.video-delete-btn svg { width: 12px; height: 12px; }

.video-card:hover .video-delete-btn { opacity: 1; }
.video-delete-btn:hover { background: #dc3545; transform: scale(1.1); }

@media (max-width: 768px) {
    .video-delete-btn { opacity: 1; background: rgba(0, 0, 0, 0.7); }
}

/* ==========================================================================
   2. ИНТЕРФЕЙС VEO
   ========================================================================== */

/* Контейнер панели Veo */
.veo-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 20px;
}

/* Контейнер для слотов */
.veo-slots-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Слоты загрузки (квадратики) */
.veo-upload-slot {
    flex: 1;
    aspect-ratio: 1 / 1; 
    background: linear-gradient(145deg, #1e2126, #15171a);
    border: 1px dashed var(--border-color, #444);
    border-radius: 16px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.veo-upload-slot:hover {
    border-color: var(--primary, #FABF3C);
    background: #25282d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Контент внутри пустого слота */
.slot-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.veo-upload-slot:hover .slot-content {
    opacity: 1;
    color: var(--primary, #FABF3C);
}

.slot-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.slot-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.veo-upload-slot .placeholder {
    color: var(--text-secondary, #666);
    font-size: 24px; font-weight: 300; pointer-events: none;
}

/* Превью картинки */
.veo-upload-slot .preview-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
    border-radius: 15px;
}

/* Кнопка удаления */
.veo-upload-slot .remove-btn {
    position: absolute;
    top: 5px; right: 5px;
    width: 24px; height: 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; line-height: 1;
    z-index: 2;
    transition: all 0.2s;
}
.veo-upload-slot .remove-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
    transform: scale(1.1);
}

/* --- ИНФОРМАЦИОННЫЙ БЛОК VEO --- */
.veo-info-block {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.badge-number {
    background: var(--primary, #FABF3C);
    color: #000;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    margin-top: 2px;
}

.info-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.info-text strong {
    font-size: 13px;
    color: var(--text-main, #fff);
    margin-bottom: 2px;
}

.info-text small {
    font-size: 11px;
    color: var(--text-secondary, #888);
}

/* Кнопки переключения модели (Fast/Quality) */
.veo-type-btn {
    border: none;
    color: var(--text-secondary, #aaa);
    font-weight: 600;
    padding: 8px;
    border-radius: 10px !important;
    transition: all 0.2s;
}

.btn-check:checked + .veo-type-btn {
    background-color: var(--bg-card, #2b2f36) !important;
    color: var(--primary, #fff) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color, #555);
}

/* Кнопки аспекта для Veo */
.aspect-btn {
    border-color: var(--border-color, #444);
    color: #ccc;
    font-size: 13px;
}
.btn-check:checked + .aspect-btn {
    background-color: var(--primary, #FABF3C) !important;
    border-color: var(--primary, #FABF3C) !important;
    color: #000 !important;
    font-weight: 700;
}

/* Стили для радио-кнопок (Veo Models & Aspect Ratio) */
.btn-check:checked + .btn-outline-primary,
.btn-check:checked + .btn-outline-secondary {
    background-color: var(--primary, #FABF3C) !important;
    border-color: var(--primary, #FABF3C) !important;
    color: #000 !important;
    box-shadow: 0 4px 12px rgba(250, 191, 60, 0.3);
}

.btn-outline-primary, .btn-outline-secondary {
    border-color: var(--border-color, #444);
    color: var(--text-secondary, #ccc);
    background: transparent;
}

.btn-outline-primary:hover, .btn-outline-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: #666;
    color: #fff;
}

/* Поле ввода сида */
#veo-seed {
    background: var(--bg-input, #1a1a1a) !important;
    border: 1px solid var(--border-color, #333) !important;
    color: var(--text-main, #fff) !important;
}
#veo-seed::placeholder { color: #666; }
#veo-seed:focus { border-color: var(--primary, #FABF3C) !important; box-shadow: none; }


/* ==========================================================================
   3. ИНТЕРФЕЙС GROK И ОБЩИЕ КОНТРОЛЫ ВИДЕО
   ========================================================================== */

/* Переключатель режимов (Текст/Фото) */
.video-mode-switcher {
    position: relative; display: flex; width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px; padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px; user-select: none;
}

.video-mode-switcher input[type="radio"] { display: none; }

.video-mode-switcher label {
    flex: 1; text-align: center; padding: 10px 0;
    cursor: pointer; z-index: 2;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600; font-size: 0.95rem;
    transition: color 0.3s ease;
}

.switcher-bg {
    position: absolute; top: 4px; left: 4px;
    width: calc(50% - 4px); height: calc(100% - 8px);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: 8px;
    transition: transform 0.3s cubic-bezier(0.45, 0.05, 0.55, 0.95);
    z-index: 1; box-shadow: 0 2px 10px rgba(255, 215, 0, 0.2);
}

#vmode-text:checked ~ .switcher-bg { transform: translateX(0); }
#vmode-text:checked + label { color: #000; }
#vmode-image:checked ~ .switcher-bg { transform: translateX(100%); }
#vmode-image:checked + label { color: #000; }

/* Область загрузки (Grok) */
.upload-drop-zone {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 15px; min-height: 100px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s ease;
}
.upload-drop-zone:hover { border-color: var(--primary, #FABF3C); background: rgba(250, 191, 60, 0.05); }

/* Кнопка генерации видео */
#generate-video-button {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 12px;
    font-size: 1rem; font-weight: bold;
    text-transform: uppercase; letter-spacing: 0.5px;
    background-color: var(--primary, #FABF3C);
    color: #000; border: none; border-radius: 12px;
    transition: all 0.3s ease;
}
#generate-video-button:hover {
    background-color: #ffca5c;
    box-shadow: 0 0 15px rgba(250, 191, 60, 0.4);
    transform: translateY(-2px);
}
#generate-video-button:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

/* Выпадающий список (Аспект для Grok/Kling) */
.custom-select {
    background-color: var(--bg-input, #1a1a1a);
    color: var(--text-main, #fff);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px; padding: 10px 12px;
    font-size: 14px; width: 100%; cursor: pointer;
    
    /* Иконка стрелки */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.custom-select:focus { 
    border-color: var(--primary, #FABF3C); 
    outline: none; 
    box-shadow: 0 0 0 4px rgba(250, 191, 60, 0.1);
}
.custom-select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

/* ==========================================================================
   4. СТИЛИ ДЛЯ KLING (КВАДРАТНЫЕ СЛОТЫ)
   ========================================================================== */

/* Квадратный слот Kling */
.kling-upload-slot {
    aspect-ratio: 1 / 1;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-width: 0;
}

.kling-upload-slot:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Плейсхолдер (иконка + текст) */
.slot-placeholder, .slot-loading, .slot-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 10px;
}

/* Превью картинки Kling (растягиваем на весь квадрат) */
.slot-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
}

/* Кнопка удаления (крестик) */
.slot-remove-btn {
    position: absolute;
    top: 5px; right: 5px;
    width: 24px; height: 24px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    z-index: 10;
    transition: background 0.2s;
}

.slot-remove-btn:hover {
    background: #dc3545;
}

/* Настройка контейнеров превью (Kling) */
#kling-image-preview, 
#kling-video-preview {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10;
    pointer-events: none;
}

/* Стили для ФОТО Kling */
#kling-image-preview .attachment-preview {
    width: 100%; height: 100%;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

#kling-image-preview img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 12px;
}

/* Стили для ВИДЕО Kling (Бейдж файла) */
#kling-video-preview .alert {
    width: 100%; height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 12px;
    background: linear-gradient(145deg, #102816, #09180d) !important;
    border: 1px solid #1e4d2b !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#kling-video-preview .fa-cloud-check,
#kling-video-preview .fa-check {
    font-size: 24px;
    color: #28a745;
    margin-bottom: 5px;
    display: block !important;
}

/* Название файла */
#kling-video-preview .text-truncate {
    color: #fff;
    font-size: 10px;
    max-width: 90%;
    display: block;
    margin-bottom: 5px;
}

/* Бейдж длительности */
#kling-video-preview .badge {
    font-size: 10px !important;
    background: rgba(0,0,0,0.5) !important;
    margin: 0 !important;
}

/* Общая кнопка удаления для Kling контейнеров */
#kling-image-preview .remove-attachment,
#kling-video-preview .remove-attachment-video,
#kling-video-preview .remove-attachment {
    position: absolute;
    top: 5px !important; right: 5px !important;
    width: 24px; height: 24px;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    pointer-events: auto; /* Включаем клики */
    z-index: 20;
    font-size: 16px; line-height: 1;
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.2s;
}

#kling-image-preview .remove-attachment:hover,
#kling-video-preview .remove-attachment:hover {
    background: #dc3545 !important;
    transform: scale(1.1);
}

/* ==========================================================================
   5. ЗАГРУЗКА И ПЛЕЙСХОЛДЕРЫ ВИДЕО
   ========================================================================== */

.video-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Уникальный класс для видео-спиннера */
.video-spinner-wrapper {
    position: relative;
    width: 48px !important; 
    height: 48px !important;
    margin-bottom: 12px;
    margin-top: 0;
    display: block;
}

.video-spinner-wrapper .spinner-outer-wheel,
.video-spinner-wrapper .spinner-inner-core {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    transform: none;
}

/* Анимация вращения */
.video-spinner-wrapper .spinner-outer-wheel {
    animation: spinVideo 2s linear infinite;
}

/* Текст статуса */
.video-placeholder .status-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 10px;
    animation: textPulse 2s infinite ease-in-out;
}

@keyframes spinVideo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes textPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ==========================================================================
   6. СТИЛИ ДЛЯ КОНТРОЛОВ GROK (Кнопки вместо Select)
   ========================================================================== */

/* Контейнер для группы кнопок */
.grok-toggle-group {
    background-color: var(--bg-input, #1a1a1a);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

/* Стили для лейбла кнопки (когда она не активна) */
.grok-toggle-btn {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    user-select: none;
    border: 1px solid transparent;
}

.grok-toggle-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* Скрываем стандартные радио-кнопки */
.btn-check {
    position: absolute;
    clip: rect(0,0,0,0);
    pointer-events: none;
}

/* Активное состояние (выбрано) */
.btn-check:checked + .grok-toggle-btn {
    background-color: var(--primary, #FABF3C);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(250, 191, 60, 0.2);
}

/* Дополнительная подпись цены внутри кнопки */
.grok-price-tag {
    display: block;
    font-size: 9px;
    opacity: 0.7;
    margin-top: 2px;
    font-weight: 400;
}
.btn-check:checked + .grok-toggle-btn .grok-price-tag {
    color: #000;
    opacity: 0.8;
    font-weight: 600;
}