/* ============================================================================
   FRANZ FINANÇAS - COMPRAS.CSS (VISUAL UNIFICADO + CORREÇÕES)
   ============================================================================ */
:root {
    --invest-primary: #00623B;
    --invest-dark: #003B23;
    --bg-graph: #0a2e2b;
    --gold: #D4AF37;
    --gold-light: #F4EBD0;
    --bg-body: #fdfbf7;
    --text-dark: #1F2937;
    --danger: #EF4444;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background-color: var(--bg-body);
    font-family: 'Mulish', sans-serif;
    display: flex;
    flex-direction: column;
    color: var(--text-dark);
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg transform='translate(5 5)' fill='%23999' fill-opacity='0.10'%3E%3Ctext font-size='14' x='5' y='15' transform='rotate(-10 5 15)'%3E🛒%3C/text%3E%3Ctext font-size='14' x='45' y='25' transform='rotate(15 45 25)'%3E🛍️%3C/text%3E%3Ctext font-size='12' x='75' y='10' transform='rotate(5 75 10)'%3E🧾%3C/text%3E%3Ctext font-size='14' x='15' y='55' transform='rotate(20 15 55)'%3E💲%3C/text%3E%3Ctext font-size='16' x='55' y='65' transform='rotate(-5 55 65)'%3E🥦%3C/text%3E%3Ctext font-size='12' x='85' y='50' transform='rotate(10 85 50)'%3E🥩%3C/text%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-attachment: fixed;
}

/* CABEÇALHO */
header {
    background: linear-gradient(180deg, var(--invest-primary) 0%, var(--invest-dark) 100%);
    padding: 15px 24px;
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 20;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-weight: 800;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--gold);
    flex: 1;
    text-align: center;
}

.btn-icon-head {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--gold);
    color: var(--gold);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    backdrop-filter: blur(5px);
}

/* DASHBOARD CURVO */
.dashboard-curved {
    position: relative;
    width: 100%;
    height: 290px;
    display: flex;
    background-color: var(--bg-graph);
    padding-top: 15px;
    overflow: hidden;
    margin-bottom: 0;
    flex-shrink: 0;
}

.dash-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    z-index: 5;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    height: 100%;
    cursor: pointer;
    min-width: 0;
    transition: filter 0.2s;
}

.dash-col:active {
    filter: brightness(1.2);
}

/* Barra mais alta e visível */
.dash-col-bar {
    width: 100%;
    min-height: 50px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    opacity: 0.9;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 12px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
    transition: height 0.5s ease;
}

.col-title {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 800;
    font-size: 0.55rem;
    text-transform: uppercase;
    margin-bottom: 2px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 90%;
}

.col-circle {
    color: white;
    font-weight: 800;
    font-size: 0.65rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 4px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-top: 2px;
}

.curve-overlay {
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 150%;
    height: 90px;
    background-color: var(--bg-body);
    border-top-left-radius: 100% 100%;
    border-top-right-radius: 100% 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 20px;
    z-index: 15;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
    border-top: 3px solid var(--gold);
}

.total-label {
    font-weight: 700;
    font-size: 0.8rem;
    color: #6B7280;
    text-transform: uppercase;
}

.total-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--invest-primary);
    margin: 0;
    line-height: 1;
}

.container {
    padding: 0 20px 110px 20px;
    position: relative;
    z-index: 15;
    flex: 1;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    box-sizing: border-box;
}

.section-header {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--invest-primary);
    border-bottom: 2px solid var(--gold);
    display: inline-block;
    padding-bottom: 5px;
    margin: 25px 0 15px 0;
    text-transform: uppercase;
}

/* CARDS E LISTA */
#categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.cat-card {
    background: white;
    padding: 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.cat-card:active {
    transform: scale(0.98);
}

.cat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 10px;
}

.cat-info {
    flex: 1;
    overflow: hidden;
}

.cat-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #4B5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-val {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-dark);
}

.item-card {
    background: white;
    padding: 15px;
    border-radius: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border-left: 4px solid #ccc;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.item-card:active {
    transform: scale(0.98);
}

.item-main {
    display: flex;
    align-items: center;
    flex: 1;
}

.item-icon {
    font-size: 1.2rem;
    margin-right: 12px;
}

.item-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #333;
}

.item-meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 2px;
}

.item-price {
    font-weight: 800;
    font-size: 1rem;
    color: #333;
}

