/* ==========================================================================
   Tema "moderno" — fluxo de compra (carrinho, entrega, pagamento)
   ========================================================================== */
.tm-checkout {
    padding: clamp(20px, 4vw, 40px) 0 clamp(48px, 6vw, 80px);
}

.tm-muted {
    color: var(--tm-muted);
    font-weight: 400;
}

/* ---------- Etapas ---------- */
.tm-etapas {
    display: flex;
    justify-content: center;
    max-width: 720px;
    margin: 0 auto clamp(24px, 4vw, 40px);
    padding: 0;
    list-style: none;
}

.tm-etapas__item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--tm-muted);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.tm-etapas__item+.tm-etapas__item::before {
    content: "";
    position: absolute;
    top: 19px;
    right: calc(50% + 26px);
    left: calc(-50% + 26px);
    height: 2px;
    border-radius: 2px;
    background: var(--tm-line);
}

.tm-etapas__item.is-feito+.tm-etapas__item::before {
    background: var(--tm-primary);
}

.tm-etapas__bola {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--tm-bg-alt);
    border: 2px solid var(--tm-line);
    font-size: 14px;
}

.tm-etapas__item.is-feito .tm-etapas__bola {
    background: var(--tm-primary);
    border-color: var(--tm-primary);
    color: #fff;
}

.tm-etapas__item.is-atual {
    color: var(--tm-ink);
    font-weight: 700;
}

.tm-etapas__item.is-atual .tm-etapas__bola {
    background: #fff;
    border-color: var(--tm-primary);
    color: var(--tm-primary);
    box-shadow: 0 0 0 5px var(--tm-primary-100);
}

/* ---------- Cabeçalho + grid ---------- */
.tm-checkout__head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 22px;
}

.tm-checkout__titulo {
    margin: 0;
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 800;
}

.tm-checkout__sub {
    color: var(--tm-muted);
}

.tm-checkout__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: clamp(20px, 3vw, 36px);
    align-items: start;
}

.tm-checkout__main {
    min-width: 0;
}

.tm-checkout__acoes-sec {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.tm-bloco-titulo {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
}

.tm-bloco-titulo:not(:first-child) {
    margin-top: 32px;
}

/* ---------- Itens ---------- */
.tm-itens {
    margin: 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius);
}

.tm-item {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto 120px 40px;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
}

.tm-itens--leitura .tm-item {
    grid-template-columns: 64px minmax(0, 1fr) auto;
}

.tm-item+.tm-item {
    border-top: 1px solid var(--tm-line);
}

.tm-item__img {
    width: 84px;
    height: 84px;
    border-radius: 12px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--tm-line);
}

.tm-itens--leitura .tm-item__img {
    width: 64px;
    height: 64px;
}

.tm-item__nome {
    margin: 0 0 4px;
    font-weight: 600;
    color: var(--tm-ink);
    line-height: 1.35;
}

.tm-item__unit {
    margin: 0;
    font-size: 14px;
    color: var(--tm-muted);
}

.tm-item__total {
    margin: 0;
    font-family: var(--tm-font-display);
    font-weight: 800;
    font-size: 17px;
    color: var(--tm-ink);
    text-align: right;
    white-space: nowrap;
}

.tm-item__remover {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--tm-muted);
    cursor: pointer;
}

.tm-item__remover:hover {
    background: #fef2f2;
    color: var(--tm-danger);
}

.tm-qtde--sm {
    display: inline-flex;
    align-items: center;
    height: 42px;
    border: 1px solid var(--tm-line);
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
}

.tm-qtde--sm button {
    width: 38px;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--tm-ink);
    font-size: 12px;
    cursor: pointer;
}

.tm-qtde--sm button:hover {
    background: var(--tm-bg-alt);
    color: var(--tm-primary);
}

.tm-qtde--sm input {
    width: 42px;
    height: 100%;
    border: 0;
    text-align: center;
    font-weight: 700;
    color: var(--tm-ink);
    -moz-appearance: textfield;
}

.tm-qtde--sm input::-webkit-outer-spin-button,
.tm-qtde--sm input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Resumo lateral ---------- */
.tm-resumo {
    position: sticky;
    top: calc(var(--tm-header-h) + 20px);
    display: grid;
    gap: 14px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow);
}

.tm-resumo__titulo {
    margin: 0;
    font-size: 19px;
}

.tm-resumo__linhas {
    margin: 0;
}

.tm-resumo__linhas>div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 15px;
}

.tm-resumo__linhas dt {
    font-weight: 400;
    color: var(--tm-muted);
}

.tm-resumo__linhas dd {
    margin: 0;
    color: var(--tm-ink);
    font-weight: 600;
    text-align: right;
}

