/* Tablet / escritorio.
   base.css es mobile-first (columna de 480px + barra inferior). Acá se reacomoda el
   shell de la app para pantallas anchas sin tocar el HTML de cada página: cualquier
   página que use .app-shell / .app-topbar / .app-content / .bottom-nav lo hereda.
   Se carga después de base.css (ver partials/head.php). */

:root{--sidebar-w:240px;--topbar-h:64px;}

/* ---- Teclado y mouse (todas las pantallas) ---- */
:where(a,button,input,select,textarea,summary):focus-visible{outline:2px solid var(--green-dark);outline-offset:2px;}
.list-item-card,.route-btn,.logout-link{transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease;}
a.card-accent{transition:transform .15s ease, box-shadow .15s ease;}
@media (hover:hover){
  a.list-item-card:hover{border-color:var(--green);box-shadow:0 12px 24px -18px oklch(30% 0.03 280 / 0.45);}
  a.card-accent:hover{transform:translateY(-2px);box-shadow:0 20px 32px -18px oklch(46% 0.13 292 / 0.55);}
  .route-btn:hover{background:var(--violet);color:white;}
  .logout-link:hover{color:var(--ink);}
}

/* ---- Tablet: sigue la barra inferior, pero la columna respira más ---- */
@media (min-width:600px) and (max-width:899.98px){
  .app-shell{max-width:640px;}
  .app-content{padding-left:28px;padding-right:28px;}
  .app-topbar{padding-left:28px;padding-right:28px;}
}

/* ---- Escritorio: sidebar lateral + topbar de ancho completo ---- */
.app-topbar-brand{color:inherit;}
.app-brand-name{font-family:'Quicksand',sans-serif;font-weight:700;font-size:15px;color:var(--ink);}
.app-brand-name span{color:var(--green-dark);}
.app-topbar-actions{display:flex;align-items:center;gap:12px;}
.app-topbar-user{display:none;text-align:right;line-height:1.25;}
.app-topbar-user-name{font-size:13.5px;font-weight:700;color:var(--ink);}
.app-topbar-user-role{font-size:11.5px;font-weight:600;color:var(--ink-faint);}

