/* ── Gestión de Deudas JCC — Frontend v2.3 — Encapsulado ─────────────── */

/* Reset total dentro de #jcc-root para neutralizar cualquier theme */
#jcc-root,
#jcc-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#jcc-root {
  --c-accent:   #a30000;
  --c-surface:  #ffffff;
  --c-bg:       #F5F2EC;
  --c-text:     #1A1714;
  --c-muted:    #7A7469;
  --c-border:   #DDD8CE;
  --c-warn:     #C27B2A;
  --c-warn-bg:  #FDF3E3;
  --c-ok:       #1A6B3C;
  --c-ok-bg:    #E5F4EC;
  --c-danger-bg:#FDE8E6;
  --radius:     12px;
  --shadow:     0 1px 3px rgba(26,23,20,.08), 0 4px 16px rgba(26,23,20,.06);

  max-width: 780px;
  margin: 32px auto;
  padding: 0 16px 60px;
  color: var(--c-text);
  font-size: 15px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#jcc-root .jcc-header h1 {
  font-size: clamp(22px,4vw,30px);
  font-weight: 700;
  color: var(--c-accent);
  margin: 0 0 20px;
  padding: 0;
  border: none;
  background: none;
  line-height: 1.2;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
#jcc-root .jcc-estado-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding: 0;
  background: none;
  border: none;
  list-style: none;
}
#jcc-root .jcc-tab {
  display: inline-block;
  padding: 10px 24px;
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  text-decoration: none;
  transition: all .2s;
  outline: none;
  box-shadow: none;
  line-height: 1.4;
}
#jcc-root .jcc-tab.active {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
  box-shadow: 0 2px 10px rgba(163,0,0,.25);
}
#jcc-root .jcc-tab:hover:not(.active) {
  border-color: var(--c-accent);
  color: var(--c-accent);
}

/* ── Alerta orden ────────────────────────────────────────────────────────── */
#jcc-root .jcc-order-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #FDF7E8;
  border: 1px solid #E8D5A0;
  border-radius: 8px;
  padding: 12px 14px 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #7A5C00;
}
#jcc-root .jcc-note-icon  { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
#jcc-root .jcc-note-text  { flex: 1; }
#jcc-root .jcc-note-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #B8960A;
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  opacity: .6;
  transition: opacity .15s;
  box-shadow: none;
  outline: none;
}
#jcc-root .jcc-note-close:hover { opacity: 1; }
#jcc-root .jcc-hidden { display: none !important; }

/* ── Banner total ────────────────────────────────────────────────────────── */
#jcc-root .jcc-total-banner {
  background: var(--c-accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
#jcc-root .jcc-total-label  { font-size: 13px; opacity: .75; margin-bottom: 2px; }
#jcc-root .jcc-total-amount { font-size: 30px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
#jcc-root .jcc-total-meta   { font-size: 12px; opacity: .6; margin-top: 4px; }

/* Botón Ir a pagar — DENTRO del banner */
#jcc-root .jcc-btn-pagar {
  display: inline-block;
  background: #fff;
  color: var(--c-accent);
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  text-decoration: none;
  outline: none;
  line-height: 1.4;
  flex-shrink: 0;
}
#jcc-root .jcc-btn-pagar:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  color: var(--c-accent);
  background: #fff;
}
#jcc-root .jcc-btn-pagar:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

/* ── Lista de deudas ─────────────────────────────────────────────────────── */
#jcc-root .jcc-deuda-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
#jcc-root .jcc-deuda-item {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-left: 3px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: visible;
  margin: 0;
}
#jcc-root .jcc-deuda-item:hover:not(.bloqueada) {
  box-shadow: var(--shadow);
  transform: translateX(2px);
}
#jcc-root .jcc-deuda-item.vencida     { border-left-color: var(--c-warn); }
#jcc-root .jcc-deuda-item.seleccionada {
  border-color: var(--c-accent);
  border-left-color: var(--c-accent);
  background: #FDF0F0;
}
#jcc-root .jcc-deuda-item.bloqueada   { cursor: not-allowed; }
#jcc-root .jcc-deuda-item.bloqueada .jcc-check { opacity: .45; }
#jcc-root .jcc-deuda-item.bloqueada .jcc-deuda-info h3,
#jcc-root .jcc-deuda-item.bloqueada .jcc-deuda-meta,
#jcc-root .jcc-deuda-item.bloqueada .jcc-deuda-amount { color: rgba(0,0,0,0.35); }
#jcc-root .jcc-deuda-item.bloqueada .jcc-deuda-amount strong { color: rgba(0,0,0,0.35); }
#jcc-root .jcc-deuda-item.pagada      {
  cursor: default;
  grid-template-columns: 1fr auto;
  border-left-color: var(--c-ok);
}
#jcc-root .jcc-deuda-item.pagada:hover { transform: none; box-shadow: none; }

