/* ==========================================
   CALCULADORA DE BOLÃO - ALINHADA AO SYSTEM DESIGN
   ========================================== */

body {
    background-color: var(--fundo);
    color: var(--texto);
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

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

/* --- CARD PRINCIPAL --- */
.calc-card {
    background: var(--fundo-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--borda);
    border-top: 4px solid var(--azul-caixa);
    overflow: hidden;
}

/* --- TOOLBAR / HEADER DO CARD --- */
.calc-card-header {
    background: #fafbfc;
    border-bottom: 1px solid var(--borda);
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.config-title {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--azul-caixa);
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-title i {
    color: var(--laranja-caixa);
    font-size: 1rem;
}

.config-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    min-height: 40px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--borda);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.config-control span {
    font-size: 0.80rem;
    font-weight: 700;
    color: var(--texto-secundario);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.pct-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

input.config-input {
    width: 48px;
    min-height: 36px;
    border: 1px solid var(--borda-sutil);
    border-radius: 6px;
    background: var(--fundo-sutil);
    font-weight: 900;
    color: var(--azul-caixa);
    font-size: 1rem;
    text-align: center;
    outline: none;
    padding: 4px 6px;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

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

.pct-symbol {
    color: var(--azul-claro);
    font-weight: 900;
    font-size: 0.95rem;
}

/* --- TABELA INTEGRADA AO CARD --- */
.calc-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

thead {
    background: var(--fundo-sutil);
    border-bottom: 1.5px solid var(--borda);
}

thead th {
    font-size: 0.72rem;
    color: var(--texto-secundario);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 8px;
    font-weight: 800;
    text-align: center;
}

thead th:first-child { text-align: left; padding-left: 16px; }
thead th:last-child { text-align: right; padding-right: 16px; }

tbody tr {
    background: white;
    border-bottom: 1px solid var(--fundo-hover);
    transition: background 0.15s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--fundo-sutil);
}

td {
    padding: 8px 6px;
    vertical-align: middle;
    height: 60px;
}

tbody td:first-child { padding-left: 14px; }
tbody td:last-child { padding-right: 14px; }

/* --- INPUTS TOUCH-FRIENDLY --- */
input.cell-input {
    width: 100%;
    height: 44px;
    border: 1.5px solid var(--borda);
    background: white;
    font-size: 16px; /* Mantém 16px para impedir zoom involuntário no iOS Safari */
    color: var(--texto);
    font-weight: 600;
    text-align: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    outline: none;
    padding: 0 4px;
}

input.cell-input:focus {
    border-color: var(--azul-caixa);
    box-shadow: 0 0 0 3px rgba(var(--primaria-escura-rgb), 0.12);
}

input.input-price {
    color: var(--texto);
}

input.input-tariff {
    color: var(--azul-caixa);
    font-weight: 700;
}

input.input-tariff:focus {
    border-color: var(--laranja-caixa);
    box-shadow: 0 0 0 3px rgba(240, 130, 0, 0.15);
}

input.input-tariff::placeholder {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.90rem;
}

input.input-qty {
    color: var(--texto);
    font-weight: 700;
}

input.error {
    color: var(--perigo) !important;
    border-color: var(--perigo) !important;
    background: #fef2f2 !important;
}

.col-result {
    font-weight: 800;
    color: var(--azul-caixa);
    text-align: right;
    font-size: 1.05rem;
    padding-right: 4px;
    white-space: nowrap;
}

/* --- LARGURAS DE COLUNAS --- */
.w-price { width: 32%; }
.w-tariff { width: 24%; }
.w-qty { width: 18%; }
.w-comm { width: 26%; }

/* --- BARRA DE AÇÕES INLINE --- */
.calc-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    justify-content: center;
    width: 100%;
}

.btn-calc-add {
    background: linear-gradient(135deg, var(--azul-claro) 0%, var(--azul-caixa) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    min-height: 44px;
    padding: 11px 18px;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1.4 1 155px;
    max-width: 230px;
    box-shadow: 0 3px 8px rgba(var(--primaria-rgb), 0.25);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.btn-calc-add:hover {
    background: linear-gradient(135deg, var(--azul-caixa) 0%, #002244 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(var(--primaria-escura-rgb), 0.35);
}

.btn-calc-add:active {
    transform: translateY(0);
}

.btn-calc-reset {
    background: white;
    color: var(--texto-secundario);
    border: 1.5px solid var(--borda);
    border-radius: var(--radius-pill);
    min-height: 44px;
    padding: 11px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1 1 130px;
    max-width: 170px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.btn-calc-reset:hover {
    border-color: var(--perigo);
    color: var(--perigo);
    background: #fef2f2;
}

/* --- FOOTER FIXO (COM SAFE AREA iOS) --- */
body:has(.footer-totals) .hub-net-status-pill,
body:has(.footer-totals) .hub-toast.show {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}
.footer-totals {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--borda);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 99;
    box-sizing: border-box;
}

.total-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.total-item:first-child { align-items: flex-start; }
.total-item:nth-child(2) {
    align-items: center;
    border-left: 1px solid var(--borda);
    border-right: 1px solid var(--borda);
    padding: 0 8px;
}
.total-item:last-child { align-items: flex-end; }

.total-label {
    font-size: 0.68rem;
    color: var(--texto-secundario);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.total-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--azul-caixa);
    white-space: nowrap;
}

.total-qty-num {
    color: var(--texto-secundario);
}

.value-collect {
    color: var(--sucesso);
    font-size: 1.25rem;
    font-weight: 900;
}

/* --- RESPONSIVIDADE MOBILE (< 540px) --- */
@media (max-width: 540px) {
    .container {
        padding: 14px 10px;
    }
    .calc-card-header {
        padding: 10px 14px;
    }
    .config-title {
        font-size: 0.80rem;
    }
    td {
        padding: 6px 3px;
        height: 54px;
    }
    tbody td:first-child { padding-left: 8px; }
    tbody td:last-child { padding-right: 8px; }
    thead th:first-child { padding-left: 10px; }
    thead th:last-child { padding-right: 10px; }
    input.cell-input {
        height: 40px;
        padding: 0 2px;
    }
    .col-result {
        font-size: 0.95rem;
    }
    .footer-totals {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    }
    .total-label {
        font-size: 0.62rem;
    }
    .total-value {
        font-size: 1.05rem;
    }
    .value-collect {
        font-size: 1.12rem;
    }
}
