/* ─── Greendrive IA — Chat Widget ─────────────────────────────────────────── */
/* Javier Toledo · Greendrive compliance · greendrivecompliance.com            */

:root {
  --gd-verde:  #1A6B45;
  --gd-lima:   #2ECC71;
  --gd-oscuro: #111827;
  --gd-gris:   #F9FAFB;
  --gd-borde:  #E5E7EB;
  --gd-texto:  #1F2937;
  --gd-radio:  12px;
  --gd-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

/* ── Contenedor principal ───────────────────────────────────────────────────── */
.gd-chat-widget {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 780px;
  min-height: 520px;
  border-radius: var(--gd-radio);
  box-shadow: var(--gd-shadow);
  overflow: hidden;
  font-family: 'Inter', 'Calibri', sans-serif;
  margin: 0 auto 32px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.gd-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--gd-verde);
  color: #fff;
}

.gd-chat-icon {
  font-size: 18px;
}

.gd-chat-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.gd-chat-badge {
  background: var(--gd-lima);
  color: var(--gd-verde);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.08em;
}

/* ── Área de mensajes ───────────────────────────────────────────────────────── */
.gd-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--gd-gris);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
}

/* ── Burbujas ───────────────────────────────────────────────────────────────── */
.gd-msg {
  display: flex;
  max-width: 88%;
}

.gd-msg-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.gd-msg-bot,
.gd-msg-bot.error {
  align-self: flex-start;
}

.gd-msg-content {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gd-texto);
}

.gd-msg-user .gd-msg-content {
  background: var(--gd-verde);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.gd-msg-bot .gd-msg-content {
  background: #fff;
  border: 1px solid var(--gd-borde);
  border-bottom-left-radius: 4px;
}

.gd-msg-bot.error .gd-msg-content {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}

/* ── Tablas dentro del chat ─────────────────────────────────────────────────── */
.gd-msg-content .gd-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
}

.gd-msg-content .gd-table th,
.gd-msg-content .gd-table td {
  border: 1px solid var(--gd-borde);
  padding: 6px 10px;
  text-align: left;
}

.gd-msg-content .gd-table th {
  background: var(--gd-verde);
  color: #fff;
  font-weight: 600;
}

.gd-msg-content .gd-table tr:nth-child(even) td {
  background: #F0FDF4;
}

/* ── Listas dentro del chat ─────────────────────────────────────────────────── */
.gd-msg-content ul {
  padding-left: 18px;
  margin: 6px 0;
}

.gd-msg-content li {
  margin-bottom: 4px;
}

/* ── Párrafos ───────────────────────────────────────────────────────────────── */
.gd-msg-content p {
  margin: 0 0 8px;
}
.gd-msg-content p:last-child {
  margin-bottom: 0;
}

/* ── Advertencia ────────────────────────────────────────────────────────────── */
.gd-warn {
  font-size: 13px;
}

/* ── Indicador de escritura ─────────────────────────────────────────────────── */
.gd-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px !important;
}

.gd-typing span {
  width: 7px;
  height: 7px;
  background: var(--gd-verde);
  border-radius: 50%;
  display: inline-block;
  animation: gd-bounce 1.2s infinite;
  opacity: 0.7;
}

.gd-typing span:nth-child(2) { animation-delay: 0.2s; }
.gd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gd-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── Input area ─────────────────────────────────────────────────────────────── */
.gd-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--gd-borde);
  align-items: flex-end;
}

.gd-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--gd-borde);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gd-texto);
  outline: none;
  transition: border-color 0.2s;
  min-height: 44px;
  max-height: 120px;
}

.gd-chat-input:focus {
  border-color: var(--gd-verde);
  box-shadow: 0 0 0 3px rgba(26, 107, 69, 0.12);
}

.gd-chat-send {
  background: var(--gd-verde);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  height: 44px;
}

.gd-chat-send:hover {
  background: #155c3a;
}

.gd-chat-send:active {
  transform: scale(0.97);
}

