/* assets/css/style.css */

/* Variáveis Globais */
:root {
    --primary-color: #28a745;
    --secondary-color: #ffc107;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --text-color: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --bg-light: #f8f9fa;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --transition-default: all 0.3s ease;
}

/* Estilos Base */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.5;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Navbar */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.navbar-dark.bg-success {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
}

/* Cards de Ofertas */
.oferta-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    box-shadow: var(--shadow-sm);
    border-radius: 10px;
    overflow: hidden;
}

.oferta-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.preco-oferta {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.preco-medio {
    font-size: 1rem;
}

/* Barra de Qualidade */
.qualidade-bar {
    height: 20px;
    border-radius: 10px;
}

.bg-excelente {
    background-color: var(--primary-color) !important;
}

.bg-media {
    background-color: var(--secondary-color) !important;
}

.bg-baixa {
    background-color: var(--danger-color) !important;
}

/* Lista de Compras */
.lista-item {
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.lista-item:hover {
    background-color: rgba(40, 167, 69, 0.05);
}

.lista-item.comprado {
    background-color: #d4edda !important;
    opacity: 0.8;
    border-left-color: var(--primary-color);
}

.lista-item.comprado .item-nome {
    color: #155724;
    text-decoration: line-through;
}

/* Checkbox personalizado */
.checkbox-custom {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-comprado {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Termômetro de Qualidade */
.termometro {
    display: inline-block;
    width: 100px;
    height: 10px;
    background: linear-gradient(to right, red, yellow, green);
    border-radius: 5px;
    position: relative;
}

.termometro-indicador {
    width: 12px;
    height: 16px;
    background: #333;
    position: absolute;
    top: -3px;
    border-radius: 3px;
    transform: translateX(-50%);
}

/* Comunidade */
.comentario-util {
    background-color: #e8f5e9;
    border-left: 4px solid var(--primary-color);
    padding: 10px;
    margin-top: 10px;
    border-radius: 0 8px 8px 0;
}

.pontos-util {
    color: var(--primary-color);
    font-weight: bold;
}

/* Mercados */
.mercado-card {
    cursor: pointer;
    transition: var(--transition-default);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.mercado-card:hover {
    background-color: var(--bg-light);
    transform: scale(1.02);
    box-shadow: var(--shadow-sm);
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Badges e tags */
.badge-economia {
    background-color: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.unidade-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: #e9ecef;
    color: #495057;
    margin-left: 5px;
    display: inline-block;
}

/* Tooltips personalizados */
.tooltip-custom {
    position: relative;
    display: inline-block;
}

.tooltip-custom:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Cards de Total */
.card-total {
    transition: var(--transition-default);
    cursor: default;
    border: none;
    border-radius: 10px;
    overflow: hidden;
}

.card-total:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Barra de Progresso */
.progress {
    transition: width 0.5s ease-in-out;
    border-radius: 10px;
    background-color: rgba(255,255,255,0.3);
}

.progress-bar {
    transition: width 0.5s ease;
}

/* Atualização em Tempo Real */
.atualizacao-tempo-real {
    font-size: 0.7rem;
    color: var(--text-muted);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Utilitários */
.cursor-pointer {
    cursor: pointer;
}

.hover\:bg-light:hover {
    background-color: var(--bg-light);
}

/* Sugestões de Produtos */
#sugestoes-produtos {
    position: absolute;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    width: calc(100% - 2rem);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: none;
    box-shadow: var(--shadow-md);
}

#sugestoes-produtos div {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
    transition: background-color 0.2s;
}

#sugestoes-produtos div:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

/* Categorias - Ocultas por padrão */
.categoria-itens {
    display: none;
}

.categoria-itens[style*="display: block"] {
    display: block !important;
    animation: slideDown 0.3s ease forwards;
}

/* Botões de Categoria */
.btn-outline-success.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-outline-secondary:hover {
    background-color: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Item Form */
.item-form {
    background-color: #f0f9f0;
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
}

/* Preço Unitário */
.preco-unitario {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.preco-sugerido {
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* Container de Itens por Categoria */
#itens-categoria {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--bg-light);
    border-radius: 8px;
}

/* Menu de Categorias */
#menu-categorias .btn {
    border-radius: 20px;
    margin: 2px;
    font-size: 0.8rem;
    transition: var(--transition-default);
}

/* ============================================ */
/* RESPONSIVIDADE - Mobile First */
/* ============================================ */

/* Tablets e dispositivos médios (até 768px) */
@media (max-width: 768px) {
    /* Ajustes gerais */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Tipografia */
    h2 {
        font-size: 1.3rem;
    }
    
    h2 i {
        font-size: 1.1rem;
    }
    
    .text-muted {
        font-size: 0.85rem;
    }
    
    /* Navbar */
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    /* Cards de resumo */
    .row.mb-4 .col-md-3.col-6 {
        padding: 5px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-body h3 {
        font-size: 1.2rem;
        word-break: break-word;
        margin: 5px 0;
    }
    
    .card-body h6 {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .card-body small {
        font-size: 0.7rem;
    }
    
    .card-total {
        margin-bottom: 10px;
    }
    
    .card-total .progress {
        margin-top: 8px !important;
        height: 2px !important;
    }
    
    .card-total .card-title i {
        font-size: 0.9rem;
    }
    
    /* Formulário de adicionar item */
    #form-adicionar-item .col-md-5,
    #form-adicionar-item .col-md-2,
    #form-adicionar-item .col-md-3 {
        margin-bottom: 10px;
    }
    
    #form-adicionar-item .input-group {
        width: 100%;
    }
    
    #form-adicionar-item .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    #form-adicionar-item .btn-outline-secondary {
        margin-left: 0 !important;
    }
    
    #form-adicionar-item .form-label {
        font-size: 0.85rem;
        margin-bottom: 3px;
    }
    
    #form-adicionar-item .row.g-3 > [class*="col-"] {
        margin-bottom: 8px;
    }
    
    /* Lista de itens */
    .lista-item {
        padding: 12px 10px;
    }
    
    .lista-item .row {
        flex-wrap: wrap;
        position: relative;
        padding-right: 35px;
        align-items: flex-start !important;
    }
    
    .lista-item .col-auto {
        margin-bottom: 8px;
    }
    
    .lista-item .col-auto:last-child {
        position: absolute;
        right: 10px;
        top: 10px;
    }
    
    .lista-item .col {
        flex: 0 0 100%;
        order: 2;
        margin-top: 8px;
    }
    
    .lista-item .checkbox-comprado {
        width: 22px;
        height: 22px;
        margin-top: 0;
    }
    
    .lista-item .input-group {
        width: 110px !important;
    }
    
    .lista-item .input-group .form-control {
        padding: 4px 6px;
        font-size: 0.85rem;
    }
    
    .lista-item .input-group-text {
        padding: 4px 6px;
        font-size: 0.8rem;
    }
    
    .lista-item .btn-outline-danger {
        padding: 4px 8px;
    }
    
    .lista-item .btn-outline-danger i {
        font-size: 0.9rem;
    }
    
    .lista-item .item-nome {
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 4px;
        padding-right: 25px;
    }
    
    .lista-item .text-muted.estimado {
        font-size: 0.8rem;
    }
    
    .lista-item .row.mt-2 {
        margin-top: 8px !important;
        padding-top: 5px;
        border-top: 1px dashed var(--border-color);
    }
    
    .unidade-badge {
        font-size: 0.6rem;
        padding: 2px 4px;
    }
    
    .preco-unitario {
        font-size: 0.7rem;
    }
    
    .d-flex.align-items-center.gap-2 {
        flex-wrap: wrap;
        gap: 5px !important;
    }
    
    /* Menu de categorias - Versão Unificada */
    #menu-categorias {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 5px;
        width: 100%;
    }
    
    #menu-categorias .btn {
        border-radius: 8px !important;
        padding: 10px 5px;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border: 1px solid var(--border-color);
        background: white;
        color: var(--text-muted);
        transition: var(--transition-default);
        margin: 0 !important;
        width: 100%;
        text-align: center;
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
        min-height: 45px;
    }
    
    #menu-categorias .btn i {
        font-size: 1rem;
    }
    
    #menu-categorias .btn.active {
        background: linear-gradient(135deg, #28a745, #20c997);
        color: white;
        border-color: var(--primary-color);
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    }
    
    #menu-categorias .btn:active {
        transform: scale(0.95);
    }
    
    /* Itens de sugestão */
    #itens-categoria {
        margin-top: 10px;
        padding: 10px;
        background: #fff;
        border-radius: 8px;
        box-shadow: var(--shadow-sm);
    }
    
    #itens-categoria .d-flex {
        gap: 5px !important;
    }
    
    #itens-categoria .btn {
        border-radius: 6px !important;
        border: 1px solid #e9ecef;
        background: var(--bg-light);
        color: var(--text-color);
        transition: all 0.2s ease;
        font-size: 0.7rem;
        padding: 8px 5px;
        flex: 1 0 auto;
        max-width: calc(50% - 5px);
        text-align: left;
        white-space: normal;
        line-height: 1.2;
        height: auto;
        min-height: 45px;
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    #itens-categoria .btn:hover,
    #itens-categoria .btn:active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
    
    #itens-categoria .btn i {
        font-size: 0.9rem;
        margin-right: 4px;
    }
    
    /* Animação das categorias */
    .categoria-itens {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Sidebar */
    .col-md-4 {
        margin-top: 20px;
    }
    
    .col-md-4 .card {
        margin-bottom: 15px;
        border-radius: 10px;
        box-shadow: var(--shadow-sm);
    }
    
    .col-md-4 .card-body {
        padding: 15px;
    }
    
    .col-md-4 .card-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .col-md-4 .list-unstyled li {
        font-size: 0.9rem;
        padding: 6px 0;
    }
    
    .col-md-4 .alert {
        padding: 10px;
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .col-md-4 .small li {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    /* Barra de progresso */
    .progress {
        height: 25px !important;
        border-radius: 12px;
    }
    
    .progress-bar {
        font-size: 0.8rem;
        line-height: 25px;
    }
    
    #texto-progresso {
        font-size: 0.8rem;
        font-weight: 500;
    }
    
    .card.mb-4 .row.mt-3 .col-4 {
        padding: 0 2px;
    }
    
    .card.mb-4 .row.mt-3 small {
        font-size: 0.7rem;
        white-space: nowrap;
    }
    
    /* Conversor */
    #conv-valor, 
    #conv-de, 
    #conv-para {
        font-size: 0.8rem;
    }
    
    #conv-resultado {
        font-size: 0.9rem;
        padding: 8px;
    }
    
    /* Botões de compartilhamento */
    .btn-group.w-100 .btn {
        font-size: 0.8rem;
        padding: 8px 0;
    }
    
    /* Sugestões de produtos */
    #sugestoes-produtos {
        width: 100% !important;
        left: 0 !important;
        max-height: 150px;
    }
    
    #sugestoes-produtos div {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    /* Melhorias de usabilidade */
    .btn,
    .sugestao-item,
    .remover-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    .checkbox-comprado {
        min-height: auto;
        min-width: auto;
    }
    
    /* Ajustes de contraste */
    .text-muted {
        color: var(--text-muted) !important;
    }
    
    /* Espaçamento geral */
    .container.mt-4 {
        margin-top: 15px !important;
    }
    
    .mb-4 {
        margin-bottom: 15px !important;
    }
}

