/* =====================================================================
   style.css  -  Estilo de la web de viandas (mobile-first).
   ===================================================================== */
:root {
    --bg:      #f4f5f7;
    --card:    #ffffff;
    --ink:     #1f2430;
    --muted:   #6b7280;
    --brand:   #e8590c;
    --brand-d: #c94b06;
    --line:    #e5e7eb;
    --ok-bg:   #e7f6ec;  --ok-ink:  #1b7a3d;
    --err-bg:  #fdecea;  --err-ink: #b3261e;
    --lock-bg: #eef1f5;  --lock-ink:#4b5563;
    --radius:  14px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
}
/* Ninguna imagen desborda su contenedor, sea cual sea su resolución. */
img { max-width: 100%; height: auto; }
.codeblock {
    background: #1e293b; color: #e2e8f0; padding: .8rem 1rem; border-radius: 8px;
    overflow-x: auto; font-size: .85rem; line-height: 1.4; margin: .6rem 0;
    white-space: pre; font-family: ui-monospace, Menlo, Consolas, monospace;
}

.brand { font-weight: 700; font-size: 1.15rem; }
.muted { color: var(--muted); }
.link  { color: var(--brand); text-decoration: none; margin-left: .75rem; }
.link:hover { text-decoration: underline; }

/* --- Barra superior --- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); padding: .8rem 1rem;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar__right { font-size: .95rem; color: var(--muted); }

/* --- Contenedores --- */
.wrap { max-width: 520px; margin: 0 auto; padding: 1.1rem 1rem 3rem; }
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.1rem;
}
.card--login { max-width: 380px; margin: 10vh auto 0; padding: 1.6rem; }
h1 { font-size: 1.35rem; margin: .2rem 0 .3rem; }

/* --- Formularios --- */
.form label, label {
    display: block; font-size: .9rem; font-weight: 600; margin-bottom: .9rem;
}
input, select {
    width: 100%; padding: .7rem .8rem; margin-top: .35rem;
    font-size: 1rem; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; color: var(--ink);
}
select:disabled { background: var(--lock-bg); color: var(--muted); }

.btn {
    display: inline-block; border: 0; border-radius: 10px; cursor: pointer;
    padding: .75rem 1.1rem; font-size: 1rem; font-weight: 600;
    text-decoration: none; text-align: center;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-d); }
.btn--ghost {
    background: #fff; color: var(--brand); border: 1px solid var(--brand);
}
.btn--block { width: 100%; margin-top: .4rem; }

/* --- Filas de días --- */
.dia-row {
    display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .6rem;
    align-items: center; padding: .55rem 0; border-top: 1px solid var(--line);
}
.dia-row:first-of-type { border-top: 0; }
.dia-row__label { display: flex; flex-direction: column; }
.dia-row__label .muted { font-size: .8rem; }
.dia-row--lock select { opacity: .8; }

/* --- Referencia semana pasada --- */
.refbox__head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.reflist { list-style: none; margin: 0 0 .9rem; padding: 0; }
.reflist li {
    display: flex; justify-content: space-between;
    padding: .3rem 0; border-bottom: 1px dashed var(--line);
}
.reflist li:last-child { border-bottom: 0; }
.reflist__dia { color: var(--muted); }

