/**
 * 🎨 ESTILOS DO TRACKER INTEGRADO
 * Estilização para os resultados de busca e meal items
 */

/* Resultados de busca */
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    border-left: 4px solid #2d5a27;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.result-item:hover {
    background: #e8f5e9;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(45, 90, 39, 0.15);
}

.result-name {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-name strong {
    color: #1b3a1a;
    font-weight: 600;
}

.result-category {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9em;
    color: #555;
    margin: 0 12px;
    text-align: right;
}

.btn-add-result {
    padding: 6px 12px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-add-result:hover {
    background: #388e3c;
}

/* Items da refeição */
.meal-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    margin: 8px 0;
    background: #f9f9f9;
    border-left: 4px solid #2d5a27;
    border-radius: 4px;
}

.meal-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.meal-item-header strong {
    font-weight: 600;
    color: #1b3a1a;
    flex: 1;
}

.meal-item-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.meal-item-controls .qty-input {
    width: 70px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.meal-item-controls .qty-unit {
    font-size: 0.9em;
    color: #666;
    min-width: 30px;
}

.meal-item-name {
    font-weight: 600;
    color: #1b3a1a;
}

.meal-item-quantity {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meal-item-quantity input {
    width: 60px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.meal-item-nutrients {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85em;
    color: #666;
    text-align: right;
}

.btn-remove-meal {
    padding: 6px 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-remove-meal:hover {
    background: #ff5252;
}

/* Estado vazio */
.empty-meal {
    padding: 20px;
    text-align: center;
    color: #333;
    font-style: italic;
    background: #f5f5f5;
    border-radius: 4px;
    border: 2px dashed #2d5a27;
}

/* Search results container */
#search-results {
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

/* tornar os resultados um overlay posicionado abaixo da barra de busca */
.search-bar {
    position: relative;
}

#search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    box-shadow: 0 8px 24px rgba(15, 23, 15, 0.12);
    z-index: 1000;
}

#search-results[style*="display: none"] {
    display: none !important;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #e8f5e9;
    border-bottom: 1px solid #ddd;
    font-size: 0.9em;
    font-weight: 600;
    color: #2d5a27;
}

.btn-clear {
    padding: 4px 8px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85em;
}

.btn-clear:hover {
    background: #f57c00;
}

/* Meal list */
.meal-list {
    background: white;
    border: 2px solid #2d5a27;
    border-radius: 4px;
    padding: 12px;
    min-height: 100px;
}

/* Botões de ação - Tracker */
.btn-save-meal,
.btn-clear-meal,
#save-meal-btn,
#clear-meal-btn,
#add-food-btn,
.btn-add {
    display: inline-block;
    padding: 10px 16px;
    margin: 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-save-meal,
#save-meal-btn {
    background: #2d5a27 !important;
    color: white !important;
}

.btn-save-meal:hover,
#save-meal-btn:hover {
    background: #1b3a1a !important;
    box-shadow: 0 2px 8px rgba(45, 90, 39, 0.3) !important;
}

.btn-clear-meal,
#clear-meal-btn {
    background: #ff9800 !important;
    color: white !important;
}

.btn-clear-meal:hover,
#clear-meal-btn:hover {
    background: #f57c00 !important;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3) !important;
}

#add-food-btn,
.btn-add {
    background: #4caf50 !important;
    color: white !important;
}

#add-food-btn:hover,
.btn-add:hover {
    background: #388e3c !important;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .result-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-info {
        margin-left: 0;
        text-align: left;
        width: 100%;
    }

    .meal-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .meal-item-nutrients {
        text-align: left;
    }
}

/* Layout horizontal do Tracker: faz o tracker ocupar o espaço principal
   e posiciona os cards de configuração secundários ao lado ou abaixo conforme largura */
.acompanhamento-calorias,
#acompanhamento-calorias {
    max-width: none !important;
    width: calc(100% - 4rem) !important;
    margin: 1.5rem auto !important;
    padding: 1.5rem !important;
}

.acompanhamento-calorias .calorias-grid,
#acompanhamento-calorias .calorias-grid {
    display: flex !important;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
}

/* Cartão principal (tracking) ocupa a maior parte do espaço horizontal */
.acompanhamento-calorias .tracking-card,
#acompanhamento-calorias .tracking-card {
    flex: 1 1 900px !important;
    min-width: 560px;
    max-width: calc(100% - 320px);
    box-sizing: border-box;
}