/* Dispositivos muito pequenos (até 480px) */
@media (max-width: 480px) {
    .card-body h3 {
        font-size: 1rem;
    }
    
    #menu-categorias .btn {
        font-size: 0.75rem;
        padding: 8px 4px;
        min-height: 40px;
    }
    
    #itens-categoria .btn {
        font-size: 0.7rem;
        padding: 6px 4px;
        min-height: 40px;
    }
    
    .lista-item .input-group {
        width: 90px !important;
    }
    
    .lista-item .btn-sm {
        padding: 4px 6px;
    }
    
    .preco-oferta {
        font-size: 1.2rem;
    }
}

/* Dispositivos extremamente pequenos (até 380px) */
@media (max-width: 380px) {
    #menu-categorias {
        grid-template-columns: 1fr;
    }
    
    #menu-categorias .btn {
        justify-content: flex-start;
        padding: 12px 15px;
        min-height: auto;
    }
    
    #itens-categoria .btn {
        max-width: 100%;
        flex: 1 0 100%;
    }
}

/* Tablets em modo paisagem (768px - 992px) */
@media (min-width: 769px) and (max-width: 992px) {
    .container {
        max-width: 95%;
    }
    
    .card-body h3 {
        font-size: 1.1rem;
    }
    
    #menu-categorias .btn {
        font-size: 0.75rem;
        padding: 4px 6px;
    }
    
    #itens-categoria .btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* ============================================ */
/* ANIMAÇÕES */
/* ============================================ */

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

.fa-spin {
    animation: spin 2s linear infinite;
}

/* ============================================ */
/* IMPRESSÃO */
/* ============================================ */

@media print {
    .navbar,
    .item-form,
    .btn,
    #menu-categorias,
    .col-md-4 .card:not(:first-child) {
        display: none !important;
    }
    
    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }
    
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
    
    .lista-item {
        break-inside: avoid;
    }
}




/* Esconder texto em dispositivos móveis */
@media (max-width: 768px) {
    .btn-danger .texto-limpar {
        display: none;
    }
}

/* Mostrar texto em tablets e desktop */
@media (min-width: 769px) {
    .btn-danger .texto-limpar {
        display: inline;
    }
}