/* --- Badges / alerts --- */
.badge {
    font-size: .72rem; font-weight: 700; padding: .2rem .5rem;
    border-radius: 999px; white-space: nowrap;
}
.badge--lock { background: var(--lock-bg); color: var(--lock-ink); }
/* --- Panel admin --- */
.wrap--wide { max-width: 720px; }
.cliente-card__head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: .5rem; margin-bottom: .7rem; padding-bottom: .5rem;
    border-bottom: 1px solid var(--line);
}
.cliente-card__nombre { font-weight: 700; font-size: 1.05rem; }
.cliente-card__ids { font-size: .82rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.cliente-card__foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: .9rem;
}
.check { display: flex; align-items: center; gap: .4rem; font-weight: 600; margin: 0; }
.check input { width: auto; margin: 0; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

/* --- Nav admin --- */
.topbar__nav { display: flex; gap: .25rem; align-items: center; }
.link--active { font-weight: 700; text-decoration: underline; }

/* --- Tabla de pedidos (admin debug) --- */
.tabla-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--card); }
.tabla th, .tabla td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabla thead th { background: #f9fafb; color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .small { font-size: .78rem; }
.fila-perm { background: #fbfbfd; }
.est { font-size: .74rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; }
.est--pendiente  { background: #fff7ed; color: #92400e; }
.est--descargado { background: var(--ok-bg); color: var(--ok-ink); }
.est--mixto      { background: #eef2ff; color: #3730a3; }

/* --- Buscador (lista de clientes) --- */
.buscador { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: 1.1rem; }
.buscador input { flex: 1; width: auto; margin: 0; }
.buscador .small { font-size: .8rem; white-space: nowrap; }
.cli-saved { box-shadow: 0 0 0 2px var(--brand); transition: box-shadow .25s; }

/* --- Formularios "Nuevo" (crear cliente / menú) --- */
.nuevo summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.nuevo-form { margin-top: .9rem; }
.nuevo-form button { margin-top: .6rem; }

/* --- Selector de semana (admin menús) --- */
.weekpick {
    display: flex; align-items: flex-end; gap: .6rem; flex-wrap: wrap;
    margin-bottom: 1rem;
}
.weekpick label { margin: 0; }
.weekpick input { width: auto; }

/* --- Visibilidad de menú (admin) --- */
.visib { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .7rem 0; margin: .3rem 0 .9rem; }
.visib__lista { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .6rem 0; }
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: var(--lock-bg); border-radius: 999px; padding: .18rem .3rem .18rem .6rem; font-size: .85rem;
}
.chip form { display: inline; margin: 0; }
.chip button {
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 0 .15rem;
}
.chip button:hover { color: var(--err-ink); }
.visib__add { display: flex; gap: .5rem; align-items: flex-start; }
.combo { position: relative; flex: 1 1 12rem; }
.combo-input { width: 100%; }
.combo-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    margin: .2rem 0 0; padding: .2rem; list-style: none; max-height: 220px;
    overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,.10);
}
.combo-list li { padding: .45rem .6rem; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.combo-list li:hover { background: var(--lock-bg); }

/* --- Tarjeta de menú (admin) --- */
.menu-card__head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: .7rem;
}
.menu-img {
    width: 100%; max-width: 320px; aspect-ratio: 4/3; object-fit: cover;
    border-radius: 10px; border: 1px solid var(--line); display: block;
}
.menu-img--empty {
    display: flex; align-items: center; justify-content: center;
    background: var(--lock-bg); color: var(--muted); font-size: .9rem;
}
.menu-upload { display: flex; gap: .6rem; flex-wrap: wrap; margin: .9rem 0; align-items: center; }
.menu-upload input[type=file] { width: auto; flex: 1 1 12rem; }

.reuse { margin-top: .4rem; }
.reuse summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.reuse__grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: .5rem; margin-top: .7rem;
}
.reuse__item { margin: 0; }
.reuse__btn {
    padding: 0; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; cursor: pointer; overflow: hidden; width: 100%;
}
.reuse__btn:hover { border-color: var(--brand); }
.reuse__btn img { width: 100%; height: 70px; object-fit: cover; display: block; }

/* --- Galería de menús (cliente) --- */
.menu-galeria {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .7rem; margin-top: .6rem;
}
.menu-galeria__item { margin: 0; }
.menu-galeria__item img {
    width: 100%; aspect-ratio: 4/3; object-fit: cover;
    border-radius: 10px; border: 1px solid var(--line);
}
.menu-galeria__item figcaption {
    text-align: center; font-size: .85rem; margin-top: .25rem; color: var(--muted);
}

