/* ─────────────────────────────
    🍽️ Design Tokens
   ───────────────────────────── */
:root {
    /* Tipografia */
    --font-family: "Montserrat", sans-serif;
    --font-xs: 12px;
    --font-sm: 14px;
    --font-md: 16px;
    --font-weight-semibold: 600;

    /* Espaçamento */
    --space-xxs: 4px;
    --space-sm: 8px;
    --space-md: 10px;
    --space-lg: 14px;
    --space-xl: 16px;

    /* Componentes */
    --block-margin: var(--space-lg);
    --radius: 14px;
    --radius-sm: 8px;
    --border-width: 1px;
    --nav-height: 70px;
    --container-max-width: 600px;

    /* Cores de Interface */
    --bg-main: #0f1115;
    --bg-card: #1a1d23;
    --text-primary: #e6e6e6;
    --text-muted: #a0a6b1;
    --divider: #2a2f38;
    --teal-primary: #14b8a6;
    --teal-dark: #0f766e;
    --gray-5: #232730;

    /* Cores dos Dias da Semana */
    --domingo: #d96c9d; --domingo-dark: #6f2a4a;
    --segunda: #d96c6c; --segunda-dark: #6f2a2a;
    --terca: #d9916c;   --terca-dark: #6f452a;
    --quarta: #d9c46c;  --quarta-dark: #6f5f2a;
    --quinta: #6cd98a;  --quinta-dark: #2a6f45;
    --sexta: #6caed9;   --sexta-dark: #2a4f6f;
    --sabado: #a66cd9;  --sabado-dark: #4a2a6f;

    --modal-overlay: rgba(0, 0, 0, 0.85);
}

/* ─────────────────────────────
    🍽️ Base & Reset
   ───────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

html {
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

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

.anim-up {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* ─────────────────────────────
    🍽️ Layout & States
   ───────────────────────────── */
#app {
    padding: var(--space-xl);
    padding-bottom: calc(var(--nav-height) + var(--space-xl));
    display: flex;
    flex-direction: column;
    gap: var(--block-margin);
}

@media (min-width: 768px) {
    #app { max-width: var(--container-max-width); margin: 0 auto; }
}

.loading-msg, .error-msg {
    text-align: center;
    padding: 50px;
    font-weight: var(--font-weight-semibold);
}

.loading-msg { opacity: 0.5; }
.error-msg { color: var(--segunda); }

/* ─────────────────────────────
    📅 Header & Selectors
   ───────────────────────────── */
.date-display {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-xxs);
}

.day-label {
    font-weight: var(--font-weight-semibold);
    font-size: 1.2rem;
}

.date-label {
    font-size: var(--font-sm);
    color: var(--teal-primary);
    font-weight: var(--font-weight-semibold);
}

.day-selector {
    display: flex;
    justify-content: space-between;
    gap: var(--space-xxs);
    margin-bottom: var(--space-md);
    background: var(--bg-card);
    padding: var(--space-sm);
    border-radius: var(--radius);
    border: var(--border-width) solid var(--divider);
}

.day-btn {
    flex: 1;
    background: var(--gray-5);
    border: none;
    color: var(--text-muted);
    padding: var(--space-sm) 0;
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all 0.2s ease;
}

.day-btn.active {
    background: var(--teal-primary);
    color: var(--bg-main);
}

