/* --- 1. ИНТЕРФЕЙС ПРИЛОЖЕНИЯ --- */
html,
body {
    font-family: 'Roboto', sans-serif;
    background: #f4f7f9;
    /* Мягкий светло-серый фон */
    margin: 0;
    padding: 0;
    color: #333;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    padding: 15px;
    /* Немного уменьшили для мобилки, на десктопе норм */
    box-sizing: border-box;
}

/* --- ШАПКА И ПОДВАЛ --- */
.main-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    background: transparent;
    position: relative;
}

.main-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.brand-logo {
    height: 32px;
    /* Подходящий размер для шапки */
    width: auto;
    object-fit: contain;
}

.main-header .logo span {
    color: #3b82f6;
    font-weight: 400;
}

.main-footer {
    margin-top: 50px;
    padding: 30px;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    font-size: 13px;
}

/* Ряд из трех кнопок */
.template-selector {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 5px;
}

.tpl-btn {
    padding: 10px 5px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 700;
    font-size: 11px;
    /* Чуть меньше шрифт, чтобы влезло в ряд */
    text-align: center;
    transition: all 0.2s ease;
    color: #64748b;
}

/* --- ЦВЕТОВЫЕ АКЦЕНТЫ (ТУСКЛЫЕ) --- */

/* Зеленый (Шаблон 1) */
.btn-green {
    background: #f0f4e8;
    border-color: #e2e8d5;
}

.btn-green:hover,
.btn-green.active {
    background: #b2d235;
    /* Твой фирменный зеленый */
    color: #1a2e05;
    border-color: #a1bf30;
}

/* Красный (Шаблон 2) */
.btn-red {
    background: #fdf2f2;
    border-color: #f9e2e2;
}

.btn-red:hover,
.btn-red.active {
    background: #ff4d4d;
    color: white;
    border-color: #e60000;
}

/* Голубой (Шаблон 3) */
.btn-blue {
    background: #f0f9fa;
    border-color: #e2f2f4;
}

.btn-blue:hover,
.btn-blue.active {
    background: #6fbac6;
    color: white;
    border-color: #5aa4b0;
}

/* Тень для активной кнопки, чтобы она чуть "выпирала" */
.tpl-btn.active {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Убираем лишние отступы у workspace, так как сверху теперь пусто */
.workspace {
    margin-top: 10px;
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.tpl-btn:hover {
    background: #f8fafc;
    color: #0f172a;
}

.tpl-btn.active {
    background: #0f172a;
    /* Темный грифельный цвет активной вкладки */
    color: white;
    border-color: #0f172a;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}

.workspace {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

/* --- Панель управления --- */
.controls {
    width: 380px;
    background: white;
    padding: 30px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    /* <--- ДОБАВИТЬ ЭТУ СТРОКУ */
}

.controls-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    font-weight: 700;
    margin-bottom: 15px;
}

.control-group {
    margin-bottom: 18px;
}

.control-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #475569;
}

.controls input[type="text"],
.controls textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    background: #f8fafc;
    transition: all 0.2s ease;
    outline: none;
    resize: none;
}

.controls input[type="text"]:focus,
.controls textarea:focus {
    border-color: #3b82f6;
    /* Синяя рамка при фокусе */
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.price-input {
    font-weight: 700;
    font-size: 16px !important;
    color: #16a34a;
}

.divider {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 15px 0;
}

/* --- Кастомные зоны загрузки файлов --- */
.custom-file-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
}

.custom-file-upload:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #3b82f6;
}

/* Класс, который добавляется через JS, когда фотка загружена */
.custom-file-upload.loaded {
    border-style: solid;
    border-color: #10b981;
    /* Зеленый цвет успеха */
    background: #ecfdf5;
    color: #10b981;
}

/* --- Кнопки Скачать и Поделиться --- */
.action-buttons {
    display: flex;
    /* На десктопе растягивается на 100%, так как share скрыт */
    gap: 10px;
    margin-top: 20px;
}

#download-btn,
#share-btn {
    flex: 1;
    /* Одинаковая ширина */
    padding: 16px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    /* Между иконкой и текстом */
}

#download-btn {
    background: #2563eb;
    /* Яркий синий */
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

