/* ===== WEB-TO-PRINT РЕДАКТОР ===== */

/* ===== ФОРМЫ НАСТРОЕК БЛОКОВ ===== */
.settings-form {
    max-width: 600px;
    margin: 20px 0;
}
.settings-form .form-group {
    margin-bottom: 20px;
}
.settings-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
    font-size: var(--fs-sm);
}
.settings-form .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: var(--fs-base);
    background: #fff;
}
.settings-form .form-control:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,107,43,0.1);
}
.settings-form .form-text {
    display: block;
    margin-top: 6px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.settings-form .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.preview-section { background: var(--bg-soft); }

/* Заглушка для блока preview без пресета */
.preview-placeholder {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border: 2px dashed var(--accent-border);
    border-radius: 8px;
    color: var(--text-muted);
}
.preview-placeholder h2 {
    margin: 0 0 10px;
    font-size: var(--fs-xl);
    color: var(--text);
}
.preview-placeholder p {
    margin: 0 0 15px;
    font-size: var(--fs-sm);
}
.preview-placeholder .admin-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.preview-placeholder .admin-link a:hover {
    text-decoration: underline;
}

.preview-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: flex-start;
}
@media (max-width: 900px) { .preview-layout { grid-template-columns: 1fr; } }

.preview-left { display: flex; flex-direction: column; gap: 14px; }

/* Холст */
.preview-canvas-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.canvas-container-outer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e8e8e8;
    min-height: 260px;
    padding: 20px;
}
.canvas-container-outer::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,0,0,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}
.canvas-size-hint {
    position: absolute;
    bottom: 6px; right: 8px;
    font-size: 10px; color: #999;
    background: rgba(255,255,255,.8);
    padding: 1px 6px;
    border-radius: 3px;
}

/* Тулбар */
.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #FAFAFA;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    min-height: 48px;
}
.toolbar-group {
    display: flex; align-items: center; gap: 4px;
    padding-right: 8px;
    border-right: 1px solid #E0E0E0;
}
.toolbar-group:last-child { border-right: none; }
.toolbar-btn {
    width: 30px; height: 30px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, border-color 0.12s;
    flex-shrink: 0;
}
.toolbar-btn:hover { background: var(--accent-light); border-color: var(--accent); }
.toolbar-btn-danger:hover { background: #FEE2E2; border-color: var(--error); color: var(--error); }
.toolbar-select {
    height: 30px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 11px; padding: 0 4px;
    max-width: 130px; background: #fff;
}
.toolbar-input-num {
    width: 46px; height: 30px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 12px; text-align: center; padding: 0 2px;
}
.toolbar-color {
    width: 30px; height: 30px;
    border: 1px solid var(--border); border-radius: 4px;
    padding: 2px; cursor: pointer; background: none;
}

/* Превью */
.live-preview-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.live-preview-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}
.live-preview-title { font-size: 12px; font-weight: 600; }
.live-preview-badge {
    font-size: 10px; font-weight: 600;
    padding: 2px 8px;
    background: var(--accent-light); color: var(--accent);
    border-radius: 20px; border: 1px solid var(--accent-border);
}
.live-preview-img-wrap {
    position: relative;
    display: flex; justify-content: center;
    padding: 16px; background: #f0f0f0;
}
.live-preview-img {
    max-width: 100%; max-height: 300px;
    object-fit: contain;
    border: 1px solid var(--border); border-radius: 4px;
    background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.live-preview-overlay {
    position: absolute; bottom: 20px; right: 20px;
    background: rgba(0,0,0,.25); color: rgba(255,255,255,.8);
    font-size: 9px; padding: 2px 6px; border-radius: 3px;
    pointer-events: none;
}
.live-preview-hint {
    padding: 8px 14px;
    font-size: 11px; color: var(--text-hint); text-align: center;
    border-top: 1px solid var(--border); background: var(--bg-soft);
}

/* Панель */
.preview-panel { display: flex; flex-direction: column; gap: 10px; }
.panel-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
}
.panel-section-title {
    font-size: 10px; font-weight: 700;
    color: var(--text-hint);
    text-transform: uppercase; letter-spacing: .08em;
    margin-bottom: 10px;
}

/* Шаблоны */
.template-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.template-category-label {
    font-size: 9px; color: var(--text-hint);
    text-transform: uppercase; letter-spacing: .06em;
    margin: 8px 0 5px;
}
.template-thumb {
    border: 2px solid var(--border); border-radius: var(--radius-md);
    padding: 5px; cursor: pointer; text-align: center;
    transition: border-color .15s, box-shadow .15s;
}
.template-thumb:hover { border-color: var(--accent); }
.template-thumb.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255,107,43,.12);
    background: var(--accent-light);
}
.template-thumb img,
.template-thumb-placeholder { width: 100%; aspect-ratio: 1; object-fit: contain; }
.template-thumb-placeholder svg { width: 100%; height: auto; }
.template-thumb-label { font-size: 9px; color: var(--text-muted); margin-top: 3px; line-height: 1.2; }