.tm-resumo__linhas .tm-resumo__total {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px dashed var(--tm-line);
}

.tm-resumo__total dt {
    color: var(--tm-ink);
    font-weight: 700;
}

.tm-resumo__total dd {
    font-family: var(--tm-font-display);
    font-size: 24px;
    font-weight: 800;
}

.tm-resumo__seguro {
    margin: 0;
    font-size: 13px;
    text-align: center;
    color: var(--tm-muted);
}

.tm-resumo__seguro i {
    color: var(--tm-success);
    margin-right: 4px;
}

.tm-resumo__itens {
    display: grid;
    gap: 10px;
    max-height: 220px;
    margin: 0;
    padding: 0 0 12px;
    overflow-y: auto;
    list-style: none;
    border-bottom: 1px solid var(--tm-line);
}

.tm-resumo__itens li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--tm-text);
}

.tm-resumo__itens img {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid var(--tm-line);
    background: #fff;
}

.tm-resumo__bloco {
    display: grid;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--tm-line);
    font-size: 14px;
}

.tm-resumo__bloco-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    line-height: 1.5;
}

.tm-resumo__bloco-head i {
    width: 16px;
    margin-right: 6px;
    color: var(--tm-primary);
}

.tm-resumo__bloco-head a {
    flex-shrink: 0;
    color: var(--tm-primary);
    font-weight: 600;
}

/* ---------- Opções selecionáveis (frete / endereço) ---------- */
.tm-opcao {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    padding: 14px 16px;
    border: 1.5px solid var(--tm-line);
    border-radius: var(--tm-radius);
    background: #fff;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, box-shadow .2s;
}

.tm-opcao:hover {
    border-color: color-mix(in srgb, var(--tm-primary) 50%, var(--tm-line));
}

.tm-opcao input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tm-opcao__radio {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--tm-line);
    border-radius: 999px;
    transition: border .2s;
}

.tm-opcao:has(input:checked) {
    border-color: var(--tm-primary);
    background: var(--tm-primary-50);
    box-shadow: 0 0 0 3px var(--tm-primary-100);
}

.tm-opcao input:checked~.tm-opcao__radio {
    border: 6px solid var(--tm-primary);
}

.tm-opcao input:focus-visible~.tm-opcao__radio {
    outline: 3px solid var(--tm-primary-100);
    outline-offset: 2px;
}

.tm-opcao.is-disabled {
    opacity: .55;
    cursor: not-allowed;
    background: var(--tm-bg-alt);
}

.tm-opcao__icone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--tm-primary-50);
    color: var(--tm-primary);
}

.tm-opcao__texto {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tm-opcao__texto strong {
    color: var(--tm-ink);
    font-weight: 600;
}

.tm-opcao__texto small {
    color: var(--tm-muted);
    font-size: 13px;
}

.tm-opcao__preco {
    font-weight: 700;
    color: var(--tm-ink);
    white-space: nowrap;
}

.tm-opcao__preco--ok {
    color: var(--tm-success);
}

.tm-opcao--destaque {
    margin-bottom: 16px;
}

.tm-endereco {
    margin-bottom: 16px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius-lg);
}

.tm-endereco__head {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}

.tm-endereco__head strong {
    color: var(--tm-ink);
}

.tm-endereco__head p {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--tm-muted);
    line-height: 1.5;
}

.tm-endereco__icone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--tm-bg-alt);
    color: var(--tm-primary);
}

.tm-endereco__opcoes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.tm-novo-endereco {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 18px;
    border: 1.5px dashed var(--tm-line);
    border-radius: var(--tm-radius-lg);
    background: transparent;
    color: var(--tm-primary);
    font-weight: 600;
    cursor: pointer;
    transition: border-color .2s, background-color .2s;
}

.tm-novo-endereco:hover {
    border-color: var(--tm-primary);
    background: var(--tm-primary-50);
}

/* ---------- Formas de pagamento ---------- */
.tm-pagamentos {
    display: grid;
    gap: 12px;
}

.tm-pagamento {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1.5px solid var(--tm-line);
    border-radius: var(--tm-radius-lg);
    background: #fff;
    color: inherit;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}

.tm-pagamento:hover {
    border-color: var(--tm-primary);
    box-shadow: var(--tm-shadow);
    transform: translateY(-2px);
}

.tm-pagamento__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    padding: 10px;
    border-radius: 14px;
    background: var(--tm-bg-alt);
    color: var(--tm-primary);
    font-size: 24px;
}

.tm-pagamento__logo img {
    max-width: 100%;
    max-height: 100%;
}