/* --- Selector de semana (cliente) --- */
.weeknav__row { display: flex; align-items: center; gap: .5rem; }
.weeknav__label { flex: 1; text-align: center; }
.weeknav__jump { display: flex; align-items: flex-end; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.weeknav__jump label { margin: 0; font-weight: 600; }
.weeknav__jump input { width: auto; }
.weeknav__cierre { margin: .7rem 0 0; font-size: .9rem; }
.btn--sm { padding: .45rem .7rem; font-size: .95rem; }
.btn--off { opacity: .4; pointer-events: none; }

/* --- Controles de recurrencia (cliente) --- */
.recurrencia { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .9rem; }
.recurrencia__aviso {
    background: #fff7ed; color: #92400e; border: 1px solid #fed7aa;
    border-radius: 10px; padding: .6rem .8rem; margin: .5rem 0; font-size: .9rem;
}
.repetir-n { display: block; margin-top: .6rem; font-weight: 600; }
.repetir-n input { width: 4rem; display: inline-block; margin: 0 .2rem; }

/* --- Miniatura y limpiar por día (cliente) --- */
.dia-row__aside { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.dia-thumb {
    width: 46px; height: 46px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--line);
}
.dia-clear {
    width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid var(--line);
    background: #fff; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
    padding: 0; flex: 0 0 auto;
}
.dia-clear:hover { border-color: var(--brand); color: var(--brand); }

/* --- Fila de acciones (limpiar / repetir N) --- */
.acciones-fila {
    display: flex; align-items: center; justify-content: space-between;
    gap: .6rem; flex-wrap: wrap; margin: .7rem 0;
}
.descargar__info { margin: .9rem 0 1rem; line-height: 1.5; }

/* --- Visor de imágenes en grande (lightbox) --- */
.zoomable { cursor: zoom-in; }
.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; background: rgba(0, 0, 0, .85); cursor: zoom-out;
}
.lightbox[hidden] { display: none; }   /* el atributo hidden gana sobre display:flex */
.lightbox__img {
    max-width: 100%; max-height: 100%;
    border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

/* --- Observación por día (cliente) --- */
.dia-obs {
    grid-column: 1 / -1; width: 100%; margin-top: .35rem;
    padding: .5rem .6rem; font-size: .9rem;
    border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

/* --- Pedido en curso (cliente, solo lectura) --- */
.mp-menu { font-weight: 600; }
.mp-menu.muted { font-weight: 400; }
.mp-obs {
    font-weight: 400; font-size: .85rem; color: var(--muted);
    margin-top: .2rem; white-space: pre-wrap; word-break: break-word;
}

/* --- Reordenar menús (admin) --- */
.menu-orden { display: inline-flex; gap: .2rem; margin-right: .4rem; }
.menu-orden .btn { padding: .25rem .5rem; line-height: 1; }
.menu-orden .btn[disabled] { opacity: .35; cursor: default; }

/* --- Observaciones (admin) --- */
.obs-cliente { margin-bottom: .5rem; }
.obs-lista { display: flex; flex-direction: column; gap: .5rem; }
.obs-item { padding: .5rem .6rem; background: #f6f7f9; border-radius: 8px; }
.obs-item__dia { display: flex; align-items: center; gap: .5rem; margin-bottom: .15rem; }
.obs-item__texto { white-space: pre-wrap; word-break: break-word; }
.btn--danger { background: #fdecea; color: #b3261e; border: 1px solid #f5c2c0; margin-top: .5rem; }
.btn--danger:hover { background: #fbd9d6; }

.devbar {
    background: #fff7ed; border: 1px dashed var(--brand); color: #92400e;
    padding: .55rem .8rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem;
}
.alert { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .95rem; }
.alert--ok  { background: var(--ok-bg);  color: var(--ok-ink); }
.alert--error { background: var(--err-bg); color: var(--err-ink); }
.alert--warn { background: #fff7ed; color: #92400e; border: 1px solid #fed7aa; }
