* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    align-items: center; /* Центрируем canvas-container */
    overflow-x: hidden;
}

.canvas-container {
    position: relative;
    overflow: hidden;
    background: #e0e0e0;
    /* Ограничиваем размером canvas, без лишних полей */
    display: inline-block;
    margin: 0;
    padding: 0;
}

#bannerCanvas {
    display: block;
    margin: 0;
    padding: 0;
    background: white;
    /* Canvas будет масштабироваться, но контейнер точно по его размеру */
}

.text-layer {
    position: absolute;
    cursor: move;
    user-select: none;
    touch-action: none;
    z-index: 10;
    padding: 2px; /* Добавляем небольшой padding для видимости рамки */
    margin: 0;
    border: 2px dashed transparent;
    transition: border-color 0.2s;
    overflow: visible; /* Текст может выходить за границы */
    min-width: 50px; /* Минимальная ширина для resize */
    min-height: 20px; /* Минимальная высота для resize */
    box-sizing: border-box; /* Учитываем border и padding в размерах */
}

.text-layer:hover {
    border-color: #007bff;
}

.text-layer.dragging {
    border-color: #007bff;
    opacity: 0.8;
}

.text-layer.out-of-bounds {
    border-color: #dc3545;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Сетка для ориентации */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
    background-size: 50px 50px; /* Размер ячейки сетки */
    opacity: 0.3;
}

/* Safe area overlay - визуальная индикация безопасной зоны */
.safe-area-overlay {
    position: absolute;
    border: 2px dashed rgba(0, 123, 255, 0.3);
    background: rgba(0, 123, 255, 0.05);
    pointer-events: none;
    z-index: 5;
    display: none; /* По умолчанию скрыто, показывается при наведении на слой */
}

.safe-area-overlay.visible {
    display: block;
}

/* Зона логотипа - запрещенная область */
.logo-zone-overlay {
    position: absolute;
    border: 2px dashed rgba(220, 53, 69, 0.5);
    background: rgba(220, 53, 69, 0.1);
    pointer-events: none;
    z-index: 5;
    display: none;
}

.logo-zone-overlay.visible {
    display: block;
}

.text-content {
    color: #323232;
    white-space: pre-wrap; /* Сохраняем переносы строк и переносим по ширине */
    word-wrap: break-word; /* Разрешаем перенос длинных слов */
    word-break: break-word; /* Разрешаем перенос слов */
    overflow-wrap: break-word; /* Разрешаем перенос слов */
    pointer-events: auto; /* Разрешаем клики для редактирования */
    overflow: visible; /* Текст может выходить за границы */
    width: 100%; /* Занимает всю ширину контейнера */
    outline: none; /* Убираем стандартный outline */
    min-height: 1em; /* Минимальная высота для пустого текста */
}

.text-content:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.text-layer.editing {
    border-color: #007bff;
    border-style: solid;
}

/* Resize handle для изменения размера текстового слоя */
.text-layer .resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    background: #007bff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: nesw-resize;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: all;
}

.text-layer:hover .resize-handle {
    opacity: 1;
}

.text-layer.resizing .resize-handle {
    opacity: 1;
    background: #0056b3;
}

.controls-panel {
    background: white;
    border-top: 1px solid #ddd;
    padding: 16px;
    overflow-y: auto;
    max-height: 40vh;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.control-group {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.control-group:last-child {
    border-bottom: none;
}

.control-group h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.control-item {
    margin-bottom: 12px;
}

.control-item label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
}

.control-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.control-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

.control-item input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
}

.control-item input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
}

.btn-edit, .btn-primary, .btn-secondary {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 8px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-primary:active {
    background: #004085;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-edit {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-edit:hover {
    background: #e9ecef;
}

.control-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.control-actions button {
    flex: 1;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 90%;
    width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

#textEditArea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-actions button {
    flex: 1;
}

/* Адаптивность */
@media (max-width: 768px) {
    .controls-panel {
        max-height: 50vh;
    }
}