.tm-pagamento__texto {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tm-pagamento__texto strong {
    color: var(--tm-ink);
    font-size: 17px;
}

.tm-pagamento__texto small {
    color: var(--tm-muted);
    font-size: 14px;
}

.tm-pagamento__tag {
    padding: 4px 10px;
    border-radius: 999px;
    background: #dcfce7;
    color: #15803d;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.tm-pagamento__seta {
    color: var(--tm-muted);
    transition: transform .2s;
}

.tm-pagamento:hover .tm-pagamento__seta {
    transform: translateX(3px);
    color: var(--tm-primary);
}

/* ---------- Barra fixa (mobile) ---------- */
.tm-barra-fixa {
    display: none;
}

/* ---------- Modal do tema ---------- */
.tm-modal {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.tm-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .6);
    animation: tmFade .2s;
}

.tm-modal__dialog {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px;
    background: #fff;
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-lg);
    animation: tmFadeDown .25s var(--tm-ease);
}

.tm-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.tm-modal__head h2 {
    margin: 0;
    font-size: 21px;
}

.tm-modal__acoes {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

@keyframes tmFade {
    from {
        opacity: 0;
    }
}

/* ---------- Formulários ---------- */
.tm-form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}

.tm-col-4 {
    grid-column: span 4;
}

.tm-col-8 {
    grid-column: span 8;
}

.tm-col-12 {
    grid-column: span 12;
}

.tm-campo label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tm-ink);
}

.tm-campo input,
.tm-campo select,
.tm-campo textarea {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--tm-line);
    border-radius: 12px;
    background: #fff;
    color: var(--tm-ink);
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s;
}

.tm-campo input:focus,
.tm-campo select:focus,
.tm-campo textarea:focus {
    outline: 0;
    border-color: var(--tm-primary);
    box-shadow: 0 0 0 4px var(--tm-primary-100);
}

.tm-campo small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--tm-muted);
}

/* ---------- Responsivo ---------- */
@media (max-width: 991px) {
    .tm-checkout__grid {
        grid-template-columns: 1fr;
    }

    .tm-resumo {
        position: static;
    }
}

@media (max-width: 767px) {
    .tm-etapas__rotulo {
        font-size: 11px;
    }

    .tm-etapas__item:not(.is-atual) .tm-etapas__rotulo {
        display: none;
    }

    .tm-etapas__bola {
        width: 34px;
        height: 34px;
        font-size: 12px;
    }

    .tm-etapas__item+.tm-etapas__item::before {
        top: 16px;
        right: calc(50% + 22px);
        left: calc(-50% + 22px);
    }

    .tm-item {
        grid-template-columns: 72px minmax(0, 1fr) auto;
        grid-template-areas:
            "img info rem"
            "img qtde total";
        gap: 10px 14px;
        padding: 16px;
    }

    .tm-item__img {
        grid-area: img;
        width: 72px;
        height: 72px;
        align-self: start;
    }

    .tm-item__info {
        grid-area: info;
    }

    .tm-item__qtde {
        grid-area: qtde;
        justify-self: start;
    }

    .tm-item__total {
        grid-area: total;
        align-self: center;
    }

    .tm-item__remover {
        grid-area: rem;
        align-self: start;
        justify-self: end;
        width: 36px;
        height: 36px;
    }

    .tm-itens--leitura .tm-item {
        grid-template-columns: 56px minmax(0, 1fr) auto;
        grid-template-areas: "img info total";
    }

    .tm-itens--leitura .tm-item__img {
        width: 56px;
        height: 56px;
    }

    /* carrinho: total + botão em barra fixa no rodapé */
    .tm-barra-fixa {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 970;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--tm-line);
        box-shadow: 0 -10px 30px -20px rgba(15, 23, 42, .5);
    }

    .tm-barra-fixa span {
        display: block;
        font-size: 12px;
        color: var(--tm-muted);
    }

    .tm-barra-fixa strong {
        font-family: var(--tm-font-display);
        font-size: 20px;
        color: var(--tm-ink);
    }

    body:has(.tm-barra-fixa) .tm-whats {
        bottom: 96px;
    }

    body:has(.tm-barra-fixa) .tm-to-top {
        bottom: 166px;
    }

    body:has(.tm-barra-fixa) .tm-footer {
        padding-bottom: 76px;
    }

    .tm-col-4,
    .tm-col-8 {
        grid-column: span 12;
    }

    .tm-modal {
        align-items: flex-end;
        padding: 0;
    }

    .tm-modal__dialog {
        border-radius: var(--tm-radius-lg) var(--tm-radius-lg) 0 0;
        max-height: 92vh;
    }

    .tm-pagamento {
        padding: 16px;
    }

    .tm-pagamento__tag {
        display: none;
    }
}