@media (min-width:900px){
  .app-shell{
    max-width:none;
    display:grid;
    grid-template-columns:var(--sidebar-w) minmax(0,1fr);
    grid-template-rows:auto 1fr;
  }

  .app-topbar{
    grid-column:1 / -1;grid-row:1;
    position:sticky;top:0;z-index:30;
    height:var(--topbar-h);
    padding:0 clamp(20px,3vw,40px);
    display:flex;align-items:center;
    background:oklch(99.5% 0.002 95 / 0.92);
    backdrop-filter:blur(10px);
    border-bottom:1px solid var(--border);
  }
  .app-topbar-row{width:100%;}
  .app-topbar-brand img{width:34px;height:34px;}
  .app-brand-name{font-size:18px;}
  .app-topbar-actions{gap:16px;}
  .app-topbar-user{display:block;}
  .logout-link{font-size:13px;padding:8px 14px;border-radius:10px;color:var(--ink-soft);}
  .logout-link:hover{background:var(--paper);}
  .avatar-initials{width:40px;height:40px;}

  /* La barra inferior pasa a ser un menú lateral fijo */
  .bottom-nav{
    grid-column:1;grid-row:2;
    position:sticky;top:var(--topbar-h);
    align-self:start;
    height:calc(100vh - var(--topbar-h));
    flex-direction:column;align-items:stretch;justify-content:flex-start;
    gap:4px;
    padding:22px 14px;
    margin-top:0;
    border-top:0;border-right:1px solid var(--border);
    box-shadow:none;
    overflow-y:auto;
  }
  .bottom-nav a{flex-direction:row;gap:12px;font-size:14.5px;padding:11px 14px;border-radius:14px;color:var(--ink-soft);}
  .bottom-nav a:hover{background:var(--paper);color:var(--ink);}
  .bottom-nav a:active{transform:none;}
  .bottom-nav a svg{width:20px;height:20px;}
  .bottom-nav a.active{background:var(--green-soft);color:var(--green-dark);}
  .bottom-nav a.active::before{display:none;}
  .bottom-nav a.active svg{animation:none;}

  /* "Buscar" deja de ser el botón flotante: mismo lugar que el resto, con el ícono destacado */
  .bottom-nav a.raised{margin-top:0;gap:6px;padding:6px 14px 6px 8px;}
  .bottom-nav a.raised .nav-circle{width:32px;height:32px;box-shadow:0 6px 12px -6px oklch(55% 0.13 152 / 0.6);}
  .bottom-nav a.raised svg{width:18px;height:18px;}
  .bottom-nav a.raised:active .nav-circle{transform:none;}
  .bottom-nav a.raised:hover{background:var(--green-soft);}
  .bottom-nav a.raised[aria-current="page"]{background:var(--green-soft);}

  .app-content{
    grid-column:2;grid-row:2;
    width:100%;max-width:980px;margin:0 auto;
    padding:clamp(24px,3vw,40px) clamp(24px,3.4vw,48px) 64px;
    gap:22px;
  }
  .app-title{font-size:clamp(23px,2.1vw,30px);}
  .app-subtitle{font-size:15px;}
  .section-label{font-size:16px;}

  /* Componentes: tamaños pensados para puntero */
  .card{padding:22px 24px;border-radius:22px;}
  .list-item-card{padding:16px 18px;}
  .stat-row .stat-tile{flex:0 1 200px;padding:18px 12px;}
  .stat-tile .num{font-size:28px;}
  .stat-tile .label{font-size:12.5px;}
  .slot-chip{padding:10px 18px;font-size:14px;}
  .app-shell .tabs{max-width:360px;}
  .check-grid{grid-template-columns:repeat(auto-fill,minmax(210px,1fr));}
  .greeting-hero{padding:14px 18px;margin:0;}

  /* Botones y formularios: no se estiran a 900px */
  .app-shell .btn:not(.btn-small){max-width:380px;}
  .app-content > form.card{max-width:760px;}
  .card > form.stack{max-width:680px;}
  form.stack > .btn-small{align-self:flex-start;}

  /* Listas en grilla (las etiquetas de fecha ocupan la fila completa) */
  .list-stack{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr));gap:14px;}
  .list-stack > .section-label{grid-column:1 / -1;}

  /* Buscar: filtros en una sola fila */
  #buscar-form{max-width:none;flex-direction:row;flex-wrap:wrap;align-items:flex-end;gap:14px;}
  #buscar-form .field-row{display:contents;}
  #buscar-form .field{flex:1 1 200px;}
  #buscar-form .field input,#buscar-form .field select{height:46px;}
  #buscar-form .btn{flex:0 0 auto;align-self:flex-end;width:auto;height:46px;padding:0 28px;font-size:15px;}
  .buscar-map{height:340px;}
}

@media (min-width:1400px){
  :root{--sidebar-w:264px;}
  .app-content{max-width:1040px;}
}

/* Buscar: el wrapper mantiene el mismo ritmo vertical que tenía .app-content;
   en pantallas muy anchas queda lista + mapa lado a lado (el mapa se queda fijo al scrollear). */
.buscar-map{isolation:isolate;} /* los z-index internos de Leaflet (hasta 1000) no deben taparle el menú fijo */
.buscar-layout{display:flex;flex-direction:column;gap:16px;}
.buscar-map-col{display:flex;flex-direction:column;gap:16px;}
@media (min-width:1180px){
  .app-content:has(.buscar-map-col){max-width:1320px;}
  .buscar-layout:has(.buscar-map-col){
    display:grid;
    grid-template-columns:minmax(340px,5fr) minmax(0,7fr);
    gap:24px;align-items:start;
  }
  .buscar-layout:has(.buscar-map-col) .list-stack{grid-template-columns:1fr;}
  .buscar-map-col{
    order:2;
    position:sticky;top:calc(var(--topbar-h) + 24px);
    height:calc(100vh - var(--topbar-h) - 48px);min-height:420px;
    display:flex;flex-direction:column;gap:12px;
  }
  .buscar-map-col .buscar-map{flex:1;height:auto;min-height:0;}
  .buscar-map-col .route-info{flex-shrink:0;}
}
