/* =========================
   LAYOUT
========================= */

.flyer-generator {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    margin-top: 30px;
    align-items: start;
}

.flyer .draggable {
    cursor: grab;
}

.flyer .draggable:active {
    cursor: grabbing;
}

/* =========================
   HEADER
========================= */

.header {
    text-align: center;
    margin-bottom: 20px;
}

/* =========================
   TEMPLATE SELECTOR
========================= */

.template-selection {
    margin-bottom: 20px;
}

.templates {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.template-card {
    width: 130px;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.template-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: 0.2s;
}

.template-card:hover img {
    transform: scale(1.03);
}

.template-card.active img {
    border-color: #f9ba1a;
}

.template-card p {
    margin-top: 6px;
    font-size: 13px;
}

/* radio dot */
.template-card::after {
    content: "";
    display: block;
    margin: 6px auto 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #ccc;
}

.template-card.active::after {
    background: #f9ba1a;
    border-color: #f9ba1a;
}

/* =========================
   PREVIEW
========================= */

.preview {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #ddd;
}

.flyer {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
    padding: 20px;
}

.flyer > * {
    position: absolute;
}

/* flyer elements */

.flyer-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
}

.flyer-products {
    display: block; /* важно */
    position: absolute;
    gap: 10px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.flyer-products img {
    width: 70px;
    height: 70px;
    object-fit: contain;
}

.flyer-discount {
    font-size: 40px;
    font-weight: bold;
    color: #e53935;
}

.flyer-utp {
    margin-top: 10px;
    font-size: 14px;
}

.flyer-dates {
    position: absolute;
    bottom: 10px;
    font-size: 12px;
    color: #555;
}

/* =========================
   CONTROLS PANEL (REFORMATED)
========================= */

.controls {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* section blocks */
.control-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* labels */
.controls label {
    font-size: 13px;
    font-weight: 600;
}

/* inputs */
.controls select,
.controls input,
.controls textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 14px;
}

/* textarea */
.controls textarea {
    resize: none;
}

.count-selector button {
    margin: 3px;
    padding: 8px 12px;
    cursor: pointer;
}

.count-selector button.active {
    background: #2d6cdf;
    color: white;
}

/* =========================
   CHECKBOX / RADIO UI
========================= */

.checkbox-group,
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-group label,
.radio-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    cursor: pointer;
    background: #fafafa;
    font-size: 13px;
    transition: 0.2s;
    flex: 1;
    text-align: center;
}

.checkbox-group label:hover,
.radio-group label:hover {
    border-color: #f9ba1a;
    background: #fff8e1;
}

.radio-group label.active {
    border-color: #f9ba1a;
    background: #fff8e1;
    font-weight: 600;
}

.radio-group input[type="radio"] {
    display: none;
}

/* =========================
   LOGO CARDS
========================= */

.logo-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.logo-card {
    width: 90px;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    background: #fff;
}

.logo-card img {
    width: 100%;
    height: 40px;
    object-fit: contain;
}

.logo-card:hover {
    border-color: #f9ba1a;
    transform: translateY(-2px);
}

.logo-card.active {
    border: 2px solid #f9ba1a;
    background: #fff8e1;
}

/* =========================
   LOGO POSITION
========================= */

.position-group {
    display: flex;
    gap: 10px;
}

.position-btn {
    flex: 1;
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    background: #fafafa;
    font-size: 13px;
    transition: 0.2s;
}

.position-btn.active {
    border-color: #f9ba1a;
    background: #fff8e1;
}

.flyer-logo-img {
    height: 200px;
    object-fit: contain;
}

/* ===== BOLD TEXT ===== */

.flyer-utp b {
    font-weight: 800;
}

#flyer-logo {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 20px; /* 🔥 ВОТ ЭТО */
}

#flyer-logo.left {
    justify-content: flex-start;
}

#flyer-logo.center {
    justify-content: center;
}

#flyer-logo.right {
    justify-content: flex-end;
}

/* =========================
   PRODUCT COUNT (КНОПКИ БАНОК)
========================= */

#product-count-aktsii {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#product-count-aktsii button {
    flex: 1;
    min-width: 40px;
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    background: #fafafa;
    font-size: 13px;
    transition: 0.2s;
}

#product-count-aktsii button:hover {
    border-color: #f9ba1a;
    background: #fff8e1;
}

#product-count-aktsii button.active {
    border-color: #f9ba1a;
    background: #fff8e1;
    font-weight: bold;
    color: black;
}

/* =========================
   PRODUCT SELECTORS (БАНКИ)
========================= */

#product-selectors {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

/* каждая строка банка */
.product-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fafafa;
    transition: 0.2s;
}

.product-row:hover {
    border-color: #f9ba1a;
    background: #fff8e1;
}

/* label внутри банка */
.product-row label {
    font-size: 13px;
    font-weight: 600;
}

/* сам select */
.product-row select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.product-row select:focus {
    outline: none;
    border-color: #f9ba1a;
}

/* =========================
   BUTTON
========================= */

#generate-pdf {
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: #f9ba1a;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

#generate-pdf:hover {
    background: #ffcc00;
}

/* =========================
   TEMPLATES LAYOUT SYSTEM
========================= */

.template-wood .flyer-discount {
    position: absolute;
    top: 20px;
    right: 20px;
}

.template-wood .flyer-products {
    justify-content: center;
}

.template-keraline .flyer-products {
    flex-direction: column;
    align-items: center;
}

.template-keraline .flyer-discount {
    text-align: center;
    font-size: 42px;
}

.template-buy3 .flyer-discount {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.template-buy3 .flyer-utp {
    text-align: center;
    font-weight: bold;
}

/* =========================
   ADAPTIVE
========================= */

@media (max-width: 900px) {
    .flyer-generator {
        grid-template-columns: 1fr;
    }

    .controls {
        position: static;
    }
}