/*
 * ============================================================================
 *  Bot DIAN — Notas Crédito / Débito / Documentos Soporte (Estilos)
 *  Archivo:  public/css/bot-dian-notas.css
 *  Proyecto: Celumania (app.ryhdistribuciones.com)
 *  Autor:    Claude para Andrés R&H — 2026-06-06
 *
 *  Se carga DESPUÉS de bot-dian.css.
 *  Sólo agrega estilos adicionales para el tab "Notas DIAN".
 * ============================================================================
 */

/* ── HEADER DEL PANEL ────────────────────────────────────────────────────── */
.bdn-panel .bdn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

.bdn-panel .bdn-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

/* ── SUB-TABS ────────────────────────────────────────────────────────────── */
.bdn-subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.bdn-subtab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 2px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.bdn-subtab:hover {
  border-color: #6366f1;
  color: #6366f1;
  background: #eef2ff;
}

.bdn-subtab.active {
  border-color: #6366f1;
  background: #6366f1;
  color: #fff;
}

/* ── FILTROS ─────────────────────────────────────────────────────────────── */
.bdn-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 16px;
}

.bdn-filtros select,
.bdn-filtros input[type="date"] {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #374151;
  background: #fff;
  min-width: 140px;
  height: 34px;
}

.bdn-filtros select:focus,
.bdn-filtros input[type="date"]:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ── TABLA WRAP ──────────────────────────────────────────────────────────── */
.bdn-tabla-wrap {
  min-height: 80px;
}

.bdn-tabla-scroll {
  overflow-x: auto;
}

.bdn-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.bdn-tabla th {
  background: #f3f4f6;
  color: #374151;
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid #e5e7eb;
}

.bdn-tabla td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.bdn-tabla tr:hover td {
  background: #f9fafb;
}

.bdn-tabla code {
  font-size: 0.75rem;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
}

.bdn-acciones {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.bdn-count {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 8px;
}

.bdn-loading,
.bdn-empty {
  text-align: center;
  color: #9ca3af;
  padding: 32px 0;
  font-size: 0.9rem;
}

.bdn-error {
  color: #dc2626;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 6px;
  border: 1px solid #fecaca;
  margin-top: 8px;
}

/* ── BADGES DE ESTADO ────────────────────────────────────────────────────── */
[class^="bdn-badge-"] {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.bdn-badge-credito  { background: #d1fae5; color: #065f46; }
.bdn-badge-debito   { background: #ffedd5; color: #9a3412; }
.bdn-badge-pendiente { background: #fef9c3; color: #854d0e; }
.bdn-badge-exitoso  { background: #d1fae5; color: #065f46; }
.bdn-badge-error    { background: #fee2e2; color: #991b1b; }
.bdn-badge-enviando { background: #dbeafe; color: #1e40af; }
.bdn-badge-omitido  { background: #f3f4f6; color: #4b5563; }
.bdn-badge-doc      { background: #ede9fe; color: #5b21b6; }

/* ── BOTONES ESTILO BD ───────────────────────────────────────────────────── */
.bd-btn-sm {
  padding: 3px 8px !important;
  font-size: 0.75rem !important;
  height: auto !important;
}

.bd-btn-info {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.bd-btn-info:hover {
  background: #93c5fd;
  color: #1e40af;
}

/* ── TOOLTIP ─────────────────────────────────────────────────────────────── */
.bdn-tooltip {
  cursor: help;
  position: relative;
}

.bdn-tooltip::after {
  content: attr(title);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  max-width: 280px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 1000;
}

.bdn-tooltip:hover::after {
  opacity: 1;
}

/* ── MODAL OVERLAY ───────────────────────────────────────────────────────── */
.bdn-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.bdn-modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.bdn-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.bdn-modal-header h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.bdn-modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.bdn-modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.bdn-modal-body {
  padding: 20px;
}

.bdn-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #f3f4f6;
  background: #f9fafb;
  border-radius: 0 0 12px 12px;
}

/* ── FORMULARIO MODAL ────────────────────────────────────────────────────── */
.bdn-form-row {
  margin-bottom: 14px;
}

.bdn-form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.bdn-form-label .bdn-req {
  color: #ef4444;
}

.bdn-form-input,
.bdn-form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 0.88rem;
  color: #111827;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.bdn-form-input:focus,
.bdn-form-select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.bdn-form-input[type="number"] {
  text-align: right;
}

textarea.bdn-form-input {
  resize: vertical;
  min-height: 80px;
}

.bdn-form-row small {
  font-size: 0.76rem;
  color: #9ca3af;
  margin-top: 3px;
  display: block;
}

/* ── TABLA RESUMEN EN MODAL ──────────────────────────────────────────────── */
.bdn-resumen {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.87rem;
}

.bdn-resumen td {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
}

.bdn-resumen td:first-child {
  color: #6b7280;
  width: 40%;
}

/* ── ALERTAS EN MODAL ────────────────────────────────────────────────────── */
.bdn-advertencia {
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.83rem;
  color: #854d0e;
  margin-top: 12px;
}

.bdn-alert-success {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  padding: 12px 16px;
  color: #065f46;
  font-size: 0.87rem;
  margin-top: 12px;
}

.bdn-alert-success code {
  font-size: 0.76rem;
  background: rgba(0,0,0,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}

.bdn-alert-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 12px 16px;
  color: #991b1b;
  font-size: 0.87rem;
  margin-top: 12px;
}

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.bdn-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.87rem;
  font-weight: 500;
  color: #fff;
  z-index: 99999;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: bdnToastIn 0.25s ease;
}

@keyframes bdnToastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.bdn-toast-success { background: #10b981; }
.bdn-toast-error   { background: #ef4444; }
.bdn-toast-info    { background: #6366f1; }
.bdn-toast-warning { background: #f59e0b; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .bdn-filtros {
    flex-direction: column;
  }

  .bdn-filtros select,
  .bdn-filtros input[type="date"] {
    width: 100%;
    min-width: unset;
  }

  .bdn-modal-box {
    max-height: 95vh;
  }

  .bdn-tabla th,
  .bdn-tabla td {
    padding: 6px 8px;
    font-size: 0.78rem;
  }
}

/* ── MODAL: BÚSQUEDA Y DETALLE DE FACTURA (paso 2) ──────────────────────── */

/* Tarjeta resumen de la factura encontrada */
.bdn-fact-card {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 4px;
}

.bdn-fact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #374151;
  padding: 2px 0;
}

.bdn-fact-totales {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #bbf7d0;
  font-weight: 500;
  color: #166534;
}

/* Tabla de ítems seleccionables */
.bdn-items-wrap {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-top: 6px;
}

.bdn-items-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.bdn-items-tabla thead {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
}

.bdn-items-tabla th {
  padding: 7px 8px;
  text-align: left;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.bdn-items-tabla td {
  padding: 7px 8px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.bdn-items-tabla tr:hover td {
  background: #f0fdf4;
}

.bdn-items-tabla tr:last-child td {
  border-bottom: none;
}

.bdn-item-chk {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #059669;
}

/* Totales calculados */
.bdn-totales-calc {
  margin: 8px 0 12px;
}

.bdn-totales-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: #065f46;
}

.bdn-totales-vacio {
  background: #fff7ed;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: #92400e;
}
