/* ============================================================
   Ok.station — Configurador de pedidos (Fase 2)
   Reutiliza tokens de styles.css; campos en tema claro.
   ============================================================ */
.order-page { min-height: 100vh; display: flex; flex-direction: column; background: #F6F7FB; }
.order-main { flex: 1; }
.order-wrap { max-width: 1180px; margin: 0 auto; padding: clamp(20px,4vw,40px) clamp(16px,4vw,32px); }
.order-head { margin-bottom: var(--space-6); }
.order-head h1 { font-size: clamp(1.5rem,3vw,2.1rem); font-weight: 800; letter-spacing: -0.03em; color: var(--text-primary); }
.order-head p { color: var(--text-secondary); margin-top: 4px; }

.order-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--space-5); align-items: start; }

/* Zona de carga */
.order-drop {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: clamp(26px,4vw,40px);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.order-drop:hover, .order-drop.is-drag { border-color: var(--brand-blue); background: var(--brand-blue-light); }
.order-drop__icon { width: 60px; height: 60px; margin: 0 auto var(--space-3); border-radius: var(--radius-md); background: var(--grad-blue); display: grid; place-items: center; }
.order-drop__icon svg { width: 30px; height: 30px; color: #fff; }
.order-drop h3 { font-size: 1.05rem; color: var(--text-primary); }
.order-drop p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* Precios de referencia (antes de subir archivos) */
.order-prices { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); padding: 16px 18px; margin-top: var(--space-4); }
.order-prices__title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 10px; }
.order-prices__list { list-style: none; margin: 0; padding: 0; }
.order-prices__list li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.88rem; color: var(--text-secondary); padding: 6px 0; border-bottom: 1px dashed var(--border-light); }
.order-prices__list li:last-child { border-bottom: none; }
.order-prices__list b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.order-prices__note { font-size: 0.72rem; color: var(--text-muted); margin-top: 10px; }