.gd-chat-send:disabled {
  background: #9CA3AF;
  cursor: not-allowed;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.gd-chat-footer {
  padding: 8px 14px;
  background: #F9FAFB;
  border-top: 1px solid var(--gd-borde);
  font-size: 11px;
  color: #9CA3AF;
  text-align: center;
}

.gd-chat-footer a {
  color: var(--gd-verde);
  text-decoration: none;
  font-weight: 500;
}

.gd-chat-footer a:hover {
  text-decoration: underline;
}

/* ── Responsive móvil ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .gd-chat-widget {
    border-radius: 8px;
    min-height: 460px;
  }

  .gd-chat-messages {
    max-height: 320px;
    padding: 12px 10px;
  }

  .gd-msg {
    max-width: 96%;
  }

  .gd-chat-input-area {
    flex-direction: column;
  }

  .gd-chat-send {
    width: 100%;
    height: 40px;
  }

  .gd-msg-content .gd-table {
    font-size: 11px;
  }
}


/* =============================================
   GD TABLAS — Estilo profesional para matrices
   ============================================= */
.gd-msg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
}
.gd-msg-content table thead tr {
  background: #15803d;
  color: #ffffff;
  text-align: left;
}
.gd-msg-content table thead th {
  padding: 9px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: none;
}
.gd-msg-content table tbody tr {
  border-bottom: 1px solid #e5e7eb;
  transition: background 0.15s;
}
.gd-msg-content table tbody tr:nth-child(even) {
  background-color: #f0fdf4;
}
.gd-msg-content table tbody tr:hover {
  background-color: #dcfce7;
}
.gd-msg-content table tbody td {
  padding: 8px 12px;
  color: #1f2937;
  vertical-align: top;
  line-height: 1.45;
}
.gd-msg-content table tbody td:first-child {
  font-weight: 600;
  color: #15803d;
  white-space: nowrap;
}

/* =============================================
   GD DOWNLOADS v1 — Botones de descarga
   ============================================= */
.gd-dl-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.08);
  flex-wrap: wrap;
}
.gd-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.gd-dl-pdf {
  background: #fff1f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
}
.gd-dl-pdf:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 2px 6px rgba(220,38,38,0.25);
}
.gd-dl-csv {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #16a34a;
}
.gd-dl-csv:hover {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 2px 6px rgba(22,163,74,0.25);
}

/* =============================================
   GD RESPONSIVE — Móvil y tablet (v1.2.0)
   ============================================= */

/* Tablet: 768px o menos */
@media (max-width: 768px) {

  .gd-chat-widget {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 460px !important;
    border-radius: 10px !important;
    margin-bottom: 20px !important;
  }

  .gd-chat-messages {
    height: 280px !important;
    max-height: 280px !important;
  }

  .gd-msg-content {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  .gd-chat-input-area textarea {
    font-size: 16px !important; /* evita zoom automático en iOS */
    min-height: 44px !important;
    padding: 10px 12px !important;
  }

  .gd-chat-input-area button {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 14px !important;
    font-size: 14px !important;
  }

  .gd-chat-header {
    padding: 10px 14px !important;
    font-size: 13px !important;
  }

  /* Tablas: scroll horizontal en móvil */
  .gd-msg-content table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }

  .gd-msg-content table tbody td:first-child {
    white-space: normal !important;
    min-width: 100px !important;
  }

  /* Botones de descarga en columna */
  .gd-dl-bar {
    flex-direction: column !important;
    gap: 6px !important;
  }

  .gd-dl-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px !important;
    font-size: 13px !important;
  }
}

/* Móvil: 480px o menos */
@media (max-width: 480px) {

  .gd-chat-widget {
    min-height: 420px !important;
    border-radius: 8px !important;
  }

  .gd-chat-messages {
    height: 250px !important;
    max-height: 250px !important;
  }

  .gd-msg {
    max-width: 95% !important;
  }

  .gd-msg-content {
    font-size: 12.5px !important;
    padding: 8px 11px !important;
  }

  .gd-chat-header {
    font-size: 12px !important;
    padding: 9px 12px !important;
  }

  /* Typing dots más pequeños en móvil */
  .gd-typing span {
    width: 7px !important;
    height: 7px !important;
  }
}