:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f1f5f9;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --bg: #ffffff;
    --bg-light: #f8fafc;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light); /* Убрали фиолетовый градиент */
    min-height: 100vh;
    color: var(--text);
}

.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease-in-out;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.sidebar-content {
    padding: 24px 20px;
}

.config-section {
    margin-bottom: 32px;
}

.config-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.color-input {
    width: 100%;
    height: 40px;
    padding: 2px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.file-input {
    display: none;
}

.file-label {
    display: block;
    padding: 10px 16px;
    background: var(--secondary);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-label:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

#mobile-sidebar-toggle {
    display: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

#main-content-area {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-content {
    background: var(--bg-light);
    overflow-y: auto;
    position: relative;
    flex-grow: 1;
}

.toolbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.toolbar-title {
    font-size: 18px;
    font-weight: 600;
}

.preview-area {
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.preview-wrapper {
    width: 100%;
    max-width: 800px;
    flex-grow: 1;
    height: 100px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
}

#preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.form-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.generated-code {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.success-message {
    background: var(--success);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: none;
    width: 100%;
    max-width: 800px;
}

.success-message.show {
    display: block;
}

.catalog-item-preview {
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 8px;
    gap: 10px;
}

.catalog-item-preview img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.catalog-item-preview .info {
    flex-grow: 1;
}

.catalog-item-preview .name {
    font-weight: 600;
}

.catalog-item-preview .price {
    font-size: 12px;
    color: var(--text-light);
}

.catalog-item-preview .remove-catalog-item {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 20px;
}

.option-value-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.option-value-row input {
    flex-grow: 1;
}

.option-value-row .remove-option-value {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 20px;
}

.catalog-item-options {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
    padding-left: 15px;
}

.edit-mode-only {
    display: none;
}

.create-mode-only {
    display: block;
}

body.is-editing .edit-mode-only {
    display: block;
}

body.is-editing .create-mode-only {
    display: none;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
}

.remove-category-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 20px;
}

.catalog-item-category {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    background: #e0e7ff;
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-block;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 999;
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    #mobile-sidebar-toggle {
        display: inline-flex;
    }
    
    .toolbar .btn-primary {
        display: none;
    }
}
/* ================================== */
/* STYLES FOR FLOATING TEXT TOOLBAR   */
/* ================================== */
#text-editing-toolbar {
    position: fixed; /* Важно, чтобы он был поверх всего */
    top: 80px; /* Начальная позиция сверху */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 1001; /* Выше чем оверлей, если он был */
    display: none; /* Скрыт по умолчанию */
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

/* Класс, который делает тулбар видимым */
#text-editing-toolbar.visible {
    display: flex;
}

#text-editing-toolbar .toolbar-group {
    display: flex;
    flex-direction: column;
}

#text-editing-toolbar label {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

#text-editing-toolbar select,
#text-editing-toolbar input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-light);
}

#text-editing-toolbar input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 2px;
}

#text-editing-toolbar input[type="number"] {
    width: 70px;
}

/* ↓↓↓ ДОБАВЬТЕ ЭТО В КОНЕЦ СТИЛЕЙ ТУЛБАРА В styles.css ↓↓↓ */
#text-editing-toolbar .input-with-buttons {
    display: flex;
    align-items: center;
}

#text-editing-toolbar .input-with-buttons input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

#text-editing-toolbar .size-adjust-btn {
    width: 28px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    background-color: var(--bg-light);
    cursor: pointer;
    font-size: 18px;
    line-height: 30px;
    flex-shrink: 0;
}

#text-editing-toolbar .size-adjust-btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

#text-editing-toolbar .size-adjust-btn:hover {
    background-color: #e2e8f0;
}
/* styles.css -> добавьте в конец файла */

/* Стили для сворачиваемых секций */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 0; /* Небольшой отступ для удобства клика */
}

.collapsible-header h3 {
    margin-bottom: 0; /* Убираем стандартный отступ у заголовка */
}

.collapsible-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.collapsible-content {
    display: none; /* По умолчанию контент скрыт */
    padding-top: 16px; /* Отступ при открытии */
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* Когда секция открыта */
.collapsible-section.is-open .collapsible-content {
    display: block; /* Показываем контент */
}

.collapsible-section.is-open .collapsible-icon {
    transform: rotate(180deg); /* Переворачиваем стрелочку */
}
/* --- ДОБАВЬТЕ ЭТО В КОНЕЦ styles.css --- */
.catalog-item-preview .info {
    flex-grow: 1;
    min-width: 0; /* Fix for flexbox overflow */
}

.catalog-item-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-catalog-item,
.remove-catalog-item {
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    transition: background 0.2s;
}

.edit-catalog-item:hover {
    background: #dbeafe; /* Light blue */
    color: #2563eb;
}

.remove-catalog-item:hover {
    background: #fee2e2; /* Light red */
    color: #dc2626;
}
/* В конец файла styles.css */
.field-config-item {
    display: flex;
    align-items: center;
    gap: 12px;
}
.field-config-label {
    flex-grow: 1;
    font-size: 14px;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(4, 120, 87, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(4, 120, 87, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(4, 120, 87, 0); }
}
