:root {
    --bg: #1c5e67;
    --bg-deep: #103f46;
    --card-bg: #ffffff;
    --surface-soft: #f4f8f9;
    --text: #0d2e34;
    --muted: #4d6670;
    --accent: #f9c647;
    --accent-dark: #dea728;
    --danger: #b23c4b;
    --line: #d5e1e5;
    --success: #1c8b56;
    --radius: 16px;
    --shadow-lg: 0 18px 38px rgba(8, 27, 31, 0.2);
    --shadow-sm: 0 8px 18px rgba(8, 27, 31, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Poppins", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 14% 16%, rgba(255, 255, 255, 0.14), transparent 44%),
        radial-gradient(circle at 88% 8%, rgba(249, 198, 71, 0.3), transparent 48%),
        linear-gradient(160deg, #215d64 0%, var(--bg) 54%, var(--bg-deep) 100%);
    min-height: 100vh;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.06), transparent 22%);
    z-index: 0;
}

.ordine-page {
    width: min(1140px, 100%);
    margin: 0 auto;
    padding: 24px 16px 34px;
    position: relative;
    z-index: 1;
}

.ordine-header {
    color: #ffffff;
    margin-bottom: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
    margin-bottom: 10px;
    opacity: 0.96;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.back-link:hover {
    opacity: 1;
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.16);
}

.ordine-header h1 {
    margin: 0;
    font-family: "Londrina Solid", cursive;
    font-size: clamp(42px, 5.4vw, 60px);
    line-height: 1;
    letter-spacing: 0.9px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.ordine-header p {
    margin: 10px auto 0;
    font-size: 16px;
    font-weight: 500;
    opacity: 0.96;
    max-width: 700px;
}

.checkout-empty {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 26px 22px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    margin-bottom: 14px;
}

.checkout-empty[hidden] {
    display: none !important;
}

.checkout-empty h2 {
    margin: 0 0 12px;
    font-family: "Londrina Solid", cursive;
    font-size: 34px;
    color: var(--bg);
}

.checkout-empty p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 15px;
}

.checkout-content {
    display: grid;
    gap: 16px;
}

.checkout-content[hidden] {
    display: none !important;
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #ffffff 100%);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-lg);
}

.card h2 {
    margin: 0 0 2px;
    font-family: "Londrina Solid", cursive;
    font-size: clamp(30px, 3vw, 38px);
    line-height: 1;
    color: var(--bg);
    letter-spacing: 0.4px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.order-rows {
    display: grid;
    gap: 12px;
}

.order-row {
    border: 1px solid #dbe6ea;
    border-radius: 14px;
    padding: 12px;
    background: var(--surface-soft);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.order-row:hover {
    border-color: #c5d6dc;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.order-row__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.order-row__name {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.order-row__unit {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.order-row__details {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 3px;
}

.order-row__detail {
    font-size: 12px;
    color: #305861;
}

.order-row__detail span {
    font-weight: 700;
}

.order-row__subtotal {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--bg);
}

.order-row__actions {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
}

.checkout-qty {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px;
    background: transparent;
    flex-shrink: 0;
}

.checkout-qty button {
    border: none;
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 999px;
    background: var(--bg);
    color: #ffffff;
    font-family: "Londrina Solid", cursive;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 28px;
    box-sizing: border-box;
}

.checkout-qty button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.checkout-qty span {
    min-width: 22px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.order-total-row {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #d7e3e7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
}

.order-total-row strong {
    color: #134f57;
    letter-spacing: 0.4px;
}

.button {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    min-height: 42px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.button:not(:disabled):hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(180deg, #ffd972 0%, var(--accent) 100%);
    color: #111111;
    box-shadow: 0 8px 18px rgba(180, 132, 18, 0.26);
}

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

.button-secondary {
    background: #eaf1f4;
    color: #183f46;
}

.button-ghost {
    background: #ffffff;
    border: 1px solid #cddce2;
    color: #194048;
}

.button-whatsapp {
    background: linear-gradient(180deg, #2fd46b 0%, #22c35e 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(31, 139, 86, 0.28);
}

.button-danger {
    background: linear-gradient(180deg, #cf5262 0%, var(--danger) 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(178, 60, 75, 0.28);
}

.button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.privacy-copy {
    margin: 8px 0 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.field {
    display: block;
    margin-bottom: 12px;
}

.field > span {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #173e46;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid #cfdee3;
    border-radius: 12px;
    padding: 12px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background-color: #f9fcfd;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(28, 94, 103, 0.68);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(28, 94, 103, 0.16);
}

.field-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.field-checkbox input {
    width: auto;
    margin-top: 2px;
}

.field-checkbox span {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
}

.field-error {
    display: block;
    min-height: 16px;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--danger);
}

.form-actions,
.message-actions {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.message-hint {
    margin: 8px 0 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.generated-message {
    width: 100%;
    min-height: 240px;
    border: 1px solid #cfdee3;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
    font-family: inherit;
    color: var(--text);
    background: #f9fcfd;
}

.message-feedback {
    min-height: 20px;
    margin: 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.message-feedback.is-success {
    color: var(--success);
}

.message-feedback.is-error {
    color: var(--danger);
}

.whatsapp-fallback {
    margin-top: 10px;
    color: var(--bg);
    word-break: break-all;
    display: inline-block;
}

.order-empty-inline {
    margin: 6px 0;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

body.overlay-open {
    overflow: hidden;
}

.whatsapp-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(8, 27, 31, 0.62);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.whatsapp-overlay[hidden] {
    display: none !important;
}

.whatsapp-overlay__panel {
    width: min(460px, 100%);
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.74);
    padding: 20px;
    text-align: center;
    box-shadow: 0 24px 42px rgba(0, 0, 0, 0.28);
}

.whatsapp-overlay__panel h2 {
    margin: 0;
    font-size: 30px;
    line-height: 1;
    font-family: "Londrina Solid", cursive;
    color: var(--bg);
}

.whatsapp-overlay__panel p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.whatsapp-overlay__actions {
    margin-top: 16px;
    display: grid;
    gap: 8px;
}

.whatsapp-overlay__home {
    margin-top: 10px;
    width: 100%;
}

.whatsapp-overlay__close {
    margin-top: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(8, 27, 31, 0.66);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

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

.confirm-overlay__panel {
    width: min(420px, 100%);
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.74);
    padding: 20px;
    text-align: center;
    box-shadow: 0 24px 42px rgba(0, 0, 0, 0.28);
}

.confirm-overlay__panel h2 {
    margin: 0;
    font-size: 30px;
    line-height: 1;
    font-family: "Londrina Solid", cursive;
    color: var(--bg);
}

.confirm-overlay__panel p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.confirm-overlay__actions {
    margin-top: 16px;
    display: grid;
    gap: 8px;
}

@media (min-width: 900px) {
    .ordine-page {
        padding: 34px 24px 40px;
    }

    .checkout-content {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "order form"
            "message message";
        gap: 18px;
    }

    .order-card { grid-area: order; }
    .form-card { grid-area: form; }
    .message-card { grid-area: message; }

    .message-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .whatsapp-overlay__actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .confirm-overlay__actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .ordine-page {
        padding: 18px 12px 24px;
    }

    .ordine-header h1 {
        font-size: 44px;
    }

    .ordine-header p {
        font-size: 14px;
        max-width: 95%;
    }

    .card {
        padding: 14px;
    }

    .card h2 {
        font-size: 31px;
    }

    .order-row__actions {
        flex-wrap: wrap;
    }

    .order-row__actions .button {
        width: 100%;
    }

    .generated-message {
        min-height: 210px;
    }
}
