/* public/assets/esmovil-modal.css */

/* ─── Modal overlay ─────────────────────────────────────────── */
.esm-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    z-index: 1000;
    overflow-y: auto;
    padding: 1.25rem 1rem;
}
.esm-modal-overlay.is-open { display: block; }
.esm-modal-overlay > .esm-search-root {
    background: var(--bg, #fff);
    max-width: 1600px;
    width: calc(100vw - 2rem);
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

/* ─── Header del buscador ───────────────────────────────────── */
.esm-search-root { font-family: inherit; }
.esm-search-header {
    display: flex;
    gap: .5rem;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border, #e5e5e5);
    flex-wrap: wrap;
}
.esm-search-input {
    flex: 1 1 320px;
    padding: .65rem .85rem;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}
.esm-search-clear,
.esm-search-close {
    padding: .55rem .85rem;
    border: 1px solid var(--border, #e5e5e5);
    background: var(--muted-bg, #f5f5f5);
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
}

/* ─── Cuerpo: resultados full-width ─────────────────────────── */
.esm-search-body {
    padding: .75rem 1.25rem 1rem;
}

.esm-search-results { min-height: 200px; }
.esm-search-status { padding: .5rem 0; }
.esm-search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

/* ─── Tarjeta producto ──────────────────────────────────────── */
.esm-card {
    position: relative;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: border-color .15s, transform .15s;
}
.esm-card.is-added { border-color: #b91c1c; box-shadow: 0 0 0 2px rgba(185,28,28,.18); }
.esm-card-img {
    position: relative;
    aspect-ratio: 16 / 11;
    background: #fafafa;
    display: flex; align-items: center; justify-content: center;
}
.esm-card-img img { width: 100%; height: 100%; object-fit: contain; }
.esm-card-fallback { font-size: 2.5rem; opacity: 0; }
.esm-card-img.no-img .esm-card-fallback { opacity: 1; }
.esm-card-img:has(img) .esm-card-fallback { display: none; }

.esm-card-body { padding: .75rem; }
.esm-card-name {
    font-size: .9rem; line-height: 1.3; margin: 0 0 .35rem; font-weight: 500;
}
.esm-card-meta { font-size: .75rem; margin: 0 0 .5rem; }
.esm-card-price { font-size: .95rem; margin: 0; display: flex; align-items: center; gap: .5rem; }

.esm-card-add {
    position: absolute; right: .55rem; bottom: .55rem;
    width: 36px; height: 36px; border-radius: 18px;
    border: none;
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    color: #fff;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
    box-shadow: 0 2px 8px rgba(185,28,28,.3);
    transition: transform .15s, box-shadow .15s;
}
.esm-card-add:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(185,28,28,.45); }
.esm-card-add.is-added { background: linear-gradient(135deg, #16a34a 0%, #15803d 100%); }

/* ─── Panel cesta — banda horizontal arriba ─────────────────── */
.esm-search-cart {
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 14px;
    margin: 0 1.25rem 1rem;
    padding: .75rem .9rem .9rem;
    box-shadow: 0 4px 14px rgba(185,28,28,.08);
}

/* Header horizontal con título + contador + total + botón */
.esm-cart-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.esm-cart-icon {
    font-size: 1.35rem;
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(185,28,28,.25);
    flex-shrink: 0;
}
.esm-cart-title-block { display: flex; align-items: center; gap: .5rem; }
.esm-search-cart h3 {
    font-size: 1rem;
    margin: 0;
    color: #1f2329;
    font-weight: 700;
}
.esm-cart-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px; height: 24px;
    padding: 0 .5rem;
    background: #b91c1c;
    color: #fff;
    border-radius: 99px;
    font-size: .78rem;
    font-weight: 700;
}
.esm-cart-header-spacer { flex: 1; }

/* Total inline (en el header) */
.esm-cart-total-inline {
    display: inline-flex;
    align-items: baseline;
    gap: .55rem;
    padding: .35rem .85rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fff7f7 100%);
    border: 1px solid #fecaca;
    border-radius: 10px;
}
.esm-cart-total-inline .esm-cart-total-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    font-weight: 600;
}
.esm-cart-total-inline .esm-cart-total-amount {
    font-size: 1.15rem;
    font-weight: 800;
    color: #b91c1c;
    letter-spacing: -.5px;
}

/* Empty state — fila inline compacta cuando no hay nada */
.esm-cart-empty {
    margin-top: .65rem;
    padding: .65rem .85rem;
    background: #fafafa;
    border: 1px dashed #e5e7eb;
    border-radius: 10px;
    color: #6b7280;
    font-size: .85rem;
    text-align: center;
}
.esm-cart-empty-icon {
    margin-right: .35rem;
    opacity: .8;
}
.esm-cart-empty .kbd {
    display: inline-block;
    padding: 0 .4rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: .8rem;
    color: #b91c1c;
    background: #fef2f2;
    font-weight: 700;
}

/* Lista de items: grid horizontal de cartas compactas */
.esm-cart-list {
    list-style: none;
    padding: 0;
    margin: .65rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: .55rem;
}
.esm-cart-list:empty { display: none; }
.esm-cart-list li {
    display: block;
    padding: .65rem .8rem;
    background: #fff;
    border: 1px solid #fee2e2;
    border-radius: 10px;
    font-size: .82rem;
    transition: border-color .15s, transform .12s, box-shadow .15s;
}
.esm-cart-list li:hover {
    border-color: #fca5a5;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(185,28,28,.1);
}
.esm-cart-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .35rem;
    margin-bottom: .35rem;
}
.esm-cart-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    flex: 1;
    min-width: 0;
}
.esm-cart-name {
    line-height: 1.3;
    margin-bottom: .35rem;
    color: #1f2329;
    word-break: break-word;
}
.esm-cart-price-row {
    display: flex;
    justify-content: flex-end;
}
.esm-cart-stock {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 600;
    white-space: nowrap;
}
.esm-cart-stock.ok { background: #dcfce7; color: #16a34a; }
.esm-cart-stock.no { background: #fee2e2; color: #dc2626; }
.esm-cart-price {
    font-weight: 700;
    font-size: 1.15rem;
    color: #b91c1c;
    white-space: nowrap;
}
.esm-cart-remove {
    border: none;
    background: #fef2f2;
    color: #b91c1c;
    cursor: pointer;
    font-size: .8rem;
    width: 26px; height: 26px;
    border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.esm-cart-remove:hover { background: #b91c1c; color: #fff; }

/* legacy compat */
.esm-cart-total-box, .esm-cart-total { display: none; }

.esm-cart-confirm {
    padding: .55rem 1.1rem;
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    box-shadow: 0 3px 10px rgba(185,28,28,.25);
    transition: transform .12s, box-shadow .15s;
    white-space: nowrap;
}
.esm-cart-confirm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(185,28,28,.35);
}
.esm-cart-confirm:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
}
.esm-cart-confirm-icon {
    width: 20px; height: 20px;
    background: rgba(255,255,255,.2);
    border-radius: 99px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .75rem;
    flex-shrink: 0;
}
.esm-cart-confirm:disabled .esm-cart-confirm-icon { background: #e5e7eb; }

@media (max-width: 700px) {
    .esm-cart-header { gap: .5rem; }
    .esm-cart-header-spacer { flex-basis: 100%; height: 0; }
    .esm-cart-confirm { width: 100%; }
    .esm-cart-list { grid-template-columns: 1fr; }
}
.esm-cart-confirm:disabled { background: #aaa; cursor: not-allowed; }

/* ─── Filter chips ─── */
.esm-search-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    padding: .65rem 1.25rem;
    border-bottom: 1px solid var(--border, #e5e5e5);
    background: #fafbfc;
}
.esm-filter-label {
    font-size: .75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    margin-right: .25rem;
}
.esm-filter-sep {
    width: 1px; height: 18px;
    background: #d1d5db;
    margin: 0 .35rem;
}
.esm-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 99px;
    padding: .3rem .75rem;
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.esm-filter-chip:hover {
    border-color: #2563eb;
    color: #2563eb;
}
.esm-filter-chip.is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 1px 3px rgba(37,99,235,.3);
}

/* ─── Bloque "Piezas esmovil añadidas" en select-parts ──────── */
.esm-added {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: .5rem;
    align-items: center;
    padding: .55rem 0;
    border-top: 1px solid var(--border, #e5e5e5);
    font-size: .9rem;
}
.esm-added:first-child { border-top: none; }
.esm-added-badges {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-bottom: .15rem;
}
.esm-added-badges:empty { display: none; }
.esm-added-name { line-height: 1.25; }
.esm-cart-thumb-fallback {
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

.hidden { display: none !important; }

/* ─── URL paste ─────────────────────────────────────────────── */
.esm-url-paste {
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border, #e5e5e5);
    background: #fafafa;
}
.esm-url-input {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    box-sizing: border-box;
}
.esm-url-input:disabled {
    opacity: .6;
    cursor: progress;
}

.esm-url-preview {
    margin-top: .75rem;
    padding: .85rem 1rem;
    background: #fff;
    border: 2px solid #d4af37;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    animation: esmFadeIn .15s ease-out;
}
@keyframes esmFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.esm-url-preview-status   { font-size: .8rem; color: #666; margin: 0 0 .25rem; }
.esm-url-preview-name     { font-size: .95rem; font-weight: 600; margin: 0 0 .35rem; line-height: 1.3; }
.esm-url-preview-meta     { font-size: .75rem; color: #666; margin: 0 0 .5rem; }
.esm-url-preview-row      { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.esm-url-preview-price    { font-size: 1.1rem; font-weight: 700; color: #1f6feb; }
.esm-url-preview-actions  { display: flex; gap: .5rem; margin-top: .75rem; justify-content: flex-end; flex-wrap: wrap; }
.esm-url-preview-actions button { padding: .5rem .85rem; border-radius: 6px; border: 1px solid var(--border, #e5e5e5); cursor: pointer; font-size: .85rem; }
.esm-url-preview-cancel   { background: #fff; }
.esm-url-preview-confirm  { background: #2ea043; color: #fff; border-color: #2ea043; }
.esm-url-preview-confirm:disabled { background: #aaa; border-color: #aaa; cursor: not-allowed; }

.esm-url-preview-error    { color: #c00; }
.esm-url-preview-warning  { background: #fff3cd; border-color: #ffc107; padding: .75rem; border-radius: 6px; font-size: .85rem; margin: .5rem 0; }
.esm-url-preview-info     { color: #666; font-size: .85rem; }
.esm-url-preview-spinner  { color: #666; font-size: .85rem; }

@media (max-width: 600px) {
    .esm-url-preview-actions { flex-direction: column; align-items: stretch; }
    .esm-url-preview-actions button { width: 100%; }
}
