/* Pedidos de Máscaras - Eva Magic (misma estética que el portal comerciantes) */
:root {
    --primario: #1e3a5f;
    --primario-oscuro: #0f2744;
    --secundario: #10b981;
    --acento: #3b82f6;
    --fondo: #f8fafc;
    --superficie: #ffffff;
    --texto: #1e293b;
    --texto-2: #64748b;
    --borde: #e2e8f0;
    --error: #ef4444;
    --radio: 10px;
    --sombra: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

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

body {
    margin: 0;
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    font-size: 15px;
    line-height: 1.5;
    padding-bottom: 80px;
}

[hidden] { display: none !important; }

/* ---------- Encabezado ---------- */
.encabezado {
    background: linear-gradient(135deg, var(--primario) 0%, var(--primario-oscuro) 100%);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.encabezado h1 { margin: 0; font-size: 1.6rem; font-weight: 700; }
.subtitulo { margin: 2px 0 0; opacity: .8; font-size: .95rem; }

/* ---------- Botones ---------- */
.btn {
    border: 0;
    border-radius: var(--radio);
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sombra); }
.btn:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-primario { background: var(--secundario); color: #fff; }
.btn-primario:hover { background: #0e9f6e; }
.btn-secundario { background: #fff; color: var(--texto); border: 1px solid var(--borde); }
.btn-claro { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); }

/* ---------- Filtros ---------- */
.filtros {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--superficie);
    border-bottom: 1px solid var(--borde);
    padding: 12px 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.buscador {
    flex: 1 1 280px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 0 12px;
    background: #fff;
}
.buscador input { border: 0; outline: 0; padding: 10px 0; font: inherit; width: 100%; background: transparent; }
.buscador:focus-within { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
select, .campo input, .campo textarea {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    background: #fff;
    color: var(--texto);
}
select:focus, .campo input:focus, .campo textarea:focus { outline: 0; border-color: var(--acento); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.check { display: flex; align-items: center; gap: 6px; color: var(--texto-2); cursor: pointer; white-space: nowrap; }

/* ---------- Tabla ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }
.estado { text-align: center; color: var(--texto-2); padding: 40px 0; }
.estado.aviso { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: var(--radio); padding: 20px; }

.tabla-contenedor { background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
    background: #f1f5f9;
    text-align: left;
    padding: 12px;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--texto-2);
}
td { padding: 8px 12px; border-top: 1px solid var(--borde); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr.con-cantidad { background: #ecfdf5; }
.td-codigo { font-variant-numeric: tabular-nums; color: var(--texto-2); white-space: nowrap; }
.td-modelo { font-weight: 600; }
.td-precio { white-space: nowrap; font-variant-numeric: tabular-nums; }

.miniatura {
    width: 112px;
    height: 112px;
    object-fit: contain;
    border-radius: 6px;
    border: 2px solid var(--borde);
    background: #fff;
    cursor: zoom-in;
    transition: border-color .15s ease, box-shadow .15s ease;
    display: block;
}
.miniatura:hover { border-color: var(--acento); box-shadow: var(--sombra); }
.sin-foto { width: 112px; height: 112px; display: grid; place-items: center; color: var(--texto-2); font-size: .75rem; border: 2px dashed var(--borde); border-radius: 6px; }

.cantidad { display: inline-flex; align-items: center; border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; background: #fff; }
.cantidad button { border: 0; background: #f1f5f9; width: 36px; height: 40px; font-size: 1.1rem; cursor: pointer; color: var(--texto); }
.cantidad button:hover { background: #e2e8f0; }
.cantidad input { width: 70px; height: 40px; border: 0; text-align: center; font: inherit; font-weight: 600; -moz-appearance: textfield; }
.cantidad input::-webkit-outer-spin-button, .cantidad input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cantidad input:focus { outline: 2px solid var(--acento); outline-offset: -2px; }

/* ---------- Zoom flotante (igual al portal comerciantes) ---------- */
#zoomFlotante {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 3px solid var(--acento);
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0,0,0,.4);
    padding: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s ease;
    width: 320px;
    height: 320px;
    top: 0;
    left: 0;
}
#zoomFlotante.visible { opacity: 1; }
#zoomFlotante img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Visor a pantalla completa (celular / clic) */
.visor { border: 0; padding: 16px; border-radius: 16px; max-width: min(92vw, 640px); background: #fff; text-align: center; }
.visor::backdrop { background: rgba(15,23,42,.75); }
.visor img { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; margin: 0 auto; }
.visor-titulo { margin: 10px 0 0; font-weight: 600; }
.visor-cerrar { position: absolute; top: 8px; right: 8px; border: 0; background: #f1f5f9; border-radius: 50%; width: 36px; height: 36px; font-size: 1rem; cursor: pointer; }

/* ---------- Formulario ---------- */
.tarjeta { background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra); padding: 24px; margin-top: 24px; scroll-margin-top: 80px; }
.tarjeta h2 { margin: 0 0 16px; font-size: 1.2rem; color: var(--primario); }
.grilla-campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.campo span { font-weight: 600; color: var(--texto-2); }
.campo .req { color: var(--error); }
.campo-ancho { margin-top: 14px; }
.campo.error input { border-color: var(--error); }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.condiciones { margin-top: 16px; padding: 14px; background: #f1f5f9; border-radius: var(--radio); white-space: pre-line; font-size: .9rem; }
.acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Barra inferior de resumen ---------- */
.barra-resumen {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    background: var(--primario);
    color: #fff;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,.15);
}
.resumen-datos { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------- Diálogo y avisos ---------- */
.dialogo { border: 0; border-radius: 16px; padding: 28px; max-width: 420px; box-shadow: var(--sombra); }
.dialogo::backdrop { background: rgba(15,23,42,.6); }
.dialogo h2 { margin-top: 0; color: var(--primario); }
.aviso-flotante {
    position: fixed;
    top: 16px; left: 50%;
    transform: translate(-50%, -150%);
    background: var(--texto);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radio);
    z-index: 2000;
    transition: transform .25s ease;
    max-width: 90vw;
}
.aviso-flotante.visible { transform: translate(-50%, 0); }
.aviso-flotante.error { background: var(--error); }

/* Encabezado y filtros alineados con el ancho de la tabla (1200px) */
.encabezado, .filtros { padding-left: max(16px, calc((100% - 1168px) / 2)); padding-right: max(16px, calc((100% - 1168px) / 2)); }
.check { flex-shrink: 0; }

/* ---------- Texto institucional (SEO) ---------- */
.sobre-nosotros { max-width: 1200px; margin: 8px auto 0; padding: 0 16px; color: var(--texto-2); font-size: .92rem; }
.sobre-nosotros h2 { font-size: 1.05rem; color: var(--primario); margin: 0 0 8px; }
.sobre-nosotros p { margin: 0 0 8px; }

/* ---------- Tarjeta "Tu pedido" ---------- */
.detalle-lista { display: flex; flex-direction: column; }
.det-item { display: grid; grid-template-columns: 56px 1fr auto auto auto 32px; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.det-item img, .det-sinfoto { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--borde); border-radius: 6px; background: #fff; }
.det-sinfoto { display: grid; place-items: center; color: var(--texto-2); }
.det-nombre { display: flex; flex-direction: column; min-width: 0; }
.det-nombre small { color: var(--texto-2); }
.det-cant span { min-width: 44px; text-align: center; font-weight: 700; }
.det-cant button { height: 34px; width: 32px; }
.det-precio { color: var(--texto-2); font-size: .85rem; white-space: nowrap; }
.det-subtotal { white-space: nowrap; min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.det-quitar { border: 0; background: #fef2f2; color: var(--error); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; }
.det-quitar:hover { background: #fee2e2; }
.detalle-totales { display: flex; justify-content: flex-end; gap: 24px; padding-top: 12px; font-size: 1.05rem; flex-wrap: wrap; }
.detalle-totales b { color: var(--primario); }
@media (max-width: 700px) {
    .det-item { grid-template-columns: 48px 1fr auto 30px; grid-template-areas: "img nombre nombre quitar" "img cant precio quitar"; gap: 6px 10px; }
    .det-item img, .det-sinfoto { grid-area: img; width: 48px; height: 48px; }
    .det-nombre { grid-area: nombre; }
    .det-cant { grid-area: cant; justify-self: start; }
    .det-precio { display: none; }
    .det-subtotal { grid-area: precio; min-width: 0; }
    .det-quitar { grid-area: quitar; }
}

/* ---------- WhatsApp ---------- */
.encabezado-botones { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5b; }
.wa-flotante {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 40;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
    transition: transform .15s ease, bottom .2s ease;
}
.wa-flotante:hover { transform: scale(1.08); }
body.con-barra .wa-flotante { bottom: 84px; }

footer { text-align: center; color: var(--texto-2); font-size: .85rem; padding: 20px; }
footer a { color: var(--acento); }

/* ---------- Celular: la tabla pasa a tarjetas ---------- */
@media (max-width: 700px) {
    body { font-size: 14px; }

    /* Encabezado compacto: título chico y los dos botones en una fila */
    .encabezado { padding: 14px 16px; gap: 10px; }
    .encabezado h1 { font-size: 1.1rem; line-height: 1.25; }
    .subtitulo { font-size: .8rem; }
    .encabezado-botones { width: 100%; flex-wrap: nowrap; gap: 8px; }
    .encabezado-botones .btn { flex: 1 1 0; justify-content: center; padding: 8px 10px; font-size: .82rem; white-space: nowrap; }
    .encabezado-botones .btn svg { width: 16px; height: 16px; flex-shrink: 0; }

    .filtros { padding: 8px 16px; gap: 8px; }
    .buscador { flex-basis: 100%; }
    .buscador input { padding: 8px 0; }
    .filtros select { flex: 1 1 0; min-width: 0; padding: 7px 10px; font-size: .88rem; }
    .check { font-size: .85rem; }

    main { padding: 12px 10px; }

    /* Cada producto como tarjeta: foto a la izquierda, datos a la derecha, aire entre filas */
    thead { display: none; }
    table, tbody { display: block; }
    tbody tr {
        display: grid;
        grid-template-columns: 84px 1fr;
        grid-template-areas: "img modelo" "img codigo" "img cant";
        grid-template-rows: auto auto 1fr;
        column-gap: 14px;
        row-gap: 2px;
        padding: 12px 14px;
        border-top: 1px solid var(--borde);
        align-items: start;
    }
    tbody tr:first-child { border-top: 0; }
    td { border: 0; padding: 0; min-width: 0; }
    .td-img { grid-area: img; }
    .miniatura, .sin-foto { width: 84px; height: 84px; border-width: 1px; }
    .td-modelo { grid-area: modelo; font-size: .98rem; line-height: 1.25; }
    .td-codigo { grid-area: codigo; font-size: .78rem; line-height: 1.35; letter-spacing: 0; }
    .td-codigo::after { content: attr(data-extra); }
    .col-categoria, .td-categoria, .td-precio { display: none; }
    .td-cant { grid-area: cant; padding-top: 8px; align-self: end; }
    .cantidad button { width: 34px; height: 34px; font-size: 1rem; }
    .cantidad input { width: 52px; height: 34px; font-size: .95rem; }

    .tarjeta { padding: 16px; margin-top: 16px; }
    .barra-resumen { padding: 8px 12px; }
    .barra-resumen .btn { padding: 8px 12px; font-size: .85rem; }
    .resumen-datos { gap: 8px; font-size: .82rem; }
    .wa-flotante { width: 50px; height: 50px; right: 12px; bottom: 14px; }
    .wa-flotante svg { width: 26px; height: 26px; }
    body.con-barra .wa-flotante { bottom: 72px; }
    .sobre-nosotros { font-size: .85rem; }
    #zoomFlotante { display: none; }
}
