
/* ---------- Base & design system ---------- */

:root {
    --color-primary: #059669;
    --color-primary-dark: #047857;
    --color-primary-light: #d1fae5;
    --color-background: #f5f7f8;
    --color-surface: #ffffff;
    --color-text: #172b2a;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-danger: #dc2626;
    --radius-card: 14px;
    --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.04);
}

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

body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
}

.container {
    width: min(100% - 2rem, 1000px);
    margin: 0 auto;
}

main {
    padding: 2.5rem 0 4rem;
}

/* ---------- Header ---------- */

.header {
    padding: 2rem 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.header h1 {
    font-size: clamp(1.8rem, 4vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--color-primary-dark);
}

.header p {
    margin-top: 0.25rem;
    color: var(--color-muted);
    font-size: 0.95rem;
}

/* ---------- Cards ---------- */

.card {
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.card h2 {
    margin-bottom: 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.section-header h2 {
    margin-bottom: 0;
}

/* ---------- Form controls ---------- */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

/* ---------- Buttons ---------- */

button {
    padding: 0.7rem 1rem;
    color: #334155;
    background: #eef2f6;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover {
    background: #e2e8f0;
}

button:active {
    transform: translateY(1px);
}

button:focus-visible {
    outline: 3px solid rgba(5, 150, 105, 0.35);
    outline-offset: 2px;
}

#addFieldButton {
    color: var(--color-primary-dark);
    background: var(--color-primary-light);
}

#addFieldButton:hover {
    background: #a7f3d0;
}

.generate-button {
    width: 100%;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    color: #ffffff;
    background: var(--color-primary);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.16);
}

.generate-button:hover {
    background: var(--color-primary-dark);
}

/* ---------- Dynamic field rows ---------- */

.field-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.85rem;
}

.field-row:last-child {
    margin-bottom: 0;
}

.field-row input,
.field-row select {
    min-width: 0;
}

.remove-field {
    color: var(--color-danger);
    background: #fef2f2;
    white-space: nowrap;
}

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

/* ---------- SQL output ---------- */

.output-section textarea {
    display: block;
    min-height: 320px;
    padding: 1rem;
    resize: vertical;
    background: #111827;
    color: #d1fae5;
    border: 1px solid #273449;
    border-radius: 10px;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    tab-size: 4;
}

.output-section textarea::placeholder {
    color: #94a3b8;
}

.output-section textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

/* ---------- Responsive layout ---------- */

@media (max-width: 600px) {
    .container {
        width: min(100% - 1.25rem, 1000px);
    }

    .header {
        padding: 1.5rem 0;
    }

    main {
        padding-top: 1.5rem;
    }

    .card {
        padding: 1.15rem;
        margin-bottom: 1rem;
    }

    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-header > div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .field-row {
        grid-template-columns: minmax(0, 1fr);
        padding: 1rem;
        border: 1px solid var(--color-border);
        border-radius: 10px;
        background: #fafcfc;
    }

    .remove-field {
        width: 100%;
    }

    .output-section textarea {
        min-height: 260px;
    }
}