/* ========================================
   Sistema Mercado — Custom Styles
   ======================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 0px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #c9d1d9;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(13, 110, 253, 0.25);
    --topbar-height: 56px;
    --primary: #0d6efd;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;
}

/* ---- Global ---- */
body {
    background-color: #f4f6f9;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---- Sidebar ---- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: width 0.25s ease;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    width: 0;
}

.sidebar-brand {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: rgba(0,0,0,0.2);
    min-height: var(--topbar-height);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .brand-icon {
    font-size: 1.5rem;
    color: var(--primary);
    flex-shrink: 0;
}

.brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.brand-version {
    color: var(--sidebar-text);
    font-size: 0.7rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.5); }

.nav-section {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    white-space: nowrap;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-size: 0.875rem;
    border-radius: 0;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active);
    color: #4da3ff;
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
    overflow: hidden;
}

/* ---- Main Content ---- */
#mainContent {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.25s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#mainContent.expanded {
    margin-left: 0;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 1rem;
}

.topbar-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #495057;
    flex: 1;
}

/* ---- Page Content ---- */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ---- KPI Cards ---- */
.kpi-card {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid transparent;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-card.kpi-green  { border-color: var(--success); }
.kpi-card.kpi-blue   { border-color: var(--primary); }
.kpi-card.kpi-orange { border-color: var(--warning); }
.kpi-card.kpi-red    { border-color: var(--danger); }

.kpi-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.kpi-green  .kpi-icon { color: var(--success); }
.kpi-blue   .kpi-icon { color: var(--primary); }
.kpi-orange .kpi-icon { color: var(--warning); }
.kpi-red    .kpi-icon { color: var(--danger); }

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.75rem;
    color: #6c757d;
}

/* ---- User Avatar ---- */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6610f2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
}

.user-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6610f2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1d23 0%, #0d1117 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* ---- Card Hover ---- */
.card-hover {
    transition: transform 0.15s, box-shadow 0.15s;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12) !important;
}

/* ---- PDV ---- */
.pdv-product-row {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.1s;
}

.pdv-product-row:hover {
    background: #f8f9fa;
}

#sugestoes .sugestao-item {
    padding: 0.5rem 0.875rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    border-bottom: 1px solid #f0f0f0;
}

#sugestoes .sugestao-item:hover {
    background: #f0f4ff;
}

.sugestao-nome { font-weight: 500; }
.sugestao-preco { color: var(--success); font-weight: 600; }
.sugestao-estoque { font-size: 0.75rem; color: #6c757d; }

/* ---- PDV Fullscreen (sem scroll) ---- */
.pdv-container {
    display: flex;
    flex-direction: column;
    /* topbar(56px) + flash-area-pt3(16px) + page-content padding-top(8px) = 80px ~= 2rem + topbar */
    height: calc(100vh - var(--topbar-height) - 2rem);
    overflow: hidden;
}

.pdv-main-row {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 0.5rem;
    overflow: hidden;
}

.pdv-col-left {
    flex: 0 0 61%;
    max-width: 61%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.4rem;
}

.pdv-col-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 0;
    overflow: hidden;
}

.pdv-items-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

.pdv-items-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.pdv-finalizar-btn {
    flex-shrink: 0;
    min-height: 56px;
    font-size: 1.3rem !important;
}

.pdv-pgto-label {
    font-size: 0.78rem;
}

