/* Gestor de imágenes por lotes — estilos
   Distribución inspirada en Microsoft Office Picture Manager:
   barra de título + barra de herramientas, zona central, panel de tareas a la derecha
   y tira de miniaturas en la parte inferior. */

:root {
  --pm-blue-900: #1b365d;
  --pm-blue-700: #2b5797;
  --pm-blue-100: #dde8f6;
  --pm-blue-50: #eef4fb;
  --pm-orange: #f39c1f;
  --pm-border: #b9cbe3;
  --app-bg: #eceff4;
  --stage-bg: #f6f7f9;
  --panel-w: 340px;
  --film-h: 172px;
}

html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
  font-size: 14px;
  color: #1f2933;
}

/* ---------- Cabecera ---------- */
.app-header { flex: 0 0 auto; box-shadow: 0 1px 3px rgba(0,0,0,.15); z-index: 5; }
.titlebar {
  display: flex; align-items: center; gap: .5rem;
  background: linear-gradient(180deg, #2f5d9b, var(--pm-blue-900));
  color: #fff; padding: .35rem .9rem;
}
.titlebar .bi { font-size: 1.15rem; color: #ffd37a; }
.app-title { font-weight: 600; letter-spacing: .2px; }
.titlebar-sub { opacity: .7; font-size: .85rem; margin-left: .5rem; }

.toolbar {
  display: flex; align-items: center; gap: .25rem; flex-wrap: wrap;
  background: linear-gradient(180deg, #f5f9fe, var(--pm-blue-100));
  border-bottom: 1px solid var(--pm-border);
  padding: .3rem .6rem;
}
.tb-group { display: flex; gap: .15rem; }
.tb-sep { width: 1px; align-self: stretch; background: var(--pm-border); margin: 0 .35rem; }
.tb-spacer { flex: 1; }
.btn-tb {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; font-size: .875rem; border: 1px solid transparent;
  color: #1f2933; background: transparent; border-radius: 4px;
}
.btn-tb:hover:not(:disabled) { background: #fff5d6; border-color: #e8c46b; }
.btn-tb:disabled { opacity: .45; }
.btn-tb .bi { font-size: 1rem; color: var(--pm-blue-700); }
.image-count { font-size: .85rem; color: #3e4c59; margin-right: .5rem; white-space: nowrap; }
.btn-process { font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.15); }

@media (max-width: 767.98px) { .tb-label { display: none; } }

/* ---------- Distribución principal ---------- */
.app-main { flex: 1 1 auto; display: flex; min-height: 0; }
.workspace { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.center { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.center-tabs { padding: .35rem .5rem 0; background: var(--pm-blue-50); border-bottom-color: var(--pm-border); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.center-tabs .nav-link { padding: .35rem .75rem; font-size: .875rem; color: #3e4c59; white-space: nowrap; }
.center-tabs .nav-link.active { color: var(--pm-blue-900); font-weight: 600; }
.tab-content { flex: 1 1 auto; min-height: 0; position: relative; }
.tab-content > .tab-pane { height: 100%; }
.tab-content > .tab-pane.active { display: flex; flex-direction: column; }

/* ---------- Zona de carga ---------- */
.dropzone {
  margin: 1.5rem; flex: 1; border: 2px dashed #9fb3cf; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: repeating-linear-gradient(45deg, #fafcff, #fafcff 12px, #f3f7fc 12px, #f3f7fc 24px);
  color: #52606d; padding: 2rem;
}
.dropzone > .bi { font-size: 3.5rem; color: var(--pm-blue-700); }
.dropzone h2 { font-size: 1.25rem; margin: .5rem 0; color: #1f2933; }
.drop-overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(27, 54, 93, .55);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.drop-overlay-inner {
  border: 3px dashed #fff; border-radius: 16px; padding: 3rem 4rem; color: #fff; text-align: center; pointer-events: none;
}
.drop-overlay-inner .bi { font-size: 4rem; }
.drop-overlay-inner p { font-size: 1.2rem; margin: 0; }

/* ---------- Editor ---------- */
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-bar {
  display: flex; align-items: center; gap: .75rem; padding: .35rem .75rem;
  background: #fff; border-bottom: 1px solid #e4e7eb; font-size: .85rem; min-height: 34px;
}
.editor-ref { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-hint { color: #7b8794; }
.editor-status .badge { font-weight: 500; }
.editor-stage { flex: 1; min-height: 0; position: relative; background: var(--stage-bg); padding: 14px; }
.editor-canvas { width: 100%; height: 100%; }
.editor-canvas img { display: block; max-width: 100%; }
.editor-stage.eyedropper .cropper-container,
.editor-stage.eyedropper .cropper-container * { cursor: crosshair !important; }
.eyedropper-hint {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(31,41,51,.85); color: #fff; padding: .35rem .8rem; border-radius: 20px; font-size: .85rem;
}
/* Marco de recorte con asas al estilo Picture Manager */
.cropper-view-box { outline: 1px solid rgba(255,255,255,.9); outline-color: rgba(255,255,255,.9); }
.cropper-line { background-color: #fff; }
.cropper-point { background-color: #fff; border: 1px solid #1f2933; width: 9px; height: 9px; opacity: 1; }
.cropper-point.point-se { width: 9px; height: 9px; }
.cropper-modal { opacity: .55; }
.editor-stage.crop-off .cropper-modal { opacity: .15; }
.editor-stage.crop-off .cropper-view-box { outline-style: dashed; }

/* ---------- Comparación ---------- */
.compare-bar, .grid-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .4rem .75rem; border-bottom: 1px solid #e4e7eb; font-size: .85rem; background: #fff;
}
.compare-name { font-weight: 600; margin-left: .5rem; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-info { color: #52606d; }
.compare-warnings { padding: .35rem .75rem; background: #fff8e6; color: #8a5a00; font-size: .82rem; border-bottom: 1px solid #f1dfb0; }
.compare-body { flex: 1; min-height: 0; position: relative; background: var(--stage-bg); }
.compare-side { display: flex; gap: 12px; height: 100%; padding: 12px; }
.compare-pane { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; margin: 0; }
.compare-pane figcaption { font-size: .8rem; color: #52606d; margin-bottom: 4px; font-weight: 600; }
.compare-pane figcaption span { font-weight: 400; }
.compare-pane .checker { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; border: 1px solid #d9dee5; border-radius: 6px; overflow: hidden; }
.compare-pane img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cmp-spinner { position: absolute; top: 12px; right: 12px; width: 1.4rem; height: 1.4rem; }
.compare-error { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); max-width: 520px; }
.checker {
  background-color: #fff;
  background-image: conic-gradient(#e3e6ea 25%, #fff 0 50%, #e3e6ea 0 75%, #fff 0);
  background-size: 18px 18px;
}
.compare-slider { height: 100%; display: flex; flex-direction: column; padding: 12px; gap: 6px; }
.slider-stage { position: relative; flex: 1; min-height: 0; border: 1px solid #d9dee5; border-radius: 6px; overflow: hidden; }
.slider-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slider-handle { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--pm-orange); box-shadow: 0 0 0 1px rgba(0,0,0,.2); pointer-events: none; }
.slider-range { max-width: 600px; margin: 0 auto; }

/* ---------- Miniaturas (cuadrícula y tira) ---------- */
.thumb { position: relative; cursor: pointer; user-select: none; }
.thumb-frame { display: flex; align-items: center; justify-content: center; background: #fff; }
.thumb-img { position: relative; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.25); background: #ddd; }
.thumb-img img { width: 100%; height: 100%; display: block; }
.crop-overlay {
  position: absolute; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .5);
  outline: 1px solid rgba(255,255,255,.95); pointer-events: none;
}
.crop-overlay.adjusted { outline: 2px solid var(--pm-orange); }
.crop-overlay.error { outline: none; box-shadow: none; inset: 0 !important; width: auto !important; height: auto !important;
  background: repeating-linear-gradient(45deg, rgba(220,38,38,.45), rgba(220,38,38,.45) 6px, rgba(220,38,38,.15) 6px, rgba(220,38,38,.15) 12px); }
.thumb-del {
  position: absolute; top: 4px; right: 4px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(31,41,51,.75); color: #fff; font-size: 12px; line-height: 22px; padding: 0;
  opacity: 0; transition: opacity .15s;
}
.thumb:hover .thumb-del, .thumb:focus-within .thumb-del { opacity: 1; }
@media (hover: none) { .thumb-del { opacity: .85; } }
.thumb-badge { position: absolute; top: 4px; left: 4px; z-index: 2; font-size: 11px; }

/* Tira inferior */
.filmstrip { flex: 0 0 var(--film-h); display: flex; flex-direction: column; background: #fff; border-top: 1px solid var(--pm-border); min-height: 0; }
.filmstrip-bar {
  display: flex; align-items: center; gap: 1rem; padding: .25rem .75rem; font-size: .8rem;
  background: linear-gradient(180deg, #f5f9fe, var(--pm-blue-100)); border-bottom: 1px solid var(--pm-border);
}
#status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-progress { display: flex; align-items: center; gap: .5rem; }
.upload-progress .progress { width: 160px; height: 8px; }
.filmstrip-strip { flex: 1; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 6px; align-items: stretch; }
.filmstrip-strip .thumb { flex: 0 0 150px; border: 2px solid #f5c97a; background: #fffaf0; display: flex; flex-direction: column; }
.filmstrip-strip .thumb.is-ref { border-color: var(--pm-orange); background: #ffe7b8; box-shadow: 0 0 0 1px var(--pm-orange); }
.filmstrip-strip .thumb-frame { height: 98px; background: transparent; }
.filmstrip-strip .thumb-name { font-size: 11px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; background: var(--pm-orange); color: #1f2933; }
.filmstrip-strip .thumb:not(.is-ref) .thumb-name { background: #f9d999; }
.filmstrip-empty { color: #9aa5b1; font-size: .85rem; margin: auto; }

/* Cuadrícula */
.image-grid { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; align-content: start; background: var(--stage-bg); }
.image-grid .thumb { background: #fff; border: 1px solid #d9dee5; border-radius: 8px; overflow: hidden; }
.image-grid .thumb.is-ref { border-color: var(--pm-orange); box-shadow: 0 0 0 2px var(--pm-orange); }
.image-grid .thumb-frame { height: 150px; background: #f1f3f6; }
.thumb-info { padding: 6px 8px; font-size: 12px; line-height: 1.35; }
.thumb-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-info .meta { color: #616e7c; }
.thumb-info .result { color: var(--pm-blue-700); }
.thumb-info .result.err { color: #b91c1c; }
.thumb-actions { display: flex; gap: 4px; padding: 0 8px 8px; }
.thumb-actions .btn { font-size: 12px; padding: 1px 6px; }
.crop-legend { font-size: .78rem; color: #52606d; display: inline-flex; align-items: center; gap: .35rem; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-left: .5rem; }
.lg-ok { border: 2px solid #fff; outline: 1px solid #616e7c; }
.lg-adj { border: 2px solid var(--pm-orange); }
.lg-err { background: rgba(220,38,38,.5); }

/* ---------- Resultados ---------- */
.results-empty { margin: auto; text-align: center; color: #7b8794; max-width: 420px; padding: 2rem; }
.results-empty .bi { font-size: 3rem; }
.results { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.results-head { display: flex; gap: .75rem; align-items: center; padding: .75rem; border-bottom: 1px solid #e4e7eb; flex-wrap: wrap; }
.results-head .progress { height: 12px; }
.results-table-wrap { flex: 1; overflow: auto; }
.results-table { font-size: .85rem; margin: 0; }
.results-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1; font-weight: 600; }
.results-table td.thumbcell { width: 64px; }
.results-table td.thumbcell img { max-width: 56px; max-height: 42px; display: block; }
.results-table .warn { color: #8a5a00; font-size: .78rem; }
.results-table .err { color: #b91c1c; font-size: .8rem; }

/* ---------- Panel de herramientas ---------- */
.tools-panel {
  background: linear-gradient(180deg, #f7faff, #eef3fa);
  border-left: 1px solid var(--pm-border);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .tools-panel { flex: 0 0 var(--panel-w); width: var(--panel-w); min-height: 0; }
}
@media (max-width: 991.98px) {
  .tools-panel.offcanvas-lg { --bs-offcanvas-width: min(360px, 92vw); }
}
.panel-title { padding: .5rem .85rem; border-bottom: 1px solid var(--pm-border); background: linear-gradient(180deg, #fff, var(--pm-blue-100)); }
.panel-title h2 { font-size: .95rem; margin: 0; color: var(--pm-blue-900); font-weight: 600; }
.tools-panel .panel-body { flex: 1 1 auto; overflow-y: auto; padding: .6rem; display: block !important; }
.panel-footer { padding: .6rem; border-top: 1px solid var(--pm-border); background: #f7faff; }

.pending { background: #fff; border: 1px solid var(--pm-border); border-radius: 6px; padding: .5rem .6rem; margin-bottom: .6rem; font-size: .8rem; }
.pending-head { color: #52606d; margin-bottom: .25rem; }
.pending-list { margin: 0; padding-left: 1.2rem; }
.pending-list li { margin: 1px 0; }
.pending-list li.fixed { color: #9aa5b1; }
.pending-list li b { color: var(--pm-blue-900); font-weight: 600; }
.pending-list li small { color: #616e7c; display: block; line-height: 1.25; }

.tool { background: #fff; border: 1px solid var(--pm-border); border-radius: 6px; margin-bottom: .5rem; }
.tool-head { display: flex; align-items: center; justify-content: space-between; padding: .2rem .6rem .2rem .2rem; }
.tool-toggle {
  flex: 1; text-align: left; border: 0; background: transparent; font-weight: 600; color: var(--pm-blue-900);
  padding: .35rem .4rem; font-size: .9rem; display: flex; align-items: center; gap: .45rem;
}
.tool-toggle::after { content: '\F282'; font-family: bootstrap-icons; margin-left: auto; margin-right: .5rem; font-size: .75rem; transition: transform .2s; }
.tool-toggle.collapsed::after { transform: rotate(-90deg); }
.tool-state { font-size: .72rem; color: #fff; background: var(--pm-blue-700); border-radius: 10px; padding: 0 .5rem; }
.tool-state:empty { display: none; }
.tool-body { padding: .2rem .75rem .75rem; font-size: .85rem; }
.tool-body .form-label { font-size: .8rem; margin-bottom: .15rem; color: #3e4c59; }
.tool-body output { font-variant-numeric: tabular-nums; color: var(--pm-blue-700); font-weight: 600; }
.hint { font-size: .76rem; color: #616e7c; margin: .25rem 0 .5rem; line-height: 1.3; }
.subhead { font-size: .8rem; font-weight: 600; color: var(--pm-blue-900); margin: .5rem 0 .25rem; border-bottom: 1px solid #e4e7eb; }
.subhead small { font-weight: 400; color: #7b8794; }
.px-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; margin-bottom: 6px; }
.px-grid label { font-size: .75rem; color: #52606d; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.px-grid input { width: 88px; }
.dims-box { font-size: .78rem; background: var(--pm-blue-50); border-radius: 4px; padding: 4px 8px; margin-bottom: 8px; }
.dims-box span { color: #616e7c; display: inline-block; width: 72px; }
.crop-stats { font-size: .78rem; margin-bottom: 8px; }
.crop-stats .s-ok { color: #15803d; } .crop-stats .s-adj { color: #b45309; } .crop-stats .s-err { color: #b91c1c; }
.hex-input { width: 90px; font-family: ui-monospace, Consolas, monospace; }
.swatch { display: inline-block; width: 10px; height: 10px; border: 1px solid #999; vertical-align: middle; margin-right: 2px; }
[data-show-if].is-hidden { display: none !important; }

/* ---------- Tablet / móvil ---------- */
@media (max-width: 575.98px) {
  .compare-side { flex-direction: column; }
  .dropzone { margin: .75rem; padding: 1rem; }
}