/* Lista de archivos */
.order-files { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-5); }
.file-card { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); overflow: hidden; }
.file-card__top { display: flex; align-items: center; gap: var(--space-3); padding: 14px 16px; border-bottom: 1px solid var(--border-light); }
.file-card__thumb { width: 46px; height: 46px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-page); flex-shrink: 0; display: grid; place-items: center; color: var(--brand-blue); }
.file-card__thumb svg { width: 22px; height: 22px; }
.file-card__meta { flex: 1; min-width: 0; }
.file-card__meta b { display: block; font-size: 0.9rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card__meta span { font-size: 0.75rem; color: var(--text-muted); }
.file-card__price { font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.file-card__price--quote { font-size: 0.8rem; font-weight: 700; color: var(--brand-blue); }
.file-card__note { font-size: 0.76rem; color: var(--text-muted); padding: 0 16px 14px; margin: -2px 0 0; }
.file-card__remove { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-light); background: #fff; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.file-card__remove:hover { border-color: var(--color-error); color: var(--color-error); }
.file-card__remove svg { width: 14px; height: 14px; }

.file-cfg { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); padding: 16px; }
.file-cfg__row { display: flex; flex-direction: column; gap: 6px; }
.file-cfg__row > label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.file-cfg select { width: 100%; padding: 9px 11px; border: 1.5px solid var(--border-light); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.85rem; background: #fff; color: var(--text-primary); }
.file-cfg select:focus { outline: none; border-color: var(--brand-blue); }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; padding: 8px 4px; border: 1.5px solid var(--border-light); background: #fff; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.seg button.is-on { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 32px; height: 32px; border: 1.5px solid var(--border-light); background: #fff; border-radius: var(--radius-sm); font-size: 1.1rem; cursor: pointer; color: var(--text-primary); }
.qty span { min-width: 30px; text-align: center; font-weight: 700; }

/* Resumen */
.order-summary { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: clamp(20px,2.5vw,26px); position: sticky; top: 20px; }
.order-summary h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-4); }
.order-summary__line { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 8px; }
.order-summary__line b { color: var(--text-primary); }
.order-summary__total { display: flex; justify-content: space-between; align-items: baseline; padding-top: var(--space-3); margin-top: var(--space-3); border-top: 1px solid var(--border-light); }
.order-summary__total b { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.order-summary textarea { width: 100%; margin-top: var(--space-3); border: 1.5px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px 12px; font-family: inherit; font-size: 0.85rem; resize: vertical; min-height: 70px; }
.order-summary textarea:focus { outline: none; border-color: var(--brand-blue); }
.order-note { font-size: 0.72rem; color: var(--text-muted); margin: 10px 0 var(--space-3); }
/* Aviso cuando el total es menor al mínimo de pago en línea ($5 MXN). */
.order-note--warn {
  color: #b4232f;
  font-weight: 600;
  background: #fdecee;
  border: 1px solid #f7c9ce;
  border-radius: 10px;
  padding: 9px 12px;
}

.order-alert { border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem; margin-bottom: var(--space-3); }
.order-alert--error { background: rgba(220,38,38,0.08); color: #B91C1C; border: 1px solid rgba(220,38,38,0.2); }
.order-alert--ok { background: rgba(22,163,74,0.08); color: #15803D; border: 1px solid rgba(22,163,74,0.2); }

/* Confirmación */
.order-done { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: clamp(28px,4vw,44px); text-align: center; max-width: 540px; margin: 0 auto; }
.order-done__check { width: 72px; height: 72px; border-radius: 50%; background: var(--grad-blue); display: grid; place-items: center; margin: 0 auto var(--space-5); }
.order-done__check svg { width: 36px; height: 36px; color: #fff; }
.order-done h2 { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.order-done .code { font-size: 1.1rem; font-weight: 700; color: var(--brand-blue); margin: 8px 0 var(--space-5); }
.order-done__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: var(--space-5); }

/* Historial (en perfil) */
.orders-list { display: flex; flex-direction: column; gap: 10px; }
.order-row { display: flex; align-items: center; gap: var(--space-4); padding: 14px 16px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: #fff; flex-wrap: wrap; }
.order-row__code { font-weight: 700; color: var(--text-primary); }
.order-row__meta { font-size: 0.8rem; color: var(--text-muted); }
.order-row__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .order-grid { grid-template-columns: 1fr; }
  .order-summary { position: static; }
  .file-cfg { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) { .file-cfg { grid-template-columns: 1fr; } }
/* Móvil: iOS hace ZOOM al enfocar campos <16px, y los controles del
   configurador quedaban por debajo del área táctil recomendada (~44px). */
@media (max-width: 768px) {
  .file-cfg select, .order-summary textarea { font-size: 16px; }
  .file-cfg select { min-height: 44px; }
  .seg button { min-height: 44px; }
  .qty button { width: 44px; height: 44px; }
}

/* Badges de estado (historial) */
.ostatus { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full); white-space: nowrap; }
.ostatus::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ostatus--recibido { background: #EEF2FF; color: #4338CA; }
.ostatus--en_revision { background: #FEF3C7; color: #B45309; }
.ostatus--en_produccion { background: #E0F2FE; color: #0369A1; }
.ostatus--en_preparacion { background: #E0F2FE; color: #0369A1; } /* tienda */
.ostatus--listo { background: #DCFCE7; color: #15803D; }
.ostatus--entregado { background: #ECFDF5; color: #047857; }
.ostatus--cancelado { background: #FEE2E2; color: #B91C1C; }
/* Estados de citas */
.ostatus--pendiente  { background: #FEF3C7; color: #B45309; }
.ostatus--confirmada { background: #E0F2FE; color: #0369A1; }
.ostatus--completada { background: #DCFCE7; color: #15803D; }
.ostatus--cancelada  { background: #FEE2E2; color: #B91C1C; }
.ostatus--no_show    { background: #F3F4F6; color: #6B7280; }

/* ── Pago en línea (bloque dentro del detalle del pedido) ── */
.order-pay { flex-basis: 100%; margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: #fbfcfe; }
.order-pay--paid { background: #f3fbf6; border-color: #cdeede; }
.order-pay__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.order-pay__title { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); }
.order-pay__body { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.order-pay__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.86rem; }
.order-pay__muted { color: var(--text-muted); font-size: 0.8rem; }
.order-pay__foot { display: flex; align-items: center; justify-content: flex-end; }
.order-pay__done { font-weight: 600; font-size: 0.85rem; color: #15803D; }
.order-pay .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ============================================================
   ANTI-DESBORDAMIENTO en móvil (configurador embebido en #fotos)
   Los contenedores flex/grid necesitan min-width:0 para encogerse;
   el input de teléfono no traía flex y empujaba el ancho → scroll lateral.
   ============================================================ */
.order-embed, #order-builder, .order-grid, .order-grid > *, .order-summary { min-width: 0; max-width: 100%; }
.input-prefix { min-width: 0; max-width: 100%; }
.input-prefix input { flex: 1 1 auto; min-width: 0; width: 100%; }
/* Filas de precios: si la etiqueta es larga, que el precio baje en vez de desbordar. */
.order-prices__list li { flex-wrap: wrap; }
.order-prices, .order-files { max-width: 100%; overflow: hidden; }
/* Nombres de archivo largos no rompen la tarjeta. */
.file-card, .file-cfg { max-width: 100%; min-width: 0; }

/* Chip de estado de pago */
.opay { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full); white-space: nowrap; }
.opay::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.opay--pendiente   { background: #F1F5F9; color: #475569; }
.opay--procesando  { background: #FEF3C7; color: #B45309; }
.opay--pagado      { background: #DCFCE7; color: #15803D; }
.opay--error       { background: #FEE2E2; color: #B91C1C; }
.opay--reembolsado { background: #EDE9FE; color: #6D28D9; }

/* ── Detalle por archivo dentro del "Resumen del pedido" ── */
.order-summary__detail { display: flex; flex-direction: column; gap: 8px; margin: 0 0 10px; }
.order-summary__item { border-bottom: 1px dashed var(--border-light); padding-bottom: 8px; }
.order-summary__item:last-child { border-bottom: none; padding-bottom: 0; }
.order-summary__item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.9rem; }
.order-summary__item-name { font-weight: 600; color: var(--text-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-summary__item-top b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-summary__item-sub { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }

/* ── Lista de precios de referencia CON TRAMOS (etiqueta arriba, precios por tramo abajo) ── */
.order-prices__list--tiers li { flex-direction: column; align-items: stretch; gap: 3px; }
.order-prices__list--tiers li span { font-weight: 600; color: var(--text-primary); }
.order-prices__list--tiers li b { font-weight: 600; font-size: 0.82rem; color: var(--text-secondary); white-space: normal; font-variant-numeric: tabular-nums; }

/* ── Panel compacto + botón que abre el modal de precios ── */
.order-prices__ref { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.order-prices__hint { display: block; font-size: 0.8rem; color: var(--text-muted, #6B7280); margin-top: 3px; }

/* ── Modal de precios de referencia ── */
.oprices-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 18px; }
.oprices-modal__overlay { position: absolute; inset: 0; background: rgba(8,12,32,0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.oprices-modal__panel { position: relative; z-index: 1; background: #fff; border-radius: var(--radius-lg, 18px); box-shadow: 0 30px 80px rgba(4,12,40,0.35); width: 100%; max-width: 520px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.oprices-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border-light, #e6eaf2); }
.oprices-modal__head h3 { margin: 0; font-size: 1.05rem; color: var(--text-primary, #0b1f3a); }
.oprices-modal__close { width: 34px; height: 34px; border: none; background: var(--surface-page, #f2f4f8); border-radius: 50%; font-size: 1.4rem; line-height: 1; color: var(--text-secondary, #475569); cursor: pointer; flex: none; }
.oprices-modal__close:hover { background: #e6eaf2; }
.oprices-modal__body { padding: 12px 22px 22px; overflow-y: auto; }
.oprices-modal__body .order-prices__list { margin: 0; }


/* ══ MODO OSCURO — html[data-theme="dark"] ══════════════════════════════════ */
html[data-theme="dark"] :is(.file-card, .order-row, .order-done, .oprices-modal__panel) {
  background: var(--surface-card);
  border-color: var(--border-light);
}
html[data-theme="dark"] .order-done { box-shadow: 0 18px 44px rgba(0,0,0,.45); }
html[data-theme="dark"] .oprices-modal__panel { box-shadow: 0 30px 80px rgba(0,0,0,.62); }
html[data-theme="dark"] .file-card__top { border-bottom-color: var(--border-light); }
html[data-theme="dark"] :is(.file-card__remove, .seg button) {
  background: var(--surface-page); border-color: var(--border-medium); color: var(--text-primary);
}
/* Pago: el verde de "pagado" se oscurece para no deslumbrar. */
html[data-theme="dark"] .order-pay { background: var(--surface-page); border-color: var(--border-light); }
html[data-theme="dark"] .order-pay--paid { background: #12241C; border-color: #1F4634; }
html[data-theme="dark"] .order-pay__done { color: #4ADE80; }
html[data-theme="dark"] .order-alert--error { background: rgba(220,38,38,.14); border-color: #7A2233; color: #FCA5A5; }

/* Ronda 2 del barrido: superficies que seguían con blanco fijo. */
html[data-theme="dark"] :is(.order-drop, .order-prices, .order-summary) {
  background: var(--surface-card);
  border-color: var(--border-light);
  color: var(--text-primary);
}
html[data-theme="dark"] :is(.file-cfg select, .qty button) {
  background: var(--surface-page);
  border-color: var(--border-medium);
  color: var(--text-primary);
}