#download-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

#download-btn:active,
#share-btn:active {
    transform: translateY(0);
}

#share-btn {
    display: none;
    /* Скрыто на ПК */
    background: #10b981;
    /* Зеленый цвет для "Поделиться" */
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

#share-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

/* --- 2. ОБЩИЕ СТИЛИ ДЛЯ КАНВАСА (ШАБЛОНОВ) --- */
.preview-area {
    display: flex;
    justify-content: center;
}

.canvas-wrapper {
    width: 450px;
    height: 800px;
    /* Пропорции 9:16 */
    min-width: 450px;
    min-height: 800px;
    /* ЖЕСТКИЙ РАЗМЕР */
    flex-shrink: 0;
    /* ЗАПРЕЩАЕМ СЖАТИЕ */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    position: relative;
    background: #222;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Маски для фото */
.mask {
    position: relative;
    overflow: hidden;
    background: #111;
}

.h-35 {
    height: 35%;
}

.h-40 {
    height: 40%;
}

.h-25 {
    height: 25%;
    flex-grow: 1;
}

.w-50 {
    width: 50%;
    height: 100%;
}

.border-top {
    border-top: 2px solid #333;
}

.car-image {
    position: absolute;
    top: 0;
    left: 0;
    cursor: grab;
}

.car-image:active {
    cursor: grabbing;
}

/* --- 3. ТЕМА 1 (ЗЕЛЕНАЯ) --- */
.theme-green .info-band {
    background: #2a2a2a;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
}

.theme-green .out-title {
    color: #b2d235;
    font-size: 26px;
    font-weight: 900;
    margin-bottom: 5px;
}

.theme-green .out-desc {
    color: #fff;
    font-size: 11px;
    line-height: 1.4;
    font-weight: bold;
}

.theme-green .out-price {
    background: #b2d235;
    color: #000;
    padding: 8px 15px;
    font-size: 24px;
    font-weight: 900;
    border-radius: 5px;
}

/* --- 4. ТЕМА 2 (КРАСНАЯ) --- */
.theme-red {
    background: #1a1a1a;
}

.theme-red .red-header {
    height: 8%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    color: white;
    border-top: 5px solid red;
    font-size: 14px;
}

.theme-red .info-band {
    background: #222;
    padding: 15px;
    text-align: center;
    border-top: 4px solid red;
}

.theme-red .out-title {
    color: red;
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.theme-red .year-badge {
    background: red;
    color: white;
    padding: 0 8px;
    border-radius: 4px;
}

.theme-red .out-desc {
    color: #fff;
    font-size: 11px;
    margin-bottom: 15px;
    font-weight: bold;
}

.theme-red .out-price {
    background: red;
    color: white;
    display: inline-block;
    padding: 10px 40px;
    font-size: 32px;
    font-weight: 900;
}

.theme-red .split-photos {
    height: 25%;
    display: flex;
    padding: 15px;
    gap: 10px;
    background: #222;
}

.theme-red .split-photos .mask {
    border: 2px solid red;
}

.theme-red .footer-text {
    text-align: center;
    color: #888;
    font-size: 10px;
    padding: 10px;
}


/* --- СТИЛИ ДЛЯ PNG-ШАБЛОНА (СЭНДВИЧ) --- */
.template-png {
    position: relative;
    background: #111;
    /* Цвет фона, если фотка не перекроет дырку */
}

/* Слой с PNG-рамкой */
.png-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 10;
    /* Лежит поверх фоток */
    pointer-events: none;
    /* МАГИЯ! Мышка проходит сквозь рамку к фоткам */
}

/* Зоны для фотографий (Слой 1) */
.photo-zone {
    position: absolute;
    overflow: hidden;
    z-index: 1;
    /* Лежат на самом дне */
}

/* ВНИМАНИЕ: Настрой эти проценты под свои прозрачные "дырки"!
  width/height - размер зоны (делай чуть больше дырки)
  top/left - отступ сверху и слева
*/
.zone-1 {
    top: 0%;
    left: 0%;
    width: 100%;
    height: 30%;
}

/* Главное фото сверху */
.zone-2 {
    top: 41%;
    left: 0%;
    width: 100%;
    height: 29.5%;
}

/* Фото слева снизу */
.zone-3 {
    top: 70.5%;
    left: 0%;
    width: 100%;
    height: 31%;
}

/* Фото справа снизу */


/* Слой с текстом (Слой 3) */
.text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    /* Лежит поверх рамки */
    pointer-events: none;
    /* Чтобы текст не мешал таскать фотки */
}

