/* === ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ === */
.theme-toggle {
    background: none;
    border: 1.5px solid rgba(255,255,255,0.15);
    color: #f0f0f7;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 50px;
    transition: 0.3s;
    line-height: 1;
}
.theme-toggle:hover { border-color: #7c3aed; background: rgba(124,58,237,0.1); }

/* === СВЕТЛАЯ ТЕМА === */
[data-theme="light"] {
    --bg-primary: #f5f3ff;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f0ecff;
    --border-color: rgba(0,0,0,0.08);
    --text-primary: #1a1025;
    --text-secondary: #5c5070;
    --text-muted: #8a7e9e;
}
[data-theme="light"] .top-bar { background: rgba(255,255,255,0.85); }
[data-theme="light"] .sidebar { background: #faf9ff; }
[data-theme="light"] .widget { background: #fff; border-color: rgba(0,0,0,0.06); }
[data-theme="light"] .radio-card { background: #f5f3ff; }
[data-theme="light"] .select-custom { background: #f5f3ff; color: #1a1025; }
[data-theme="light"] .select-custom option { background: #ffffff; color: #1a1025; }
[data-theme="light"] .prompt-box { background: #fff; }
[data-theme="light"] .prompt-box__input { background: #f5f3ff; color: #1a1025; }
[data-theme="light"] .preview-area { background: #faf9ff; }
[data-theme="light"] .auth-popup { background: #fff; color: #1a1025; }
[data-theme="light"] .auth-popup .field input { background: #f5f3ff; color: #1a1025; }
[data-theme="light"] .theme-toggle { color: #1a1025; border-color: rgba(0,0,0,0.15); }
[data-theme="light"] .frame-upload-box { border-color: rgba(0,0,0,0.1); background: rgba(0,0,0,0.01); }
[data-theme="light"] .frame-upload-box:hover { border-color: #7c3aed; background: rgba(124,58,237,0.03); }

/* === КАСТОМНЫЙ SELECT — ВЫСОКИЙ Z-INDEX И ЧЁТКИЙ ЦВЕТ === */
.custom-select {
    position: relative;
    z-index: 10;
}
.custom-select-list {
    z-index: 9999 !important;
    background: #0f0f1e !important;
    border: 1px solid #7c3aed !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.8) !important;
}
.custom-select-item {
    color: #ffffff !important;
    font-weight: 500 !important;
    background: #0f0f1e !important;
}
.custom-select-item:hover {
    background: rgba(124,58,237,0.3) !important;
    color: #ffffff !important;
}

/* === ФИКСАЦИЯ ЦВЕТА OPTIONS В НАТИВНОМ SELECT === */
.select-custom option {
    background: #0f0f1e !important;
    color: #ffffff !important;
}

/* === ЗАГРУЗКА КАДРОВ === */
.frames-upload {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.frame-upload-box {
    flex: 1;
    min-width: 240px;
    min-height: 200px;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
}
.frame-upload-box:hover {
    border-color: #7c3aed;
    background: rgba(124,58,237,0.05);
}
.frame-upload-box.has-image {
    border-color: #7c3aed;
    border-style: solid;
}
.frame-upload-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}
.frame-upload-box.has-image img { display: block; }
.frame-upload-box .frame-label {
    font-size: 0.95rem;
    color: #9090a8;
    text-align: center;
    padding: 20px;
    z-index: 1;
    pointer-events: none;
}
.frame-upload-box.has-image .frame-label { display: none; }
.frame-upload-box .frame-optional {
    font-size: 0.8rem;
    color: #606078;
    margin-top: 4px;
}
.frame-upload-box input[type="file"] { display: none; }

/* === ОКНО АВТОРИЗАЦИИ === */
.auth-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #161622;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 28px 24px;
    width: 340px;
    max-width: 90vw;
    z-index: 10000;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    color: #f0f0f7;
    font-family: 'Inter', sans-serif;
}
.auth-popup.active { display: block; }
.auth-popup__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
}
.auth-popup__backdrop.active { display: block; }
.auth-popup__close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #9090a8;
    font-size: 1.4rem;
    cursor: pointer;
}
.auth-popup__close:hover { color: #fff; }
.auth-popup h4 { text-align: center; font-size: 1.1rem; font-weight: 700; margin-bottom: 18px; }
.auth-popup .field { margin-bottom: 12px; }
.auth-popup .field label { display: block; font-size: 0.8rem; color: #9090a8; margin-bottom: 4px; }
.auth-popup .field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid rgba(255,255,255,0.1);
    background: #0a0a15;
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
}
.auth-popup .field input:focus { outline: none; border-color: #7c3aed; }
.auth-popup .err { color: #ef4444; font-size: 0.75rem; margin-top: 2px; display: none; }
.auth-popup .ok { color: #22c55e; font-size: 0.8rem; text-align: center; margin-top: 8px; display: none; }
.auth-popup .btn {
    width: 100%;
    padding: 11px;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    margin-top: 6px;
    transition: 0.2s;
}
.auth-popup .btn-purple { background: #7c3aed; color: #fff; }
.auth-popup .btn-purple:hover { background: #6d28d9; }
.auth-popup .link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 0.78rem;
}
.auth-popup .link-row span { color: #a78bfa; cursor: pointer; }
.auth-popup .link-row span:hover { text-decoration: underline; }

/* === БЛОКИРОВКА РЕЖИМА РАБОТЫ === */
.radio-card.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* === КНОПКА ДОБАВИТЬ ИЗОБРАЖЕНИЕ === */
.btn-add-image {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 2px dashed rgba(255,255,255,0.2);
    color: #a78bfa;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.3s;
    background: rgba(124,58,237,0.05);
}
.btn-add-image:hover {
    border-color: #7c3aed;
    background: rgba(124,58,237,0.12);
    color: #c084fc;
}

/* === ПРЕВЬЮ ЗАГРУЖЕННОГО ИЗОБРАЖЕНИЯ === */
#imagePreviewBox {
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 12px;
    overflow: hidden;
}
#imagePreviewBox.has-image {
    border-color: #7c3aed;
    border-style: solid;
}

/* === УМЕНЬШЕННЫЕ ОТСТУПЫ В САЙДБАРЕ (на 30%) === */
.sidebar {
    padding: 14px !important;
    overflow-y: auto !important;
}
.sidebar__header {
    margin-bottom: 14px !important;
}
.sidebar__header h3 {
    font-size: 1rem !important;
}
.widget {
    padding: 12px !important;
    margin-bottom: 10px !important;
    position: relative;
    z-index: auto;
}
.widget:has(.custom-select) {
    z-index: 10;
    overflow: visible !important;
}
.widget__title {
    font-size: 0.75rem !important;
    margin-bottom: 8px !important;
}
.widget__content {
    gap: 5px !important;
    overflow: visible !important;
}
.radio-card {
    padding: 8px 10px !important;
    font-size: 0.82rem !important;
}
.select-custom {
    padding: 8px 10px !important;
    font-size: 0.82rem !important;
}

/* === ФИКСАЦИЯ ВЫПАДАЮЩЕГО СПИСКА ПОВЕРХ ВСЕХ ЭЛЕМЕНТОВ === */
#aiSelectContainer {
    z-index: 100 !important;
    position: relative !important;
}
#aiSelectContainer > div {
    z-index: 100 !important;
}
#aiWidget {
    z-index: 99 !important;
    position: relative !important;
}

/* === МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media (max-width: 768px) {
    .top-bar {
        padding: 0 12px;
        height: 56px;
    }
    .top-bar__nav {
        display: none;
    }
    .top-bar__right {
        gap: 6px;
    }
    .top-bar__right .btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    .credits-badge {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
    .hamburger {
        display: block;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 56px;
        z-index: 99;
        width: 280px;
        height: calc(100vh - 56px);
        transition: left 0.3s ease;
        padding: 16px;
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar__close {
        display: block;
    }
    
    .workspace {
        padding: 16px 12px;
    }
    
    .frames-upload {
        flex-direction: column;
        gap: 12px;
    }
    .frame-upload-box {
        min-height: 160px;
    }
    
    .prompt-box {
        padding: 16px;
    }
    .prompt-box__input {
        font-size: 16px;
    }
    
    #imagePreviewWrapper {
        flex-direction: column;
    }
    #imagePreviewBox {
        width: 100%;
        min-height: 120px;
    }
    
    .prompt-hints {
        gap: 4px;
    }
    .hint-chip {
        padding: 4px 10px;
        font-size: 0.7rem;
    }
    
    .preview-area {
        min-height: 250px;
    }
    
    .auth-popup {
        width: 95vw;
        padding: 24px 16px;
    }
}