/* Ocultar el checkbox nativo con máxima especificidad — el theme no puede pisarlo */
#jcc-root input.jcc-checkbox,
#jcc-root input[type="checkbox"].jcc-checkbox,
#jcc-root .jcc-deuda-item input[type="checkbox"] {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Checkbox visual — pointer-events:none para que el click pase al item */
#jcc-root .jcc-check {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--c-border);
  border-radius: 6px;
  background: #fff;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: none;
}
#jcc-root .seleccionada .jcc-check {
  background: var(--c-accent);
  border-color: var(--c-accent);
}
#jcc-root .seleccionada .jcc-check::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

/* Info de la deuda */
#jcc-root .jcc-deuda-info h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--c-text);
  margin: 0 0 4px;
  padding: 0;
  line-height: 1.4;
  background: none;
  border: none;
}
#jcc-root .jcc-deuda-meta {
  font-size: 12px;
  color: var(--c-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
}
#jcc-root .jcc-cargo-note { font-size: 11px; color: var(--c-warn); margin-top: 3px; }

/* Monto */
#jcc-root .jcc-deuda-amount {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
#jcc-root .jcc-deuda-amount strong {
  font-size: 18px;
  font-weight: 700;
  display: block;
  color: var(--c-text);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
#jcc-root .jcc-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}
#jcc-root .jcc-badge-vencida   { background: var(--c-warn-bg);   color: var(--c-warn); }
#jcc-root .jcc-badge-pendiente { background: #FEF3CD;             color: #856404; }
#jcc-root .jcc-badge-pagada    { background: var(--c-ok-bg);      color: var(--c-ok); }

/* ── Tooltip + info ──────────────────────────────────────────────────────── */
#jcc-root .jcc-info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
}
#jcc-root .jcc-info-icon {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-accent);
  border: 1px solid var(--c-accent);
  border-radius: 20px;
  padding: 1px 7px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  line-height: 1.6;
}
#jcc-root .jcc-info-tip:hover .jcc-info-icon,
#jcc-root .jcc-info-tip.open  .jcc-info-icon {
  background: var(--c-accent);
  color: #fff;
}
#jcc-root .jcc-info-bubble {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: var(--c-text);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 10px;
  width: 260px;
  box-shadow: 0 4px 6px rgba(0,0,0,.06), 0 10px 30px rgba(0,0,0,.13);
  border: 1px solid var(--c-border);
  z-index: 9999;
  pointer-events: none;
  white-space: normal;
}
#jcc-root .jcc-info-tip:hover .jcc-info-bubble,
#jcc-root .jcc-info-tip.open  .jcc-info-bubble { display: block; }

/* ── Historial agrupado ──────────────────────────────────────────────────── */
#jcc-root .jcc-mes-grupo  { margin-bottom: 28px; }
#jcc-root .jcc-mes-label  {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--c-border);
}
#jcc-root .jcc-mes-nombre { font-size: 17px; font-weight: 700; color: var(--c-text); }
#jcc-root .jcc-mes-sub    { font-size: 12px; color: var(--c-muted); }
#jcc-root .jcc-mes-total  { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--c-ok); }

/* ── Botón cargar más ────────────────────────────────────────────────────── */
#jcc-root .jcc-btn-cargar-mas {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  color: var(--c-text);
  padding: 12px 32px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  outline: none;
  box-shadow: none;
  line-height: 1.4;
}
#jcc-root .jcc-btn-cargar-mas:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
  box-shadow: var(--shadow);
}
#jcc-root .jcc-cargar-hint { font-size: 11px; color: var(--c-muted); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
#jcc-root .jcc-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--c-muted);
}
#jcc-root .jcc-empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
#jcc-root .jcc-empty h3   { font-size: 20px; color: var(--c-text); margin-bottom: 6px; }
#jcc-root .jcc-empty p    { margin: 0; }

/* Link */
#jcc-root .jcc-link {
  color: var(--c-accent);
  font-size: 12px;
  text-decoration: none;
  font-weight: 500;
}
#jcc-root .jcc-link:hover { text-decoration: underline; }
#jcc-root .jcc-aviso { font-size: 14px; color: var(--c-muted); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #jcc-root .jcc-total-banner  { flex-direction: column; align-items: flex-start; }
  #jcc-root .jcc-btn-pagar     { width: 100%; text-align: center; }
  #jcc-root .jcc-deuda-item:not(.pagada) { grid-template-columns: 26px 1fr; }
  #jcc-root .jcc-deuda-amount  { grid-column: 2; justify-self: end; }
  #jcc-root .jcc-info-bubble   { left: auto; right: 0; transform: none; width: 220px; }
}