/* Настрой координаты текста под свой дизайн */
.template-png .out-title {
    position: absolute;
    top: 29.2%;
    /* Отступ сверху */
    /* --- Новые правила для центровки --- */
    left: 0;
    /* Прижимаем блок к левому краю */
    width: 100%;
    /* Растягиваем блок на всю ширину картинки */
    text-align: center;
    /* Выравниваем сам текст по центру блока */
    /* ----------------------------------- */
    color: #b2d235;
    font-size: 28px;
    font-weight: 900;
}

/* Подзаголовок (Комплектация) */
.template-png .out-subtitle {
    position: absolute;
    top: 33%;
    /* Чуть ниже заголовка (который на 44%) */
    left: 0;
    width: 100%;
    text-align: center;
    color: #bbca7c;
    /* Светло-серый, чтобы не спорил с заголовком */
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
}

/* Описание */
.template-png .out-desc {
    position: absolute;
    top: 36%;
    /* Базовое значение (будем менять ползунком) */
    left: 5%;
    /* Базовое значение */
    width: 100%;
    text-align: left;
    color: #ffffff;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 700;
}

.template-png .out-price {
    position: absolute;
    top: 35%;
    left: 52%;
    /* background: #b2d235; */
    color: #000000;
    padding: 8px 15px;
    font-size: 24px;
    font-weight: 900;
    border-radius: 5px;
}


/* =========================================
   ШАБЛОН 2 (КРАСНЫЙ - .tpl-2)
   ========================================= */

/* --- Координаты дырок --- */
.tpl-2 .t2-zone-1 {
    top: 13.32%;
    left: 0;
    width: 100%;
    height: 32.6%;
}

.tpl-2 .t2-zone-2 {
    top: 67%;
    left: 5.8%;
    width: 43%;
    height: 17%;
}

.tpl-2 .t2-zone-3 {
    top: 67%;
    left: 51.8%;
    width: 43%;
    height: 17%;
}

/* --- НОВЫЕ НЕЗАВИСИМЫЕ СТИЛИ --- */

/* 1. НАЗВАНИЕ МОДЕЛИ (Красное, справа от центра) */
.tpl-2 .val-title {
    position: absolute;
    /* Двигай вверх/вниз */
    top: 47.9%;

    /* Двигай влево/вправо (отступ от правого края) */
    right: 48%;
    /* 50% = центр. Чем больше число, тем левее уедет */
    width: 45%;
    text-align: right;
    /* Текст прижат к правому краю своего блока */

    color: #ff0000;
    /* Меняй размер шрифта */
    font-size: 30px;
    font-weight: 900;
}

/* 2. ГОД (Белое, слева от центра) */
.tpl-2 .val-year {
    position: absolute;
    /* Двигай вверх/вниз НЕЗАВИСИМО от названия */
    top: 48.4%;

    /* Двигай влево/вправо (отступ от левого края) */
    left: 57%;
    /* 50% = центр. Чем больше число, тем правее уедет */
    width: 45%;
    text-align: left;
    /* Текст прижат к левому краю своего блока */

    color: #ffffff;
    /* Меняй размер шрифта НЕЗАВИСИМО от названия */
    font-size: 22px;
    font-weight: 900;
}

/* --- Остальной текст --- */
.tpl-2 .out-desc {
    position: absolute;
    top: 54.8%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 600;
}

.tpl-2 .out-subtitle {
    position: absolute;
    top: 52%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ffffff;
    font-size: 14px;
    font-weight: 900;
}

.tpl-2 .out-price {
    position: absolute;
    top: 59.6%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ffffff;
    /* В этом макете цена белая */
    font-size: 32px;
    font-weight: 900;
}

.tpl-2 .out-footer {
    position: absolute;
    top: 86%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #dddddd;
    font-size: 10px;
}