/* ---- Responsive ---- */
@media (max-width: 767.98px) {
    /* PDV Mobile: colunas empilhadas verticalmente */
    .pdv-container {
        height: calc(100vh - var(--topbar-height) - 1.25rem);
    }

    .pdv-main-row {
        flex-direction: column;
        gap: 0.375rem;
    }

    .pdv-col-left {
        flex: 0 0 45%;
        max-width: 100%;
    }

    .pdv-col-right {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .pdv-finalizar-btn {
        min-height: 48px;
        font-size: 1.1rem !important;
    }

    #sidebar {
        width: 0;
    }

    #sidebar.mobile-open {
        width: var(--sidebar-width);
    }

    #mainContent {
        margin-left: 0 !important;
    }

    /* Overlay escurecido atrás da sidebar no mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1039;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Padding reduzido no mobile */
    .page-content {
        padding: 0.75rem;
    }

    /* KPI: fonte menor em telas pequenas */
    .kpi-value {
        font-size: 1.1rem;
    }

    .kpi-card {
        padding: 0.875rem;
        gap: 0.625rem;
    }

    .kpi-icon {
        font-size: 1.5rem;
    }

    /* Headings de página menores */
    .page-content h2 {
        font-size: 1.25rem;
    }

    /* Topbar: título truncado */
    .topbar-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 160px;
    }

    /* Botões de ação nas tabelas: empilhar em telas muito pequenas */
    .table .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
    }
}

/* ---- Utilities ---- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer { cursor: pointer; }

code { font-size: 0.82em; }

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.badge { font-weight: 500; }

.card { border: none; }
.card.border { border: 1px solid #dee2e6 !important; }

/* ========================================
   PDV — Modo Caixa (letras maiores para
   boa visualização do cliente)
   ======================================== */

/* Busca de produto */
#buscaProduto {
    font-size: 1.25rem !important;
    height: 3.25rem;
}

/* Container de busca - necessário para posicionar sugestões */
.card-body:has(#buscaProduto) {
    position: relative;
}

#sugestoes {
    position: absolute !important;
    top: calc(100% - 1rem);
    left: 0 !important;
    right: 0 !important;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 320px;
    min-height: 50px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
}

/* Sugestões de autocomplete */
#sugestoes .sugestao-item {
    font-size: 1.1rem !important;
    padding: 0.75rem 1rem;
}
.sugestao-nome { font-size: 1.05rem; }
.sugestao-preco { font-size: 1.05rem; }
.sugestao-estoque { font-size: 0.9rem; }

/* Cabeçalho da tabela de itens */
#tabelaItens thead th {
    font-size: 1.15rem !important;
    letter-spacing: 0.03em;
}

/* Células da tabela de itens */
#tabelaItens tbody td {
    font-size: 1.25rem;
    padding: 0.85rem 0.6rem;
    vertical-align: middle;
}

/* Input de quantidade dentro da tabela */
#tabelaItens .qty-input {
    font-size: 1.15rem;
    height: 2.6rem;
}

/* Seção de totais */
#subtotal,
#total {
    font-size: 1.35rem !important;
}
#total {
    font-size: 1.75rem !important;
}

/* Label "TOTAL:" */
.d-flex.fs-4 span:first-child {
    font-size: 1.4rem;
}

/* Troco */
#troco {
    font-size: 1.35rem !important;
}

/* Desconto input */
#descontoInput {
    font-size: 1.05rem;
}

/* Valor recebido */
#valorRecebido {
    font-size: 1.35rem;
    height: 3rem;
}

/* Botões de forma de pagamento */
.btn-check + .btn {
    font-size: 1.05rem;
    padding: 0.65rem 1rem;
}

/* Botão Finalizar Venda */
#btnFinalizar {
    font-size: 1.35rem !important;
    padding: 0.85rem 1.25rem;
    letter-spacing: 0.03em;
}

/* Cliente select */
#clienteId {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
}

/* Card headers no PDV */
#tabelaItens ~ * .card-header,
.card-header {
    font-size: 1rem;
}

/* Badge contador de itens */
#qtdItens {
    font-size: 0.9rem;
    padding: 0.35em 0.6em;
}

/* ---- Scanner de câmera (modal mobile) ---- */
#scannerRegion {
    border-radius: 0;
    overflow: hidden;
    background: #000;
    min-height: 240px;
}

#scannerRegion video {
    width: 100% !important;
    max-height: 60vh;
    object-fit: cover;
}

/* Caixa de mira do scanner */
#scannerRegion canvas,
#scannerRegion div[style*="border"] {
    border-color: #0d6efd !important;
}

/* Botão câmera — só aparece em mobile */
#btnCamera {
    min-width: 3.25rem;
    font-size: 1.2rem;
}
