
body {
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    background-color: #e9ebee;
    color: #333;
}

/* --- ОСНОВНАЯ СТРУКТУРА --- */
.app-container { display: flex; }
.controls {
    width: 380px;
    padding: 25px;
    background-color: #ffffff;
    border-right: 1px solid #ddd;
    box-sizing: border-box;
    height: 100vh;
    overflow-y: auto;
}
.preview {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 50px;
}
.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.controls h2 {
    margin: 0;
    padding: 0;
    border: none;
}
.controls h3 {
    margin-top: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}
#history-buttons {
    display: flex;
    gap: 5px;
}
#history-buttons button {
    width: 40px;
    height: 30px;
    padding: 0;
    margin: 0;
    font-size: 20px;
    line-height: 30px;
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    cursor: pointer;
}
#history-buttons button:hover:not(:disabled) {
    background-color: #e0e0e0;
}
#history-buttons button:disabled {
    color: #aaa;
    cursor: not-allowed;
    background-color: #f8f8f8;
}

.controls label {
    display: block;
    margin: 15px 0 5px;
    font-weight: bold;
    font-size: 14px;
}
.controls input, .controls textarea, .controls select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

#region-input-wrapper {
    position: relative;
}
#ctrl-region-input {
    padding-right: 25px;
}
#clear-region-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 20px;
    color: #aaa;
    line-height: 1;
    user-select: none;
}
#clear-region-button:hover {
    color: #333;
}

.controls button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
}
.controls button.secondary {
    background-color: #6c757d;
    margin-top: 10px;
}
.controls button.secondary:hover {
    background-color: #5a6268;
}
#add-product-button, #generate-data-button, #replace-flag-button, .calculation-button, .gender-button {
    background-color: #e9e9e9;
    color: #333;
    margin-bottom: 5px;
    margin-top: 0;
}
#add-product-button:hover, #generate-data-button:hover, #replace-flag-button:hover, .calculation-button:hover, .gender-button:hover {
    background-color: #dcdcdc;
}

.name-generation-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.gender-buttons-wrapper {
    display: flex;
    gap: 5px;
}
.gender-button {
    font-size: 12px;
    padding: 8px;
    flex: 1;
}

.control-group {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.control-group label {
    margin-top: 0;
}
.calculation-button {
    font-size: 14px;
    padding: 10px;
    margin-top: 5px;
}

/* --- Стили аккордеона --- */
.accordion-item {
    margin-top: 15px;
}
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-top: 0;
}
.accordion-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #333;
    transition: transform 0.3s ease;
}
.accordion-header.active .accordion-arrow {
    transform: rotate(180deg);
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding: 0 5px;
}
.accordion-content.active {
    max-height: 1000px; /* Достаточно большая высота для любого контента */
    padding: 10px 5px 5px 5px;
}
/* Сброс отступа для первого элемента в аккордеоне */
.accordion-content > *:first-child {
    margin-top: 0;
}


/* --- Стили для панели форматирования --- */
#format-buttons { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; transition: opacity 0.3s; align-items: center; }
#format-buttons.disabled { opacity: 0.5; pointer-events: none; }
#format-buttons button { width: 40px; height: 40px; padding: 0; margin: 0; font-size: 18px; background-color: #f0f0f0; color: #333; border: 1px solid #ccc; }
#format-buttons button:hover { background-color: #e0e0e0; }
#ctrl-color { width: 38px; height: 38px; padding: 2px; border: 1px solid #ccc; background-color: #f0f0f0; cursor: pointer; }
#ctrl-font-size { height: 40px; width: 60px; text-align: center; border: 1px solid #ccc; border-radius: 4px; padding: 0 5px; }
#ctrl-font { height: 40px; padding: 0 5px; background-color: #f0f0f0; flex-grow: 1; }

