:root {
    --bg-editor: #f8fafc;
    --bg-panel: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    background: var(--bg-editor);
    color: var(--text-main);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.editor-panel {
    width: 450px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

.preview-panel {
    flex-grow: 1;
    background: #52525b;
    /* Neutral dark background for contrast */
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

/* Editor Header */
.editor-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions {
    display: flex;
    gap: 8px;
}

/* Scrollable Form Area */
.editor-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Form Sections */
.form-section {
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.section-header {
    padding: 12px 16px;
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.section-header:hover {
    background: #e2e8f0;
}

.section-body {
    padding: 16px;
    display: none;
    /* Hidden by default for accordion effect, handled by JS */
}

.section-body.open {
    display: block;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

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

/* Dynamic Lists */
.list-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    position: relative;
    background: #f8fafc;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: 4px;
}

.btn-remove:hover {
    background: #fee2e2;
}

.btn-add {
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

/* Primary Button */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Preview Iframe */
iframe#previewFrame {
    width: 210mm;
    /* A4 width */
    height: 297mm;
    /* A4 height */
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: none;
    transform: scale(0.9);
    /* Slight scale down to fit comfortably */
    transform-origin: top center;
    transition: transform 0.2s;
}

@media (max-width: 1200px) {
    iframe#previewFrame {
        transform: scale(0.7);
    }
}