.btn-gold-text {
    background-color: #0f393b;
    color: #F4D35E;
    border: 1px solid #F4D35E;
    font-weight: 700;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    text-transform: uppercase;
    margin-bottom: 15px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* SEÇÃO DADOS */
.data-box {
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid #eee;
    margin-top: 20px;
    text-align: center;
}

.data-box h4 {
    margin: 0 0 15px 0;
    color: #555;
    font-size: 1rem;
}

.btn-data-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-data {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-data.blue {
    background: #e0f2fe;
    color: #0284c7;
}

.btn-data.red {
    background: #fee2e2;
    color: #dc2626;
    margin-top: 10px;
    width: 100%;
}

/* --- MODAIS UNIFICADOS (TODOS BEGE CLARO + BORDA DOURADA) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

/* AQUI ESTÁ A MÁGICA: TODAS AS JANELAS COM O MESMO ESTILO */
.modal-sheet {
    background-color: #fdfbf7;
    /* Fundo Bege da Marca */
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 25px;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid var(--gold);
    /* Borda Dourada */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.modal-title {
    color: var(--invest-primary);
    font-weight: 800;
    font-size: 1.3rem;
}

.close-btn {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
}

/* INPUTS E LISTAS DENTRO DAS JANELAS */
.ocr-row,
.product-select-item {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border: 1px solid #eee;
}

.modern-input,
.modern-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-top: 5px;
    box-sizing: border-box;
    background: #fff;
    font-family: 'Mulish', sans-serif;
}

.modern-input:focus {
    border-color: var(--invest-primary);
    outline: none;
}

/* BOTÕES DE AÇÃO PRINCIPAL */
.btn-save-ocr {
    width: 100%;
    padding: 15px;
    background: var(--invest-primary);
    color: var(--gold);
    border: 2px solid var(--gold);
    border-radius: 12px;
    font-weight: 800;
    margin-top: 15px;
    cursor: pointer;
    text-transform: uppercase;
}

/* UTILS */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 57, 59, 0.95);
    z-index: 3000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #F4D35E;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(244, 211, 94, 0.3);
    border-top-color: #F4D35E;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 50px;
    padding: 16px;
    position: fixed;
    z-index: 10000;
    left: 50%;
    bottom: 120px;
    transform: translateX(-50%);
    opacity: 0;
    transition: 0.3s;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 140px;
}

#toast.error {
    background-color: #d32f2f;
}

.fab-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 1000;
}

.fab-cam {
    background: var(--invest-primary);
    color: var(--gold);
    width: 50px;
    height: 55px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    font-size: 2rem;
    display: flex;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.bottom-nav {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 380px;
    background: #0f393b;
    border: 1px solid var(--gold);
    border-radius: 50px;
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    z-index: 900;
}

.nav-item {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--gold);
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

/* --- ESTILO DA JANELA DE PLANEJAR COMPRA --- */
/* Ajuste do Modal para ocupar melhor a tela */
#listModal .modal-sheet {
    padding: 0;
    /* Remove padding padrão para controlar layout */
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    /* Altura máxima */
    background: #f9f9f9;
}

/* Cabeçalho fixo dentro do modal */
.plan-header {
    padding: 15px;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

/* Campo de busca moderno */
.plan-search {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #eee;
    background: #f0f2f5;
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.plan-search:focus {
    background: white;
    border-color: #00623B;
    box-shadow: 0 0 0 3px rgba(0, 98, 59, 0.1);
}

/* Lista de produtos com rolagem */
#masterProductList {
    flex: 1;
    /* Ocupa o espaço restante */
    overflow-y: auto;
    /* Permite rolar */
    padding: 10px;
}

/* Card do Produto */
.product-select-item {
    background: white;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.1s;
    border: 1px solid transparent;
}

/* Efeito ao selecionar */
.product-select-item.selected {
    border-color: #00623B;
    background-color: #f0fdf4;
}

.product-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Checkbox customizado (visual) */
.custom-check {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    transition: all 0.2s;
}

.product-select-item.selected .custom-check {
    background: #00623B;
    border-color: #00623B;
}

.prod-details b {
    display: block;
    font-size: 0.9rem;
    color: #333;
}

.prod-details small {
    color: #888;
    font-size: 0.75rem;
}

/* Controles de Quantidade (+ e -) */
.qty-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f5f5f5;
    padding: 3px;
    border-radius: 8px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: white;
    border-radius: 6px;
    color: #00623B;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-input-visual {
    width: 25px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    background: transparent;
    border: none;
}

/* Rodapé Fixo (Total e Botão) */
.plan-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.plan-total-label {
    font-size: 0.8rem;
    color: #666;
}

.plan-total-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: #00623B;
}

.btn-finish-list {
    background: #00623B;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}