.text-actions { display: flex; gap: 10px; margin-top: 10px; }
.text-actions button { margin-top: 0; padding: 8px; font-size: 12px; }
.text-actions button.danger { background-color: #dc3545; }
.text-actions button.danger:hover { background-color: #c82333; }
.text-actions button:disabled { background-color: #ccc; cursor: not-allowed; }

.control-toggles { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; }
.control-toggles label { display: flex; align-items: center; gap: 8px; }
.control-icon { width: 22px; height: 22px; stroke: #333; cursor: pointer; transition: stroke 0.3s; }
.control-icon:hover { stroke: #007bff; }
.control-icon.dimmed { stroke: #ccc; }

/* --- ФОРМА --- */
.form-wrapper { position: relative; width: 450px; padding: 30px; background-color: #fff; border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); box-sizing: border-box; overflow: hidden; background-image: linear-gradient(90deg, #3580ed 50%, transparent 50%), linear-gradient(90deg, #3580ed 50%, transparent 50%), linear-gradient(0deg, #3580ed 50%, transparent 50%), linear-gradient(0deg, #3580ed 50%, transparent 50%); background-repeat: repeat-x, repeat-x, repeat-y, repeat-y; background-size: 10px 2px, 10px 2px, 2px 10px, 2px 10px; background-position: 0 0, 0 100%, 0 0, 100% 0; animation: marching-ants 400ms linear infinite; }
@keyframes marching-ants { from { background-position: 0 0, 0 100%, 0 0, 100% 0; } to { background-position: 10px 0, -10px 100%, 0 -10px, 100% 10px; } }
#snap-guide { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background-color: #ff0000a0; z-index: 999; transform: translateX(-50%); display: none; }
.draggable { position: absolute; cursor: move; user-select: none; transition: opacity 0.3s; }
.editable-text { cursor: text; }
.editable-text[contenteditable="true"], #phone-input-container.editing { outline: 2px solid #6a5acd; cursor: text !important; }
.dynamic-text { top: 150px; left: 10%; width: 80%; text-align: center; }

/* Режим фокуса при редактировании текста */
.form-wrapper.text-editing-mode .draggable:not(.editing):not([contenteditable="true"]) {
    opacity: 0.3;
    pointer-events: none;
}

#top-text { top: 30px; left: 5%; width: 90%; text-align: center; font-size: 14px; line-height: 1.5; color: #555; }
.highlight { color: #d9534f; font-weight: bold; }
#product-area { top: 85px; left: 50%; transform: translateX(-50%); width: 300px; height: 300px; touch-action: none; box-sizing: border-box; }
.image-placeholder { height: 100%; width: 100%; border: 2px solid #ddd; background-color: #fafafa; box-sizing: border-box; }
#product-area img { max-width: 100%; height: 100%; display: block; object-fit: cover; }
#product-area.selected { outline: 2px solid #007bff; outline-offset: 2px; }
#preview-discount { top: 375px; left: 50%; width: auto; transform: translateX(-50%); font-size: 38px; font-weight: 900; white-space: nowrap; }

#price-area {
    top: 395px;
    left: 50%;
    width: auto;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 48px;
    color: #ff0000;
    font-weight: 900;
}
.price .price-old {
    font-size: 28px;
    color: #888;
    text-decoration: line-through;
    margin-right: 15px;
    font-weight: normal;
}

#timer-label { top: 495px; left: 50%; width: auto; transform: translateX(-50%); font-size: 14px; color: #555; white-space: nowrap; }
#preview-timer { top: 520px; left: 50%; width: auto; transform: translateX(-50%); font-size: 40px; font-weight: bold; }

#name-label { top: 580px; left: 10%; width: auto; text-align: center; font-size: 14px; margin-bottom: 8px; }
#preview-name { top: 600px; left: 50%; width: 80%; transform: translateX(-50%); }
#phone-label { top: 655px; left: 10%; width: auto; text-align: center; font-size: 14px; margin-bottom: 8px; }
#phone-input-container { top: 675px; left: 50%; width: 80%; transform: translateX(-50%); }

.simulated-input { min-height: 44px; line-height: 1.2; color: #999; width: 100%; padding: 12px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; }
.phone-input-wrapper { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 4px; padding: 0 12px; background-color: #fff; min-height: 44px; box-sizing: border-box; }
.phone-input-wrapper input { border: none; padding-left: 5px; flex-grow: 1; height: 100%; font-size: 16px; pointer-events: none; background: transparent; }
.phone-input-wrapper input:focus { outline: none; }
.form-wrapper.text-editing-mode #phone-input-container.editing input { pointer-events: auto; }
#preview-flag { width: 24px; height: 18px; object-fit: contain; margin-right: 8px; }
#preview-button { top: 740px; left: 50%; width: 80%; transform: translateX(-50%); background-color: #5b99e5; color: white; border: none; padding: 16px; font-size: 18px; font-weight: bold; border-radius: 5px; cursor: pointer; text-transform: uppercase; transition: background-color 0.3s ease, transform 0.2s ease; }
#preview-button:hover { background-color: #4a8ae0; }
#preview-button:active { transform: translateX(-50%) scale(0.96); }
#bottom-text { top: 800px; left: 50%; width: auto; transform: translateX(-50%); text-align: center; font-size: 11px; color: #777; white-space: nowrap; }
.hidden { display: none !important; }
#edit-banner { position: fixed; top: -60px; left: 0; width: 100%; padding: 15px 0; background-color: #6a5acd; color: white; text-align: center; font-size: 20px; font-weight: bold; text-transform: uppercase; cursor: pointer; z-index: 9999; transition: top 0.4s ease-in-out; }
#edit-banner.visible { top: 0; }
.simulation-mode .controls { display: none; }
.simulation-mode .preview { width: 100vw; height: 100vh; padding: 0; align-items: center; justify-content: center; }
.simulation-mode .draggable { cursor: default; }
.simulation-mode .resizable { cursor: default; }
.simulation-mode #product-area.selected { outline: none; }
.simulation-mode .editable-text[contenteditable="true"] { outline: none; }

/* --- Стили для ручек изменения размера --- */
.resize-handle { box-sizing: border-box; position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid #007bff; z-index: 10; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#product-area.selected .resize-handle { opacity: 1; pointer-events: auto; }
.resize-handle.tl { top: -7px; left: -7px; cursor: nwse-resize; }
.resize-handle.tr { top: -7px; right: -7px; cursor: nesw-resize; }
.resize-handle.bl { bottom: -7px; left: -7px; cursor: nesw-resize; }
.resize-handle.br { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* --- Стили для модального окна помощи --- */
#help-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    line-height: 45px;
    padding: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}
#help-modal .modal-content {
    background: #fff;
    padding: 25px 35px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
#help-modal .modal-content h4 {
    margin-top: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}
#help-modal .modal-content ul {
    padding-left: 20px;
}
#help-modal .modal-content li {
    margin-bottom: 8px;
}
#help-modal .close-button {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #aaa;
}
#help-modal .close-button:hover {
    color: #333;
}