/* Добавление объектов */
.add-objects-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* Ассеты */
.assets-panel { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.assets-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 10px; background: var(--bg-soft);
    font-size: 11px; font-weight: 600;
}
.assets-panel-close { background: none; border: none; cursor: pointer; font-size: 14px; color: #999; }
.assets-grid {
    display: grid; grid-template-columns: repeat(4,1fr);
    gap: 4px; padding: 6px;
    max-height: 180px; overflow-y: auto;
}
.asset-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 5px 3px;
    border: 1px solid var(--border); border-radius: 4px;
    cursor: pointer; transition: background .12s;
}
.asset-item:hover { background: var(--accent-light); border-color: var(--accent); }
.asset-item svg { width: 28px; height: 28px; }
.asset-item span { font-size: 7px; color: #999; text-align: center; line-height: 1.2; }

/* Размеры */
.size-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 5px; }
.size-btn {
    padding: 7px 5px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: #fff; font-size: 10px; font-weight: 600;
    cursor: pointer; text-align: center;
    transition: all .12s; white-space: nowrap;
}
.size-btn:hover  { border-color: var(--accent); color: var(--accent); }
.size-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.size-btn-custom { border-style: dashed; color: var(--text-hint); }

/* Режим tabs */
.preview-mode-tabs {
    display: flex; gap: 3px;
    background: var(--bg-section); border-radius: var(--radius-md);
    padding: 3px; margin-bottom: 10px;
}
.preview-mode-tab {
    flex: 1; padding: 7px; font-size: 12px; font-weight: 500;
    color: var(--text-muted); background: transparent;
    border: none; border-radius: 4px; cursor: pointer; transition: all .12s;
}
.preview-mode-tab.active {
    background: var(--bg); color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Ошибка */
.editor-error {
    margin-top: 10px; padding: 10px 14px;
    background: #FEE2E2; color: var(--error);
    border-radius: var(--radius-md); font-size: 12px;
}

/* ===== СТИЛИ ДЛЯ ПРЕСЕТА ШТАМПЫ И ПЕЧАТИ ===== */

/* Быстрые поля штампа */
.stamp-field {
    font-size: 14px;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.stamp-field:focus { border-left-color: var(--accent-dark); }

/* Заготовки прямоугольных штампов */
.template-thumb .template-thumb-placeholder[style*="aspect-ratio"] {
    height: auto;
}

/* ===== SVG ПРЕВЬЮ (режим шаблонов) ===== */
.svg-preview-outer {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    min-height: 300px;
    padding: 24px;
}

/* SVG вставленный inline масштабируется через CSS */
.svg-preview-outer svg.stamp-svg-preview {
    max-width: 100%;
    max-height: 340px;
    width: auto;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.12));
}

.svg-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-hint);
    font-size: 13px;
}

.svg-loading,
.svg-error {
    color: var(--text-hint);
    font-size: 13px;
    padding: 40px;
    text-align: center;
}

.svg-preview-hint {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--text-hint);
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
}

/* ===== СЕТКА ШАБЛОНОВ ШТАМПОВ ===== */
.template-grid-stamps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.template-thumb-stamp {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}
.template-thumb-stamp:hover {
    border-color: var(--accent);
}
.template-thumb-stamp.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(255,107,43,0.12);
}
.template-thumb-stamp img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
}
.stamp-thumb-placeholder {
    position: relative;
    width: 100%;
}
.stamp-thumb-placeholder svg {
    width: 100%;
    height: auto;
}
.stamp-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 700;
    color: #DDD;
}
.template-thumb-name {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.2;
}

/* ===== СЕТКА ЗАГОТОВОК ПРЯМОУГОЛЬНЫХ ===== */
.template-grid-rect {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.template-thumb-rect {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.template-thumb-rect:hover { border-color: var(--accent); background: var(--accent-light); }
.template-thumb-rect.active { border-color: var(--accent); background: var(--accent-light); }
.rect-thumb-label { font-size: 11px; font-weight: 700; color: var(--text); }

/* ===== БЫСТРЫЙ ВВОД ===== */
.qi-form { display: flex; flex-direction: column; gap: 10px; }
.qi-field { display: flex; flex-direction: column; gap: 4px; }

/* ===== ФИНАЛЬНОЕ ПРЕВЬЮ ===== */
.final-preview-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 14px;
}
.final-preview-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--success);
    color: #fff;
}
.final-preview-title {
    font-size: 13px;
    font-weight: 700;
}
.final-preview-sub {
    font-size: 11px;
    opacity: 0.95;
}
.final-preview-img-wrap {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #f5f5f5;
}
.final-preview-img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ===== СТАТУС PDF ===== */
.pdf-status {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    display: none;
}
.pdf-status-loading {
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFE0B2;
}
.pdf-status-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}
.pdf-status-error {
    background: #FEE2E2;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

/* ===== КАРТОЧКА ПРЕВЬЮ ===== */
.preview-canvas-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.preview-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}
.preview-canvas-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}
.preview-size-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    border: 1px solid var(--accent-border);
}

/* ===== ПОЛЯ ВВОДА ===== */
.field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.field-input {
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font-base);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(233,30,99,0.12);
}
.field-hint {
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 4px;
}
