/* =========================================================
   NUTRILAB — Estilos globales
   Complementa Tailwind CSS con componentes personalizados
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    background-color: #000d14;
    color: #ffffff;
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ---- Tipografía display ---- */
.font-display { font-family: 'Bebas Neue', Impact, sans-serif; }

/* ---- Scrollbar personalizada ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #000d14; }
::-webkit-scrollbar-thumb { background: #003a55; border-radius: 2px; }

/* ---- Layout base con barra inferior ---- */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.app-content {
    flex: 1;
    padding-top: 64px;   /* Header fijo */
    padding-bottom: 80px; /* Navbar inferior */
    overflow-y: auto;
}

/* ---- Header fijo ---- */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(0, 13, 20, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #003a55;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

/* ---- Navbar inferior fija ---- */
.app-navbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 72px;
    background: rgba(0, 33, 48, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid #003a55;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #a0aec0;
    min-width: 60px;
    text-align: center;
}

.nav-item.active { color: #ff3e35; }
.nav-item:hover  { color: #ffffff; }

.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }

/* ---- Botones ---- */
.btn-primary {
    background: #ff3e35;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover   { background: #cc322b; }
.btn-primary:active  { transform: scale(0.98); }
.btn-primary:disabled{ background: #444; cursor: default; opacity: 0.6; }

.btn-secondary {
    background: #002130;
    color: #ffffff;
    border: 1px solid #003a55;
    border-radius: 10px;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-secondary:hover { background: #003050; border-color: #ff3e35; }

.btn-ghost {
    background: transparent;
    color: #a0aec0;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover { background: #002130; color: #fff; }

/* ---- Tarjetas ---- */
.card {
    background: #002130;
    border: 1px solid #003a55;
    border-radius: 16px;
    padding: 20px;
}

.card-sm {
    background: #002130;
    border: 1px solid #003a55;
    border-radius: 12px;
    padding: 14px;
}

/* ---- Tarjeta de receta ---- */
.recipe-card {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 4/5;
    background: #002130;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,62,53,0.15); }
.recipe-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.recipe-card .overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,13,20,0.97) 0%, rgba(0,13,20,0.6) 60%, transparent 100%);
    padding: 12px 10px 10px;
}
.recipe-card .badge {
    position: absolute;
    top: 8px; left: 8px;
    background: #ff3e35;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 3px 7px;
    border-radius: 4px;
    text-transform: uppercase;
}
.recipe-card .badge.mercadona { background: #1e7e34; }

/* ---- Inputs ---- */
.input {
    width: 100%;
    background: #000d14;
    border: 1px solid #003a55;
    border-radius: 10px;
    color: #ffffff;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.input:focus { border-color: #ff3e35; }
.input::placeholder { color: #4a6070; }
.input:disabled { opacity: 0.5; cursor: not-allowed; }

select.input { cursor: pointer; }

/* ---- Labels ---- */
.label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* ---- Macros pills ---- */
.macro-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #001520;
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 56px;
}
.macro-pill .value { font-size: 16px; font-weight: 700; color: #fff; }
.macro-pill .value.protein { color: #ff3e35; }
.macro-pill .key   { font-size: 9px; font-weight: 600; color: #a0aec0; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Barra de macros ---- */
.macro-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; }
.macro-bar .seg-p { background: #ff3e35; border-radius: 3px; }
.macro-bar .seg-c { background: #3b82f6; border-radius: 3px; }
.macro-bar .seg-f { background: #f59e0b; border-radius: 3px; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn .2s ease;
}
@media (min-width: 640px) {
    .modal-overlay { align-items: center; }
}
.modal-content {
    background: #001520;
    border: 1px solid #003a55;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUp .25s ease;
}
@media (min-width: 640px) {
    .modal-content { border-radius: 20px; max-height: 85vh; }
}

/* ---- Filtros ---- */
.filter-chip {
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: 1px solid #003a55;
    background: #002130;
    color: #a0aec0;
}
.filter-chip.active { background: #ff3e35; border-color: #ff3e35; color: #fff; }
.filter-chip:hover:not(.active) { border-color: #ff3e35; color: #fff; }

/* ---- Tracker días ---- */
.tracker-day {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid #003a55;
    background: #001520;
    color: #4a6070;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tracker-day.completed {
    background: #ff3e35;
    border-color: #ff3e35;
    color: #fff;
}
.tracker-day:hover { border-color: #ff3e35; color: #fff; }

/* ---- Planner tabla ---- */
.planner-cell {
    background: #001520;
    border: 1px solid #003a55;
    border-radius: 8px;
    padding: 8px;
    min-height: 64px;
    cursor: pointer;
    transition: border-color 0.2s;
    font-size: 11px;
    line-height: 1.3;
}
.planner-cell:hover    { border-color: #ff3e35; }
.planner-cell.has-recipe { border-color: #003a55; background: #002130; }
.planner-cell .meal-name { color: #fff; font-weight: 600; font-size: 11px; }
.planner-cell .meal-kcal { color: #ff3e35; font-size: 10px; margin-top: 2px; }

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #002130;
    border: 1px solid #003a55;
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 500;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    animation: slideUp .25s ease;
}
.toast.success { border-color: #22c55e; color: #22c55e; }
.toast.error   { border-color: #ff3e35; color: #ff3e35; }

/* ---- Animaciones ---- */
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin     { to { transform: rotate(360deg); } }

.animate-spin { animation: spin 1s linear infinite; }

/* ---- Loading spinner ---- */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid #003a55;
    border-top-color: #ff3e35;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---- Sección vacía ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #4a6070;
    text-align: center;
    gap: 12px;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.5; }
.empty-state p   { font-size: 15px; line-height: 1.5; }

/* ---- Responsive grid de recetas ---- */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 480px) { .recipes-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .recipes-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 1024px){ .recipes-grid { grid-template-columns: repeat(5, 1fr); } }

/* ---- Imagen placeholder para recetas sin imagen ---- */
.recipe-placeholder {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #002130 0%, #001520 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

/* ---- Barra de búsqueda ---- */
.search-bar {
    position: relative;
}
.search-bar input { padding-left: 40px; }
.search-bar .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #4a6070;
    pointer-events: none;
}

/* ---- Scrollable horizontal (filtros) ---- */
.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ---- Segmented control ---- */
.segmented {
    display: flex;
    background: #001520;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.segmented button {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: #a0aec0;
}
.segmented button.active { background: #ff3e35; color: #fff; }

/* ---- Badge de categoría ---- */
.category-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: #ff3e35;
    color: #fff;
}
.category-badge.MERCADONA  { background: #1e7e34; }
.category-badge.KETO       { background: #7c3aed; }
.category-badge.BULK       { background: #1d4ed8; }
.category-badge.FITFAT     { background: #b45309; }
.category-badge.DESAYUNO   { background: #b45309; }
.category-badge.SNACK      { background: #0e7490; }
.category-badge.POSTRE     { background: #be185d; }

/* ---- Progreso circular (tracker) ---- */
.progress-ring { transform: rotate(-90deg); }
.progress-ring-circle { transition: stroke-dashoffset 0.5s ease; }
