/* cl_presupuestos — front. Variables en :root (ver styleCss()): --clp-color, --clp-color-text, --clp-radius, --clp-cols */
.clpresup {
  --clp-border: #dfe3e8;
  --clp-muted: #6b7280;
  --clp-bg: #fff;
  --clp-soft: color-mix(in srgb, var(--clp-color, #1f6feb) 10%, #fff);
  box-sizing: border-box;
}
.clpresup *, .clpresup *::before, .clpresup *::after { box-sizing: border-box; }
.clpresup-muted { color: var(--clp-muted); font-size: .875em; }
.clpresup-h { font-size: 1.15rem; margin: 0 0 .75rem; }
.clpresup-intro { margin: 0 0 1rem; color: var(--clp-muted); }
.clpresup-panel { background: var(--clp-bg); border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); padding: 1rem; margin-bottom: 1rem; }
.clpresup-link { color: var(--clp-color); font-weight: 600; text-decoration: none; }
.clpresup-link:hover { text-decoration: underline; }
.clpresup-num { text-align: right; white-space: nowrap; }

/* Botones */
.clpresup-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  border: 2px solid var(--clp-color); border-radius: var(--clp-radius, 6px);
  font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none !important;
  transition: background-color .15s, color .15s, opacity .15s, transform .05s;
}
.clpresup-btn:active { transform: translateY(1px); }
.clpresup-btn:disabled, .clpresup-btn.is-loading { opacity: .6; cursor: progress; }
.clpresup-btn--sm { padding: .35em .7em; font-size: .85rem; }
.clpresup-btn--md { padding: .55em 1em; font-size: .95rem; }
.clpresup-btn--lg { padding: .8em 1.4em; font-size: 1.05rem; }
.clpresup-btn--full { display: flex; width: 100%; }
.clpresup-btn--solid { background: var(--clp-color); color: var(--clp-color-text, #fff) !important; }
.clpresup-btn--solid:hover { filter: brightness(1.08); }
.clpresup-btn--outline { background: transparent; color: var(--clp-color) !important; }
.clpresup-btn--outline:hover { background: var(--clp-color); color: var(--clp-color-text, #fff) !important; }
.clpresup-btn--soft { background: var(--clp-soft); border-color: transparent; color: var(--clp-color) !important; }
.clpresup-btn--soft:hover { border-color: var(--clp-color); }
.clpresup-btn--link { background: none; border-color: transparent; color: var(--clp-color) !important; padding-left: 0; padding-right: 0; }
.clpresup-btn--link:hover { text-decoration: underline !important; }
.clpresup-ico { flex: 0 0 auto; }

/* Botón en ficha / carrito */
.clpresup-pbtn { margin: .75rem 0; }
.clpresup-pbtn--listing { margin: .4rem 0 0; }
.clpresup-cartbtn { margin: 1rem 0; display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }

/* Cabecera */
.clpresup-header { position: relative; display: inline-block; }
/* Botón flotante (theme sin hook de cabecera) */
.clpresup-header--float { position: fixed; right: 16px; bottom: 16px; z-index: 1040; }
.clpresup-header--float.is-empty { display: none; }
.clpresup-header--float .clpresup-header__link { background: var(--clp-color); color: var(--clp-color-text, #fff); padding: .6rem 1rem; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-weight: 600; }
.clpresup-header--float .clpresup-count { background: var(--clp-color-text, #fff); color: var(--clp-color); }
.clpresup-header--float .clpresup-dropdown { top: auto; bottom: calc(100% + 8px); }
.clpresup-has-float .clpresup-toast { bottom: 76px; }
@media (max-width: 767px) { .clpresup-header--float .clpresup-header__label { display: none; } .clpresup-header--float .clpresup-dropdown { position: absolute; left: auto; right: 0; top: auto; width: calc(100vw - 32px); } }
.clpresup-header__link { display: inline-flex; align-items: center; gap: .35rem; color: inherit; text-decoration: none; padding: .35rem .25rem; }
.clpresup-header__label { font-size: .9rem; }
.clpresup-count { display: inline-flex; min-width: 1.35em; height: 1.35em; padding: 0 .35em; align-items: center; justify-content: center; border-radius: 999px; background: var(--clp-color); color: var(--clp-color-text, #fff); font-size: .75rem; font-weight: 700; }
.clpresup-count.is-empty { opacity: .45; }
.clpresup-dropdown { position: absolute; right: 0; top: 100%; z-index: 1050; width: 340px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); box-shadow: 0 12px 30px rgba(0,0,0,.15); padding: .9rem; text-align: left; }
.clpresup-dropdown[hidden] { display: none; }
@media (max-width: 767px) { .clpresup-header__label { display: none; } .clpresup-dropdown { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; } }

/* Cesta (líneas) */
.clpresup-lines { list-style: none; margin: 0; padding: 0; }
.clpresup-line { display: grid; grid-template-columns: 48px 1fr auto; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--clp-border); }
.clpresup-line:last-child { border-bottom: 0; }
.clpresup-line img { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; background: #fafafa; }
.clpresup-line__name { font-size: .9rem; line-height: 1.25; overflow-wrap: anywhere; }
.clpresup-line__name a { color: inherit; text-decoration: none; font-weight: 600; }
.clpresup-line__name small { display: block; color: var(--clp-muted); }
.clpresup-line__side { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.clpresup-line__total { font-weight: 600; white-space: nowrap; }
.clpresup-line--compact { grid-template-columns: 40px 1fr auto; }
.clpresup-line--compact img { width: 40px; height: 40px; }
.clpresup-line--noimg { grid-template-columns: 1fr auto; }
.clpresup-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); overflow: hidden; }
.clpresup-stepper button { width: 28px; border: 0; background: #f4f5f7; cursor: pointer; font-size: 1rem; line-height: 1; }
.clpresup-stepper button:hover { background: var(--clp-soft); }
.clpresup-stepper input { width: 48px; border: 0; text-align: center; -moz-appearance: textfield; appearance: textfield; padding: .25rem 0; }
.clpresup-stepper input::-webkit-outer-spin-button, .clpresup-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.clpresup-remove { border: 0; background: none; color: var(--clp-muted); cursor: pointer; font-size: .8rem; padding: 0; text-decoration: underline; }
.clpresup-remove:hover { color: #b91c1c; }
.clpresup-basket__head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .25rem; }
.clpresup-basket__total { display: flex; justify-content: space-between; font-weight: 700; padding: .75rem 0 .25rem; border-top: 2px solid var(--clp-border); margin-top: .25rem; }
.clpresup-basket__actions { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; }
.clpresup-basket__empty { color: var(--clp-muted); margin: .5rem 0; }

/* Página */
.clpresup-page__grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.clpresup-layout--left .clpresup-page__grid { grid-template-columns: 340px minmax(0, 1fr); }
.clpresup-layout--left .clpresup-page__basket { order: -1; }
.clpresup-layout--below .clpresup-page__grid { grid-template-columns: minmax(0, 1fr); }
.clpresup-page__basket { position: sticky; top: 1rem; }
.clpresup-layout--below .clpresup-page__basket { position: static; }
@media (max-width: 991px) {
  .clpresup-page__grid, .clpresup-layout--left .clpresup-page__grid { grid-template-columns: minmax(0, 1fr); }
  .clpresup-page__basket { position: static; order: 2; }
}
.clpresup-filters { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.clpresup-filters__search { display: flex; gap: .5rem; }
.clpresup-filters__search input { flex: 1; min-width: 0; }
.clpresup-filters__row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.clpresup-filters input[type=search], .clpresup-filters select, .clpresup-field input, .clpresup-field select, .clpresup-field textarea, .clpresup-combo, .clpresup-qty {
  border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); padding: .5rem .65rem; background: #fff; font: inherit; max-width: 100%;
}
.clpresup-filters select { max-width: 240px; }
.clpresup-check { text-align: left; display: inline-flex; gap: .45rem; align-items: flex-start; cursor: pointer; font-size: .9rem; }
.clpresup-check input { margin-top: .2rem; }
.clpresup-views { margin-left: auto; display: inline-flex; border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); overflow: hidden; }
.clpresup-views button { border: 0; background: #fff; padding: .4rem .55rem; cursor: pointer; color: var(--clp-muted); display: inline-flex; }
.clpresup-views button.is-active { background: var(--clp-color); color: var(--clp-color-text, #fff); }
.clpresup-results-wrap.is-loading { opacity: .5; pointer-events: none; transition: opacity .15s; }
.clpresup-results__count { margin: 0 0 .75rem; font-size: .9rem; }
.clpresup-empty { padding: 2rem 0; text-align: center; color: var(--clp-muted); }

/* Barra móvil de la página */
.clpresup-mobilebar { display: none; }
@media (max-width: 991px) {
  .clpresup-mobilebar { display: flex; position: fixed; right: 14px; bottom: 14px; white-space: nowrap; z-index: 1040; align-items: center; gap: .5rem; padding: .65rem 1.1rem; border-radius: 999px; background: var(--clp-color); color: var(--clp-color-text, #fff) !important; font-weight: 700; text-decoration: none !important; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
  .clpresup-mobilebar .clpresup-count { background: var(--clp-color-text, #fff); color: var(--clp-color); }
  .clpresup-mobilebar:has(.clpresup-count.is-empty) { display: none; }
}
@media (max-width: 480px) { .clpresup-mobilebar > span:not(.clpresup-count) { display: none; } }

/* Cuadrícula */
.clpresup-results--grid .clpresup-items { display: grid; grid-template-columns: repeat(var(--clp-cols, 3), minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1199px) { .clpresup-results--grid .clpresup-items { grid-template-columns: repeat(min(var(--clp-cols, 3), 3), minmax(0, 1fr)); } }
@media (max-width: 767px) { .clpresup-results--grid .clpresup-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; } }
.clpresup-card { display: flex; flex-direction: column; border: 1px solid var(--clp-border); border-radius: var(--clp-radius, 6px); background: #fff; overflow: hidden; }
.clpresup-card__img { display: block; aspect-ratio: 1 / 1; background: #fafafa; }
.clpresup-card__img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.clpresup-card__body { padding: .75rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.clpresup-card__brand { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--clp-muted); }
.clpresup-card__name { font-size: .95rem; margin: 0; line-height: 1.3; }
.clpresup-card__name a { color: inherit; text-decoration: none; }
.clpresup-card__name a:hover { color: var(--clp-color); }
.clpresup-card__desc { font-size: .85rem; color: var(--clp-muted); margin: .2rem 0; }
.clpresup-card__meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: auto; padding-top: .3rem; flex-wrap: wrap; }
.clpresup-card__actions { display: flex; gap: .4rem; padding: 0 .75rem .75rem; }
.clpresup-card__actions .clpresup-qty { width: 64px; flex: 0 0 auto; }
.clpresup-card__actions .clpresup-btn { flex: 1; }
.clpresup-price { font-weight: 700; font-size: 1.05rem; color: var(--clp-color); }
.clpresup-ref { font-size: .8rem; color: var(--clp-muted); }
.clpresup-stock { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; background: #f3f4f6; color: var(--clp-muted); }
.clpresup-stock.is-in { background: #dcfce7; color: #166534; }
.clpresup-combo { width: 100%; font-size: .85rem; padding: .35rem .5rem; }

/* Lista */
.clpresup-results--list .clpresup-items { display: flex; flex-direction: column; gap: .75rem; }
.clpresup-results--list .clpresup-card { display: grid; grid-template-columns: 120px minmax(0, 1fr) 220px; align-items: center; }
.clpresup-results--list .clpresup-card__img { height: 120px; aspect-ratio: auto; }
.clpresup-results--list .clpresup-card__actions { padding: .75rem; }
@media (max-width: 767px) {
  .clpresup-results--list .clpresup-card { grid-template-columns: 90px minmax(0, 1fr); }
  .clpresup-results--list .clpresup-card__img { height: 90px; }
  .clpresup-results--list .clpresup-card__actions { grid-column: 1 / -1; padding-top: 0; }
}

/* Tabla */
.clpresup-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.clpresup-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.clpresup-table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--clp-muted); border-bottom: 2px solid var(--clp-border); padding: .5rem; white-space: nowrap; }
.clpresup-table td { border-bottom: 1px solid var(--clp-border); padding: .5rem; vertical-align: middle; }
.clpresup-table tbody tr:hover { background: #fafbfc; }
.clpresup-table__name { display: flex; gap: .6rem; align-items: center; min-width: 220px; }
.clpresup-table__name img { width: 40px; height: 40px; object-fit: contain; flex: 0 0 auto; }
.clpresup-table__name a { color: inherit; font-weight: 600; text-decoration: none; }
.clpresup-table__name .clpresup-combo { margin-top: .3rem; max-width: 260px; display: block; }
.clpresup-table .clpresup-qty { width: 70px; text-align: right; padding: .35rem .4rem; }

.clpresup-pager { display: flex; gap: .3rem; justify-content: center; margin: 1.25rem 0 .5rem; flex-wrap: wrap; }
.clpresup-pager button { min-width: 2.2rem; height: 2.2rem; border: 1px solid var(--clp-border); background: #fff; border-radius: var(--clp-radius, 6px); cursor: pointer; }
.clpresup-pager button.is-active { background: var(--clp-color); border-color: var(--clp-color); color: var(--clp-color-text, #fff); }

/* Formulario */
.clpresup-request__grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 991px) { .clpresup-request__grid { grid-template-columns: minmax(0, 1fr); } .clpresup-request__summary { order: -1; } }
.clpresup-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; margin-bottom: 1rem; }
@media (max-width: 575px) { .clpresup-fields { grid-template-columns: minmax(0, 1fr); } }
.clpresup-field { display: flex; flex-direction: column; gap: .3rem; margin: 0; font-size: .9rem; text-align: left; }
.clpresup-field span { font-weight: 600; }
.clpresup-field--wide { grid-column: 1 / -1; }
.clpresup-field input, .clpresup-field select, .clpresup-field textarea { width: 100%; }
.clpresup-privacy { margin: .5rem 0 1rem; }
.clpresup-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* Avisos y presupuesto */
.clpresup-alert { padding: .75rem 1rem; border-radius: var(--clp-radius, 6px); margin-bottom: 1rem; }
.clpresup-alert p, .clpresup-alert ul { margin: 0; }
.clpresup-alert--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.clpresup-alert--ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.clpresup-badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; color: #fff; background: var(--badge, #666); }
.clpresup-view__head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.clpresup-view__head p { margin: .35rem 0 0; }
.clpresup-totals { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1.5rem; max-width: 360px; margin: 1rem 0 0 auto; }
.clpresup-totals dt { font-weight: normal; color: var(--clp-muted); }
.clpresup-totals dd { margin: 0; text-align: right; white-space: nowrap; }
.clpresup-totals__grand { font-size: 1.15rem; font-weight: 700 !important; color: inherit !important; border-top: 2px solid var(--clp-border); padding-top: .4rem; }
.clpresup-note { background: #f9fafb; border-left: 3px solid var(--clp-color); padding: .75rem 1rem; margin: 1rem 0; border-radius: 0 var(--clp-radius, 6px) var(--clp-radius, 6px) 0; }
.clpresup-accept { display: flex; flex-direction: column; gap: .9rem; align-items: flex-start; border-color: var(--clp-color); }
.clpresup-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.clpresup-actions form { margin: 0; }
.clpresup-reject { margin: 1rem 0; font-size: .9rem; }
.clpresup-reject summary { cursor: pointer; color: var(--clp-muted); }
.clpresup-reject form { margin-top: .6rem; display: flex; flex-direction: column; gap: .5rem; max-width: 480px; }
.clpresup-empty-box { text-align: center; padding: 2rem 1rem; }
.clpresup-locked { border: 2px solid var(--clp-color); border-radius: var(--clp-radius, 6px); padding: .9rem 1rem; margin: 1rem 0; background: var(--clp-soft); }
.clpresup-locked p { margin: 0 0 .5rem; }
.clpresup-locked-line input, .clpresup-locked-line button { opacity: .45; cursor: not-allowed; }
.clpresup-locked .clpresup-actions { margin: 0; }

/* Aviso flotante */
.clpresup-toast { position: fixed; right: 16px; bottom: 16px; z-index: 2000; max-width: min(380px, calc(100vw - 32px)); background: #111827; color: #fff; padding: .85rem 1rem; border-radius: var(--clp-radius, 6px); box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: .75rem; align-items: center; transform: translateY(20px); opacity: 0; transition: opacity .2s, transform .2s; font-size: .9rem; }
.clpresup-toast.is-visible { opacity: 1; transform: none; }
.clpresup-toast.is-error { background: #991b1b; }
.clpresup-toast a { color: #fff; font-weight: 700; white-space: nowrap; text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .clpresup-toast, .clpresup-btn { transition: none; } }