/* Cards secundários mantêm largura fixa e caem abaixo em telas pequenas */
.acompanhamento-calorias .config-card,
.acompanhamento-calorias .premium-card,
#acompanhamento-calorias .config-card,
#acompanhamento-calorias .premium-card {
    flex: 0 0 320px;
    max-width: 360px;
}

/* Em telas pequenas, empilha tudo em coluna, com o tracking no topo */
@media (max-width: 1100px) {

    .acompanhamento-calorias .calorias-grid,
    #acompanhamento-calorias .calorias-grid {
        flex-direction: column;
    }

    .acompanhamento-calorias .tracking-card,
    .acompanhamento-calorias .config-card,
    .acompanhamento-calorias .premium-card,
    #acompanhamento-calorias .tracking-card,
    #acompanhamento-calorias .config-card,
    #acompanhamento-calorias .premium-card {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

/* Corrigir overlay premium bloqueando cliques: deixar o overlay visual mas permitir interação
   com elementos subjacentes (como o seletor). O conteúdo central do overlay continua clicável. */
#premium-overlay {
    pointer-events: none !important;
}

#premium-overlay .premium-content {
    pointer-events: auto !important;
}

/* Ajustes de legibilidade para a página completa do tracker */
/* Aplica cores mais escuras dentro do container do tracker full-page (#tracker-root) */
#tracker-root,
#tracker-root * {
    color: #1b3a1a !important;
}

.page-container {
    background: #ffffff;
    color: #1b3a1a;
}

#tracker-root .search-input,
#tracker-root .food-selector,
#tracker-root .quantity-input {
    background: #ffffff !important;
    color: #111 !important;
}

#tracker-root .result-item {
    background: #ffffff !important;
    color: #111 !important;
    border-left-color: #2d5a27 !important;
}

#tracker-root .results-list,
#tracker-root .meal-list {
    background: #fafafa !important;
}

/* ========== NOVOS ESTILOS PARA RENDERIZAÇÃO SIMPLIFICADA ========== */

.meal-item-simple {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 12px !important;
    margin: 8px 0 !important;
    background: #f9f9f9 !important;
    border-left: 4px solid #2d5a27 !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    z-index: 10 !important;
    grid-template-columns: unset !important;
}

.meal-item-simple:hover {
    background: #f0f0f0 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.meal-item-header-simple {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
}

.meal-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    flex: 1 !important;
}

.meal-info strong {
    font-weight: 600 !important;
    color: #1b3a1a !important;
    font-size: 1em !important;
    display: block !important;
}

.meal-category {
    font-size: 0.85em !important;
    color: #666 !important;
    font-style: italic !important;
    display: block !important;
}

.btn-remove-simple {
    background: #ff6b6b !important;
    color: white !important;
    border: none !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    transition: background 0.2s ease !important;
    flex-shrink: 0 !important;
    min-width: 40px !important;
    text-align: center !important;
}

.btn-remove-simple:hover {
    background: #ff5252 !important;
}

.meal-item-qty-editor {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px !important;
    background: #fff !important;
    border-radius: 4px !important;
    border: 1px solid #ddd !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
}

.meal-item-qty-editor label {
    font-weight: 500 !important;
    color: #333 !important;
    font-size: 0.9em !important;
    min-width: 90px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

.qty-input-simple {
    width: 70px !important;
    padding: 6px !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    font-size: 0.95em !important;
    font-weight: 600 !important;
    text-align: center !important;
    background: #fff !important;
    color: #333 !important;
    flex-shrink: 0 !important;
}

.qty-input-simple:focus {
    outline: none !important;
    border-color: #2d5a27 !important;
    box-shadow: 0 0 4px rgba(45, 90, 39, 0.2) !important;
}

.qty-unit {
    color: #555 !important;
    font-size: 0.9em !important;
    min-width: 25px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-weight: 500 !important;
}

.meal-item-nutrition-simple {
    display: flex !important;
    gap: 12px !important;
    padding: 10px !important;
    background: #e8f5e9 !important;
    border-radius: 4px !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
}

.meal-item-nutrition-simple .nutrient {
    font-weight: 600 !important;
    color: #1b3a1a !important;
    font-size: 0.95em !important;
    white-space: nowrap !important;
    padding: 2px 0 !important;
}

.meal-item-nutrition-simple .nutrient:first-child {
    color: #d97706 !important;
    font-weight: 700 !important;
}