/* =========================================
   ШАБЛОН 3 (ГОЛУБОЙ - .tpl-3)
   ========================================= */

/* --- Координаты дырок --- */
.tpl-3 .t3-zone-1 {
    top: 13%;
    left: 8%;
    width: 84%;
    height: 41%;
}

.tpl-3 .t3-zone-2 {
    top: 45.5%;
    left: 12.6%;
    width: 34.4%;
    height: 16.3%;
    border-radius: 14px 0px 0px 0px;
}

.tpl-3 .t3-zone-3 {
    top: 49.5%;
    left: 51.5%;
    width: 35.4%;
    height: 17.3%;
    border-radius: 14px 0px 0px 0px;
}

/* 1. НАЗВАНИЕ МОДЕЛИ (Две строки, выровнено вправо) */
.tpl-3 .val-title {
    position: absolute;
    top: 63.5%;
    right: 51%;
    /* Отступ от центра влево */
    width: 45%;
    text-align: right;
    color: #6fbac6;
    /* Голубой цвет из твоего макета */
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    /* Чтобы строки стояли плотно друг к другу */
}

/* 2. ГОД (Слева, с голубой плашкой) */
.tpl-3 .val-year {
    position: absolute;
    top: 68.35%;
    /* Стоит на одном уровне с нижней строкой названия */
    left: 51%;
    /* Отступ от центра вправо */

    /* Делаем плашку */
    width: max-content;
    /* Чтобы фон облегал только цифры */
    /* background: #6fbac6; */
    color: #ffffff;
    padding: 2px 14px;
    border-radius: 6px;

    font-size: 21px;
    font-weight: 900;
}

/* 3. КОМПЛЕКТАЦИЯ (Под названием, выровнена вправо) */
.tpl-3 .out-subtitle {
    position: absolute;
    top: 72%;
    /* Ниже названия */
    right: 51%;
    /* Такое же выравнивание, как у названия */
    width: 48%;
    text-align: right;

    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
}

/* 4. ОСТАЛЬНОЙ ТЕКСТ (По центру) */
.tpl-3 .out-desc {
    position: absolute;
    top: 77%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ffffff;
    font-size: 11px;
    line-height: 1.5;
    font-weight: 700;
}

.tpl-3 .out-price {
    position: absolute;
    top: 82.5%;
    left: 38px;
    width: 100%;
    text-align: center;
    color: #ffffff;
    font-size: 34px;
    font-weight: 900;
}

.tpl-3 .out-footer {
    position: absolute;
    top: 89%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #dddddd;
    font-size: 10px;
}

/* --- КНОПКИ И ДОП. СТИЛИ --- */
.burger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
}

.secondary-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.close-btn {
    display: none;
}

/* --- ЕДИНЫЙ БЛОК ДЛЯ МОБИЛОК --- */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }

    .burger-btn {
        display: block;
    }

    .close-btn {
        display: block;
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: none;
        color: #94a3b8;
        cursor: pointer;
        padding: 5px;
    }

    .drawer-handle {
        width: 40px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 3px;
        margin: 0 auto 15px auto;
    }

    .workspace {
        flex-direction: column;
        align-items: center;
        padding-top: 0;
    }

    .preview-area {
        margin-top: 15px;
        display: block;
        margin-left: auto;
        margin-right: auto;
        border-radius: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }

    .canvas-wrapper {
        /* JS handles scaling dynamically */
        transform: none;
        margin-bottom: 0;
        box-shadow: none;
        /* Let preview-area have the shadow */
    }

    /* Шторка */
    .controls {
        position: fixed;
        bottom: -100%;
        left: 0;
        right: 0;
        margin-left: 15px;
        margin-right: 15px;
        width: auto !important;
        height: 90vh;
        /* Увеличенная высота (была 80vh) */
        z-index: 1000;
        transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 20px 20px 0 0;
        overflow-y: auto;
        padding: 20px;
        padding-bottom: 50px;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    }

    .controls.open {
        bottom: 0;
    }

    .overlay.active {
        display: block;
    }

    #share-btn {
        display: flex;
        /* Показываем кнопку "Поделиться" на мобильных */
    }
}