/* =========================================================
   Recetario Moderno — Tema Oscuro Gourmet
   ========================================================= */
:root {
  --bg: #121418;
  --bg-elev: #1a1c22;
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --line: #2c2f36;

  --brand: #facc15;
  --brand-2: #f59e0b;
  --accent: #22d3ee;
  --danger: #ef4444;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,.6);

  --pill-bg: #2b2f37;
  --pill-ink: #e2e8f0;

  --card-img-h: 160px;
  --grid-min: 260px;
  --focus: 0 0 0 3px rgba(250,204,21,.3);
}

*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Topbar */
.topbar{
  position: sticky; top:0; z-index:20;
  display:grid; grid-template-columns:auto 1fr auto; gap:14px;
  align-items:center;
  padding:16px 20px;
  background: rgba(18,20,24,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1{margin:0; color:var(--brand); font-size: clamp(18px,2vw,22px);}

.searchbar{display:flex; gap:10px; align-items:center}
.searchbar input{
  width:100%;
  background:#0f1115;
  border:1px solid #2d2f35;
  color:var(--ink);
  border-radius: var(--radius-md);
  padding:10px 14px;
  box-shadow: var(--shadow-sm);
}
.searchbar input::placeholder{ color:#717b8f }

.filters{display:flex; gap:12px; align-items:center; color:var(--muted) }
select, input[type="checkbox"]{ accent-color: var(--brand); }

button{
  background:#22252c;
  border:1px solid #2f323a;
  color:var(--ink);
  border-radius: var(--radius-md);
  padding:8px 14px;
  cursor:pointer;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
button:hover{ background:#2d3038; box-shadow: var(--shadow-md) }
button.primary{ background:linear-gradient(145deg,var(--brand),var(--brand-2)); color:#1a1a1a; border:none }
button.primary:hover{ box-shadow:0 0 12px rgba(250,204,21,.35) }
button.small{ height:34px; padding:0 10px; font-size:14px }
button.ghost{ background:transparent }

/* Layout */
.layout{ display:grid; grid-template-columns: 360px 1fr; gap:20px; padding:20px; align-items:start }
.sidebar,.results{
  background: var(--bg-elev);
  border:1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding:16px;
}
.section-title{ margin:0 0 12px 0; color:var(--brand); font-weight:700 }

/* Grid & Cards */
.grid{ display:grid; gap:14px; grid-template-columns: repeat(auto-fill,minmax(var(--grid-min),1fr)) }
.card{
  display:flex; flex-direction:column;
  background:#1f2229;
  border:1px solid #2f333c;
  border-radius: var(--radius-lg);
  overflow:hidden;
  transition: transform .15s ease, box-shadow .3s ease;
}
.card:hover{ transform: translateY(-3px); box-shadow: 0 10px 30px rgba(250,204,21,.15) }
.card img{ width:100%; height:var(--card-img-h); object-fit:cover }
.card .body{ padding:12px; display:grid; gap:10px }
.card h3{ margin:0; font-size:16px }
.tags{ display:flex; flex-wrap:wrap; gap:8px; color:var(--muted) }
.badge{ background:var(--pill-bg); color:var(--pill-ink); padding:4px 10px; border-radius:999px; font-size:12px; }
.actions{ display:flex; justify-content:space-between; align-items:center; gap:8px }
.fav-btn{ font-weight:700 }

/* Estados */
.loading,.empty{ color:var(--muted); padding:12px; text-align:center }

/* Favoritos */
.fav-list{ list-style:none; margin:8px 0 12px 0; padding:0; display:grid; gap:8px }
.fav-list li{ background:#1f2329; border:1px solid #333740; border-radius: var(--radius-md); padding:8px 10px; display:flex; justify-content:space-between; align-items:center }
.fav-list a{ color:var(--brand); text-decoration:none }

/* Footer */
.footer{ border-top:1px solid var(--line); padding:12px 20px; color:var(--muted); background:#0e0f12; text-align:center }

/* Focus */
:focus-visible{ outline:none; box-shadow: var(--focus); border-radius:8px }

/* Responsive */
@media (max-width: 1100px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ order:-1 }
}

/* =========================================================
   Mejoras de Responsividad (Mobile-First)
   ========================================================= */

@media (max-width: 768px) {
  /* Topbar: Apilado vertical para mejor uso del espacio */
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px;
    position: sticky; /* Se mantiene pegajoso pero más compacto */
  }

  .topbar h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 2px;
  }

  .searchbar {
    width: 100%;
  }

  .searchbar input {
    font-size: 16px; /* Evita que iOS haga zoom al enfocar */
    padding: 12px;
  }

  /* Filtros: Ajuste para pantallas táctiles */
  .filters {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }

  .filters label {
    font-size: 14px;
    background: rgba(255,255,255,0.03);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
    min-width: 140px;
    border: 1px solid var(--line);
  }

  #btnSearch {
    width: 100%;
    height: 46px;
    margin-top: 4px;
    font-weight: 700;
  }

  /* Layout: Ajuste de espaciado */
  .layout {
    padding: 10px;
    gap: 16px;
  }

  .sidebar {
    padding: 12px;
  }

  /* Ajustamos la lista de favoritos para que no ocupe toda la pantalla vertical */
  .fav-list {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
  }

  /* Grid: Una sola columna clara en móvil */
  .grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card .body {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 1.3rem; }
  
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  
  #btnSearch {
    grid-column: span 2;
  }

  /* Acciones de la tarjeta: botones más grandes para dedos */
  .card .actions {
    flex-direction: column;
    gap: 10px;
  }

  .card .actions a, 
  .card .actions button {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 12px;
  }
}
