/* =====================================================
   RESET E CONFIGURAÇÕES GERAIS
===================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #16a34a;
    --color-primary-dark: #15803d;
    --color-primary-soft: #dcfce7;

    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-danger-soft: #fee2e2;

    --color-warning: #d97706;
    --color-warning-soft: #fef3c7;

    --color-success: #16a34a;
    --color-success-soft: #dcfce7;

    --color-background: #f4f6f8;
    --color-card: #ffffff;
    --color-border: #e5e7eb;
    --color-border-dark: #d1d5db;

    --color-text: #111827;
    --color-text-secondary: #4b5563;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;

    --shadow-small:
        0 2px 8px
        rgba(15, 23, 42, 0.06);

    --shadow-medium:
        0 12px 32px
        rgba(15, 23, 42, 0.09);

    --radius-small: 8px;
    --radius-medium: 14px;
    --radius-large: 20px;

    --transition:
        0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--color-background);
    color: var(--color-text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    line-height: 1.5;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

/* =====================================================
   CABEÇALHO
===================================================== */

.checkout-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background:
        rgba(255, 255, 255, 0.96);
    border-bottom:
        1px solid
        var(--color-border);
    backdrop-filter: blur(14px);
}

.checkout-header-content {
    width: min(
        1180px,
        calc(100% - 32px)
    );
    min-height: 78px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkout-back-button {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border:
        1px solid
        var(--color-border);
    border-radius: 50%;
    background: #ffffff;
    color: var(--color-text);
    text-decoration: none;
    font-size: 24px;
    font-weight: 700;
    transition:
        background var(--transition),
        border-color var(--transition),
        transform var(--transition);
}

.checkout-back-button:hover {
    background: #f9fafb;
    border-color:
        var(--color-border-dark);
    transform:
        translateX(-2px);
}

.checkout-eyebrow {
    display: block;
    margin-bottom: 2px;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.checkout-header h1 {
    font-size: 23px;
    line-height: 1.2;
}

/* =====================================================
   PÁGINA PRINCIPAL
===================================================== */

.checkout-page {
    width: min(
        1180px,
        calc(100% - 32px)
    );
    margin: 0 auto;
    padding: 32px 0 64px;
}

.checkout-content {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        390px;
    gap: 28px;
    align-items: start;
}

.checkout-form-column,
.checkout-summary-column {
    min-width: 0;
}

.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* =====================================================
   CARREGAMENTO
===================================================== */

.checkout-loading {
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--color-text-muted);
    text-align: center;
}

.checkout-loading-spinner {
    width: 46px;
    height: 46px;
    border:
        4px solid
        #dcfce7;
    border-top-color:
        var(--color-primary);
    border-radius: 50%;
    animation:
        checkout-spin
        0.8s linear infinite;
}

@keyframes checkout-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   CARTÕES
===================================================== */

.checkout-card,
.checkout-summary-card {
    background: var(--color-card);
    border:
        1px solid
        var(--color-border);
    border-radius:
        var(--radius-large);
    box-shadow:
        var(--shadow-small);
}

.checkout-card {
    padding: 26px;
}

.checkout-summary-card {
    position: sticky;
    top: 104px;
    padding: 24px;
    box-shadow:
        var(--shadow-medium);
}

/* =====================================================
   TÍTULOS DAS SEÇÕES
===================================================== */

.checkout-section-heading {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.checkout-step {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background:
        var(--color-primary-soft);
    color:
        var(--color-primary-dark);
    font-size: 15px;
    font-weight: 800;
}

.checkout-section-heading h2 {
    margin-bottom: 4px;
    font-size: 20px;
    line-height: 1.25;
}

.checkout-section-heading p {
    color:
        var(--color-text-muted);
    font-size: 14px;
}

/* =====================================================
   CAMPOS
===================================================== */

.checkout-fields {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.checkout-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.checkout-field-full {
    grid-column: 1 / -1;
}

.checkout-field label,
.checkout-coupon-label {
    color:
        var(--color-text-secondary);
    font-size: 14px;
    font-weight: 700;
}

.checkout-field input,
.checkout-field textarea,
.checkout-field select,
.checkout-coupon-input {
    width: 100%;
    border:
        1px solid
        var(--color-border-dark);
    border-radius:
        var(--radius-small);
    background: #ffffff;
    color: var(--color-text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        background var(--transition);
}

.checkout-field input,
.checkout-field select,
.checkout-coupon-input {
    height: 48px;
    padding: 0 14px;
}

.checkout-field textarea {
    min-height: 110px;
    padding: 13px 14px;
    resize: vertical;
}

.checkout-field input::placeholder,
.checkout-field textarea::placeholder,
.checkout-coupon-input::placeholder {
    color:
        var(--color-text-light);
}

.checkout-field input:focus,
.checkout-field textarea:focus,
.checkout-field select:focus,
.checkout-coupon-input:focus {
    border-color:
        var(--color-primary);
    box-shadow:
        0 0 0 4px
        rgba(22, 163, 74, 0.12);
}

.checkout-field input.is-invalid,
.checkout-field textarea.is-invalid,
.checkout-field select.is-invalid {
    border-color:
        var(--color-danger);
    background:
        #fffafa;
    box-shadow:
        0 0 0 4px
        rgba(220, 38, 38, 0.08);
}

.checkout-field-error {
    color:
        var(--color-danger);
    font-size: 12px;
    font-weight: 700;
}

/* =====================================================
   PAGAMENTO
===================================================== */

.payment-options {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.payment-option {
    position: relative;
    min-height: 92px;
    display: flex;
    align-items: center;
    border:
        1px solid
        var(--color-border);
    border-radius:
        var(--radius-medium);
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.payment-option:hover {
    border-color:
        var(--color-primary);
    transform:
        translateY(-1px);
}

.payment-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.payment-option-content {
    width: 100%;
    min-height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px;
}

.payment-option-content strong {
    margin-bottom: 3px;
    font-size: 15px;
}

.payment-option-content small {
    color:
        var(--color-text-muted);
    font-size: 12px;
}

.payment-option:has(input:checked) {
    border-color:
        var(--color-primary);
    background:
        var(--color-primary-soft);
    box-shadow:
        0 0 0 3px
        rgba(22, 163, 74, 0.1);
}

.payment-option:has(input:checked)
.payment-option-content strong {
    color:
        var(--color-primary-dark);
}

/* =====================================================
   RESUMO DO PEDIDO
===================================================== */

.checkout-summary-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom:
        1px solid
        var(--color-border);
}

.checkout-summary-heading h2 {
    font-size: 20px;
}

.checkout-store-name {
    max-width: 150px;
    color:
        var(--color-primary-dark);
    font-size: 13px;
    font-weight: 800;
    text-align: right;
    word-break: break-word;
}

/* =====================================================
   ITENS
===================================================== */

.checkout-items {
    max-height: 340px;
    margin: 18px 0;
    padding-right: 4px;
    overflow-y: auto;
}

.checkout-items::-webkit-scrollbar {
    width: 5px;
}

.checkout-items::-webkit-scrollbar-thumb {
    background:
        var(--color-border-dark);
    border-radius: 999px;
}

.checkout-item {
    display: grid;
    grid-template-columns:
        52px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 13px 0;
    border-bottom:
        1px solid
        #f0f1f3;
}

.checkout-item:last-child {
    border-bottom: none;
}

.checkout-item-image {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius:
        var(--radius-small);
    background: #f3f4f6;
    overflow: hidden;
    font-size: 23px;
}

.checkout-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.checkout-item-content {
    min-width: 0;
}

.checkout-item-name {
    margin-bottom: 2px;
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkout-item-quantity {
    color:
        var(--color-text-muted);
    font-size: 12px;
}

.checkout-item-total {
    font-size: 14px;
    white-space: nowrap;
}

/* =====================================================
   CUPOM
===================================================== */

.checkout-coupon-section {
    margin: 20px 0;
    padding: 18px;
    border:
        1px dashed
        var(--color-border-dark);
    border-radius:
        var(--radius-medium);
    background:
        linear-gradient(
            135deg,
            #ffffff,
            #f8fff9
        );
}

.checkout-coupon-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.checkout-coupon-heading h3 {
    margin-bottom: 2px;
    font-size: 16px;
}

.checkout-coupon-heading p {
    color:
        var(--color-text-muted);
    font-size: 12px;
}

.checkout-coupon-icon {
    font-size: 24px;
}

.checkout-coupon-form {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.checkout-coupon-controls {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr) auto;
    gap: 8px;
}

.checkout-coupon-input {
    min-width: 0;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.checkout-coupon-button {
    min-width: 92px;
    height: 48px;
    padding: 0 16px;
    border: none;
    border-radius:
        var(--radius-small);
    background:
        var(--color-primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    transition:
        background var(--transition),
        transform var(--transition),
        opacity var(--transition);
}

.checkout-coupon-button:hover {
    background:
        var(--color-primary-dark);
}

.checkout-coupon-button:active {
    transform: scale(0.98);
}

.checkout-coupon-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.checkout-coupon-message {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius:
        var(--radius-small);
    font-size: 13px;
    font-weight: 700;
}

.checkout-coupon-message.is-success {
    background:
        var(--color-success-soft);
    color:
        var(--color-success);
}

.checkout-coupon-message.is-error {
    background:
        var(--color-danger-soft);
    color:
        var(--color-danger);
}

.checkout-coupon-message.is-warning {
    background:
        var(--color-warning-soft);
    color:
        var(--color-warning);
}

.checkout-coupon-applied {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border:
        1px solid
        #bbf7d0;
    border-radius:
        var(--radius-small);
    background:
        var(--color-success-soft);
}

.checkout-coupon-applied-content {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkout-coupon-applied-icon {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background:
        var(--color-primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
}

.checkout-coupon-applied-content div {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.checkout-coupon-applied-content span {
    color:
        var(--color-text-secondary);
    font-size: 11px;
}

.checkout-coupon-applied-content strong {
    color:
        var(--color-primary-dark);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkout-coupon-remove-button {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color:
        var(--color-danger);
    font-size: 12px;
    font-weight: 800;
    text-decoration: underline;
}

.checkout-coupon-remove-button:hover {
    color:
        var(--color-danger-dark);
}

/* =====================================================
   VALORES
===================================================== */

.checkout-values {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 0;
    border-top:
        1px solid
        var(--color-border);
    border-bottom:
        1px solid
        var(--color-border);
}

.checkout-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color:
        var(--color-text-secondary);
    font-size: 14px;
}

.checkout-value-row strong {
    color:
        var(--color-text);
    white-space: nowrap;
}

.checkout-discount-row {
    color:
        var(--color-success);
}

.checkout-discount-row strong {
    color:
        var(--color-success);
}

.checkout-free-delivery-message {
    padding: 9px 11px;
    border-radius:
        var(--radius-small);
    background:
        var(--color-success-soft);
    color:
        var(--color-primary-dark);
    font-size: 12px;
    font-weight: 700;
}

.checkout-total-row {
    margin-top: 4px;
    padding-top: 15px;
    border-top:
        1px dashed
        var(--color-border-dark);
    color:
        var(--color-text);
    font-size: 17px;
    font-weight: 800;
}

.checkout-total-row strong {
    color:
        var(--color-primary-dark);
    font-size: 21px;
}

/* =====================================================
   BOTÃO DE CONFIRMAÇÃO
===================================================== */

.checkout-submit-button {
    width: 100%;
    min-height: 54px;
    margin-top: 20px;
    border: none;
    border-radius:
        var(--radius-medium);
    background:
        var(--color-primary);
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    box-shadow:
        0 9px 22px
        rgba(22, 163, 74, 0.24);
    transition:
        background var(--transition),
        transform var(--transition),
        box-shadow var(--transition),
        opacity var(--transition);
}

.checkout-submit-button:hover {
    background:
        var(--color-primary-dark);
    transform:
        translateY(-1px);
    box-shadow:
        0 12px 27px
        rgba(22, 163, 74, 0.3);
}

.checkout-submit-button:active {
    transform:
        translateY(0);
}

.checkout-submit-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.checkout-submit-button.is-loading {
    position: relative;
    color: transparent;
}

.checkout-submit-button.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin:
        -11px 0 0 -11px;
    border:
        3px solid
        rgba(255, 255, 255, 0.45);
    border-top-color:
        #ffffff;
    border-radius: 50%;
    animation:
        checkout-spin
        0.75s linear infinite;
}

.checkout-security-message {
    margin-top: 13px;
    color:
        var(--color-text-muted);
    font-size: 11px;
    line-height: 1.45;
    text-align: center;
}

/* =====================================================
   MENSAGEM GLOBAL
===================================================== */

.checkout-message {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100;
    width: min(
        460px,
        calc(100% - 32px)
    );
    padding: 14px 18px;
    border-radius:
        var(--radius-medium);
    box-shadow:
        0 18px 45px
        rgba(15, 23, 42, 0.2);
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    transform:
        translateX(-50%);
}

.checkout-message.is-success {
    background:
        var(--color-success);
}

.checkout-message.is-error {
    background:
        var(--color-danger);
}

.checkout-message.is-warning {
    background:
        var(--color-warning);
}

/* =====================================================
   CARRINHO VAZIO E SUCESSO
===================================================== */

.checkout-empty {
    width: min(
        560px,
        100%
    );
    margin: 60px auto;
    padding: 48px 32px;
    border:
        1px solid
        var(--color-border);
    border-radius:
        var(--radius-large);
    background: #ffffff;
    box-shadow:
        var(--shadow-medium);
    text-align: center;
}

.checkout-empty-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background:
        var(--color-primary-soft);
    color:
        var(--color-primary-dark);
    font-size: 34px;
    font-weight: 900;
}

.checkout-empty h2 {
    margin-bottom: 10px;
    font-size: 25px;
}

.checkout-empty p {
    margin: 0 auto 24px;
    max-width: 420px;
    color:
        var(--color-text-muted);
}

.checkout-empty-button {
    min-height: 48px;
    padding: 0 22px;
    border: none;
    border-radius:
        var(--radius-medium);
    background:
        var(--color-primary);
    color: #ffffff;
    font-weight: 800;
    transition:
        background var(--transition),
        transform var(--transition);
}

.checkout-empty-button:hover {
    background:
        var(--color-primary-dark);
    transform:
        translateY(-1px);
}

/* =====================================================
   ESTADO DE ENVIO
===================================================== */

body.checkout-submitting {
    cursor: progress;
}

body.checkout-submitting
.checkout-form {
    pointer-events: none;
    opacity: 0.75;
}

/* =====================================================
   TABLETS
===================================================== */

@media (
    max-width: 980px
) {
    .checkout-content {
        grid-template-columns: 1fr;
    }

    .checkout-summary-column {
        order: -1;
    }

    .checkout-summary-card {
        position: static;
    }

    .checkout-items {
        max-height: none;
    }
}

/* =====================================================
   CELULARES
===================================================== */

@media (
    max-width: 680px
) {
    .checkout-header-content,
    .checkout-page {
        width:
            calc(100% - 24px);
    }

    .checkout-header-content {
        min-height: 68px;
    }

    .checkout-header h1 {
        font-size: 19px;
    }

    .checkout-eyebrow {
        font-size: 10px;
    }

    .checkout-back-button {
        width: 40px;
        height: 40px;
    }

    .checkout-page {
        padding-top: 18px;
        padding-bottom: 40px;
    }

    .checkout-content {
        gap: 16px;
    }

    .checkout-card,
    .checkout-summary-card {
        border-radius:
            var(--radius-medium);
    }

    .checkout-card {
        padding: 20px 16px;
    }

    .checkout-summary-card {
        padding: 19px 16px;
    }

    .checkout-section-heading {
        margin-bottom: 20px;
    }

    .checkout-section-heading h2 {
        font-size: 18px;
    }

    .checkout-fields {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .checkout-field-full {
        grid-column: auto;
    }

    .payment-options {
        grid-template-columns: 1fr;
    }

    .payment-option,
    .payment-option-content {
        min-height: 70px;
    }

    .checkout-summary-heading {
        flex-direction: column;
        gap: 6px;
    }

    .checkout-store-name {
        max-width: none;
        text-align: left;
    }

    .checkout-coupon-controls {
        grid-template-columns: 1fr;
    }

    .checkout-coupon-button {
        width: 100%;
    }

    .checkout-coupon-applied {
        align-items: flex-start;
    }

    .checkout-item {
        grid-template-columns:
            46px minmax(0, 1fr);
    }

    .checkout-item-image {
        width: 46px;
        height: 46px;
    }

    .checkout-item-total {
        grid-column: 2;
        justify-self: start;
        margin-top: -6px;
        color:
            var(--color-primary-dark);
    }

    .checkout-empty {
        margin-top: 24px;
        padding: 38px 20px;
    }

    .checkout-message {
        bottom: 16px;
    }
}

/* =====================================================
   TELAS MUITO PEQUENAS
===================================================== */

@media (
    max-width: 380px
) {
    .checkout-header-content,
    .checkout-page {
        width:
            calc(100% - 18px);
    }

    .checkout-summary-card,
    .checkout-card {
        padding-left: 13px;
        padding-right: 13px;
    }

    .checkout-value-row {
        gap: 10px;
        font-size: 13px;
    }

    .checkout-total-row strong {
        font-size: 19px;
    }
}