.day-btn.is-today:not(.active) {
    background-color: var(--teal-dark);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─────────────────────────────
    🍽️ Cards & Accordion
   ───────────────────────────── */
.cards-stack {
    display: flex;
    flex-direction: column;
    gap: var(--block-margin);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: var(--border-width) solid var(--divider);
    overflow: hidden;
}

.card-header {
    padding: var(--space-lg);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    transition: background 0.3s ease;
}

.card-header span:first-child {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Cor padrão para categorias/refeições (fora da aba semana) */
.card:not(.domingo):not(.segunda):not(.terca):not(.quarta):not(.quinta):not(.sexta):not(.sabado) .card-header {
    background: var(--teal-primary);
    color: var(--teal-dark);
}

.item-counter {
    opacity: 0.7;
    font-size: 0.75em;
    margin-left: 5px;
}

.accordion-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem;
    opacity: 0.7;
}

.card:not(.collapsed) .accordion-arrow {
    transform: rotate(180deg);
}

/* Conteúdo com animação suave */
.card-content {
    max-height: 2000px;
    opacity: 1;
    padding: var(--space-lg);
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease, 
                padding 0.4s ease;
}

.card.collapsed .card-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

/* ─────────────────────────────
    🍽️ Rows & Items
   ───────────────────────────── */
.row {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    font-size: var(--font-sm);
    align-items: center;
}

.row:last-child { margin-bottom: 0; }

.row span:first-child {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.row span:last-child {
    background: var(--gray-5);
    padding: var(--space-xxs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    color: var(--text-muted);
}

/* Controle de ícones nas rows */
.row i {
    display: none;
    color: var(--text-muted);
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

/* Ícones aparecem apenas em cards com classe de dia da semana */
.card[class*="segunda"] .row i, .card[class*="terca"] .row i, 
.card[class*="quarta"] .row i, .card[class*="quinta"] .row i, 
.card[class*="sexta"] .row i, .card[class*="sabado"] .row i, 
.card[class*="domingo"] .row i {
    display: inline-block;
}

.empty-row { opacity: 0.3; }
.empty-style { opacity: 0.2; }

/* Receitas */
.has-recipe {
    color: var(--teal-primary) !important;
    cursor: pointer;
}

.recipe-icon {
    font-size: 0.7rem;
    margin-left: var(--space-xxs);
    opacity: 0.7;
    display: inline-block !important;
}

/* ─────────────────────────────
    🍳 Modal de Receitas
   ───────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: var(--container-max-width);
    border-radius: 24px 24px 0 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: var(--space-xl);
    border: var(--border-width) solid var(--divider);
    border-bottom: none;
    animation: fadeInUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

#modal-title {
    font-size: 1.3rem;
    color: var(--teal-primary);
    font-weight: var(--font-weight-semibold);
}

.close-btn {
    background: var(--gray-5);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.recipe-time {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(20, 184, 166, 0.1);
    color: var(--text-muted);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-lg);
    width: fit-content;
}

.recipe-section-title {
    font-size: var(--font-md);
    font-weight: var(--font-weight-semibold);
    margin: var(--space-xl) 0 var(--space-sm) 0;
    color: var(--teal-primary);
}

.recipe-prep-text {
    font-size: var(--font-sm);
    color: var(--text-muted);
    background: var(--gray-5);
    padding: var(--space-lg);
    border-radius: var(--radius);
    
    /* Mantemos o flex para que as divs (.prep-step) se alinhem corretamente */
    display: flex;
    flex-direction: column;
    
    /* White-space: pre-wrap pode ser removido pois agora usamos divs individuais, 
       mas manter não quebra nada. */
    word-wrap: break-word;
}

.prep-step {
    /* É aqui que a mágica acontece: o espaço entre cada parágrafo */
    margin-bottom: 12px; 
    line-height: 1.5; /* Um espaçamento de linha interno mais confortável para leitura */
    display: block;
}

.prep-step:last-child {
    margin-bottom: 0;
}

.modal-footer {
    margin-top: var(--space-xl);
    padding-bottom: var(--space-sm);
}

.btn-confirm {
    width: 100%;
    padding: var(--space-lg);
    border-radius: var(--radius);
    border: none;
    background: var(--teal-primary);
    color: var(--bg-main);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-md);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.btn-confirm:active {
    opacity: 0.8;
}
/* ─────────────────────────────
    🧭 Navigation
   ───────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--bg-card);
    display: flex;
    border-top: var(--border-width) solid var(--divider);
    z-index: 100;
}

.bottom-nav button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease;
}

.bottom-nav button i {
    font-size: 1.2rem;
    margin-bottom: var(--space-xxs);
}

.bottom-nav button.active {
    color: var(--teal-primary);
}

.bottom-nav button.active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 40%;
    height: 3px;
    background: var(--teal-primary);
    border-radius: 0 0 4px 4px;
}

/* 🎨 SECTION: Daily Colors */
.domingo .card-header { background: var(--domingo); color: var(--domingo-dark); }
.segunda .card-header { background: var(--segunda); color: var(--segunda-dark); }
.terca .card-header   { background: var(--terca); color: var(--terca-dark); }
.quarta .card-header  { background: var(--quarta); color: var(--quarta-dark); }
.quinta .card-header  { background: var(--quinta); color: var(--quinta-dark); }
.sexta .card-header   { background: var(--sexta); color: var(--sexta-dark); }
.sabado .card-header  { background: var(--sabado); color: var(--sabado-dark); }

/* Ajuste de ícones nos headers coloridos */
.card[class*="domingo"] .card-header i, .card[class*="segunda"] .card-header i,
.card[class*="terca"] .card-header i, .card[class*="quarta"] .card-header i,
.card[class*="quinta"] .card-header i, .card[class*="sexta"] .card-header i,
.card[class*="sabado"] .card-header i {
    color: rgba(0,0,0,0.4);
}