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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-bottom: 30px;
    width: 100%;
}

.form-section,
.preview-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

.form-section h2,
.preview-section h2 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 20px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[readonly],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.form-group input[readonly] {
    background-color: #f5f7fb;
    color: #667eea;
    font-weight: 600;
}

.form-group.required label::after {
    content: ' *';
    color: #e74c3c;
}

.form-group.error input,
.form-group.error textarea {
    border-color: #e74c3c;
}

.error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 4px;
}

/* Repeatable Sections */
.repeatable-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    position: relative;
}

.repeatable-action-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 0 0;
    margin-top: 12px;
    background: rgba(249, 249, 249, 0.96);
    border-top: 1px solid #ddd;
    z-index: 1;
}

.repeatable-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.repeatable-section-header h3 {
    font-size: 16px;
    color: #333;
    margin: 0;
}

.repeatable-button-group {
    display: flex;
    gap: 3px;
    align-items: center;
}

.button-overflow {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
    position: relative !important;
    overflow: visible !important;
    min-width: 0 !important;
}

.button-overflow > .btn {
    flex: none !important;
    white-space: nowrap !important;
}

.overflow-menu-toggle {
    display: none;
}

.overflow-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    max-width: min(280px, 100vw);
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    z-index: 1200;
    padding: 6px 0;
    display: none;
    flex-direction: column;
    align-items: flex-end;
}

.overflow-menu.open {
    display: flex;
}

.overflow-menu-item {
    display: block;
    width: auto;
    padding: 0;
    margin-bottom: 8px;
    border: none;
    background: transparent;
    text-align: right;
    font: inherit;
    color: #333;
    cursor: pointer;
}

.overflow-menu-item.btn {
    display: inline-flex;
    width: auto;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    padding: 3px 6px;
    margin: 0 8px 8px;
}

.overflow-menu-item.btn:last-child {
    margin-bottom: 0;
}

.overflow-menu-item:hover,
.overflow-menu-item:focus {
    background: #f4f6f8;
}

.overflow-menu-item:disabled {
    color: #999;
    cursor: not-allowed;
}

.bulk-add-menu {
    position: relative;
    display: flex;
}

.bulk-toggle {
    padding: 8px 10px;
    min-width: auto;
}

.bulk-options {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 100px;
}

.bulk-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: white;
    text-align: left;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.bulk-option:hover {
    background: #f0f0f0;
}

.bulk-option:first-child {
    border-radius: 3px 3px 0 0;
}

.bulk-option:last-child {
    border-radius: 0 0 3px 3px;
}

.repeatable-item {
    background: white;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.repeatable-item:last-child {
    margin-bottom: 0;
}

.repeatable-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.repeatable-item-header button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.repeatable-item-header button:hover {
    background: #c0392b;
}

/* Button Styles */
.button-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn {
    padding: 3px 6px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5568d3;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 2px 3px;
    font-size: 11px;
}

/* Preview Section */
.preview-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.email-consent-note {
    background: #fff8e6;
    border: 1px solid #f2d38a;
    border-radius: 6px;
    color: #6a4b00;
    font-size: 13px;
    padding: 12px 14px;
}

.sticky-actions {
    position: sticky;
    top: 16px;
    z-index: 20;
    padding: 12px;
    margin: 0;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(221, 221, 221, 0.9);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.sticky-actions .btn {
    box-shadow: none;
}

.preview-content {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 400px;
    display: block;
}

/* Remove nested preview content styles since they're now in the iframe */

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }

    header,
    footer,
    .button-group,
    .preview-controls {
        display: none;
    }

    .preview-section {
        box-shadow: none;
        padding: 0;
    }

    .preview-content {
        border: none;
        padding: 0;
    }
}

footer {
    background: #f9f9f9;
    padding: 15px 20px;
    border-radius: 8px;
    text-align: center;
    color: #666;
    font-size: 12px;
    width: 100%;
}

.toast-container {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(100%, 360px);
    z-index: 1200;
    pointer-events: none;
}

.toast-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
    background: rgba(15, 23, 42, 0.92);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    animation: toastIn 220ms ease forwards;
    pointer-events: auto;
}

.toast-message--success {
    background: #2f855a;
}

.toast-message--error {
    background: #c53030;
}

.toast-message--info {
    background: #1a202c;
}

.toast-message button {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast-message[hidden] {
    display: none !important;
}

@keyframes toastIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.55);
    padding: 18px;
}

.confirm-overlay[hidden] {
    display: none;
}

.confirm-dialog {
    width: min(100%, 420px);
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
}

.confirm-dialog p {
    margin: 0 0 18px;
    color: #1f2937;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.confirm-actions button,
.prompt-actions button {
    min-width: 90px;
}

.prompt-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font: inherit;
    box-sizing: border-box;
    margin-bottom: 18px;
}

.prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

@media (max-width: 1080px) {
    .toast-container {
        right: 12px;
        bottom: 12px;
        width: min(100%, 320px);
    }
}

.privacy-link {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.privacy-link:hover {
    text-decoration: underline;
}

.footer-separator {
    margin: 0 10px;
    color: #bbb;
}

.privacy-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

.privacy-page header {
    margin-bottom: 24px;
}

.privacy-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.privacy-card h2 {
    color: #667eea;
    margin-bottom: 12px;
}

.privacy-card p,
.privacy-card li {
    margin-bottom: 10px;
    line-height: 1.7;
}

.privacy-card ul {
    padding-left: 20px;
}
