/* ===== Censo Pesquero · Chat widget (popup + página) ===== */
:root {
  --cpc-accent: #0a6fb5;
  --cpc-accent-dark: #075486;
  --cpc-bot-bg: #f1f4f7;
  --cpc-text: #1c2b36;
  --cpc-radius: 16px;
  --cpc-font: 'Inter', system-ui, sans-serif;
}

/* --- Botón flotante (FAB) --- */
.cpc-fab {
  position: fixed; right: 20px; bottom: 78px; z-index: 9998;
  width: 62px; height: 62px; border-radius: 50%; border: none;
  background: transparent; padding: 0; cursor: pointer; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  transition: transform .15s ease;
}
.cpc-fab:hover { transform: scale(1.06); }
.cpc-fab img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* --- Panel del popup --- */
.cpc-panel {
  position: fixed; right: 20px; bottom: 150px; z-index: 9999;
  width: 380px; max-width: calc(100vw - 32px);
  height: 70vh; max-height: 620px;
  background: #fff; border-radius: var(--cpc-radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
  display: none; flex-direction: column; overflow: hidden;
}
.cpc-panel.cpc-open { display: flex; }

/* --- Header (popup y página) --- */
.cpc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--cpc-accent); color: #fff;
}
.cpc-header-logo { width: 36px; height: 36px; object-fit: contain;
  background: #fff; border-radius: 50%; padding: 3px; }
.cpc-header-titles { display: flex; flex-direction: column; line-height: 1.1; margin-right: auto; }
.cpc-header-titles strong { font-size: 15px; font-family: var(--cpc-font); }
.cpc-header-titles span { font-size: 12px; opacity: .85; font-family: var(--cpc-font); }
.cpc-icon-btn {
  background: transparent; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 6px; text-decoration: none; border-radius: 8px;
}
.cpc-icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }

/* --- Zona de montaje (mensajes + input) --- */
.cpc-mount { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.cpc-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  font-family: var(--cpc-font); color: var(--cpc-text);
  background: #fbfcfd;
}
.cpc-msg { display: flex; }
.cpc-msg.cpc-user { justify-content: flex-end; }
.cpc-bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.5; white-space: normal; word-wrap: break-word;
}
.cpc-bot .cpc-bubble { background: var(--cpc-bot-bg); border-bottom-left-radius: 4px; }
.cpc-user .cpc-bubble { background: var(--cpc-accent); color: #fff; border-bottom-right-radius: 4px; }
.cpc-bubble a { color: inherit; text-decoration: underline; }
.cpc-bot .cpc-bubble a { color: var(--cpc-accent-dark); }
.cpc-bubble code { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

/* --- Adjuntos --- */
.cpc-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cpc-att {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #d7dee5; border-radius: 10px;
  padding: 6px 10px; font-size: 13px; color: var(--cpc-accent-dark);
  text-decoration: none; max-width: 100%;
}
.cpc-att:hover { border-color: var(--cpc-accent); }
.cpc-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpc-user .cpc-att { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.4); color: #fff; }

/* --- Indicador "escribiendo" --- */
.cpc-typing .cpc-bubble { display: inline-flex; gap: 4px; }
.cpc-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #9aa7b2;
  display: inline-block; animation: cpc-blink 1.2s infinite both;
}
.cpc-typing i:nth-child(2) { animation-delay: .2s; }
.cpc-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes cpc-blink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* --- Input --- */
.cpc-input {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px; border-top: 1px solid #e6ebf0; background: #fff;
}
.cpc-input textarea {
  flex: 1; resize: none; border: 1px solid #d7dee5; border-radius: 12px;
  padding: 9px 12px; font-family: var(--cpc-font); font-size: 14.5px;
  max-height: 120px; line-height: 1.4; outline: none;
}
.cpc-input textarea:focus { border-color: var(--cpc-accent); }
.cpc-btn {
  border: none; cursor: pointer; border-radius: 12px; padding: 9px;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none;
}
.cpc-send { background: var(--cpc-accent); color: #fff; }
.cpc-send:hover { background: var(--cpc-accent-dark); }
.cpc-file { background: #eef2f6; color: var(--cpc-accent-dark); }
.cpc-file:hover { background: #e2e8ee; }

/* --- Chips de archivos pendientes de enviar --- */
.cpc-pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 6px; background: #fff; }
.cpc-pending .cpc-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: #eef2f6; border-radius: 9px; padding: 4px 8px; font-family: var(--cpc-font);
}
.cpc-pending .cpc-chip button { border: none; background: none; cursor: pointer; color: #8593a0; font-size: 14px; }
.cpc-note { padding: 0 12px 6px; font-size: 12px; color: #c0392b; font-family: var(--cpc-font); }

/* ===== Página dedicada (chat.php) ===== */
.cpc-page-body { margin: 0; background: #eef2f6; }
.cpc-page-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--cpc-accent); color: #fff; font-family: var(--cpc-font);
}
.cpc-page-header img { width: 40px; height: 40px; object-fit: contain;
  background: #fff; border-radius: 50%; padding: 3px; }
.cpc-page-header .cpc-page-title { font-weight: 600; margin-right: auto; }
.cpc-page-header a { color: #fff; text-decoration: none; font-size: 14px; opacity: .9; }
.cpc-page-header a:hover { opacity: 1; text-decoration: underline; }
.cpc-page {
  max-width: 820px; margin: 0 auto; height: calc(100vh - 64px);
  display: flex; flex-direction: column; background: #fff;
}
.cpc-page .cpc-mount { height: 100%; }
.cpc-page .cpc-messages { background: #fff; }

@media (max-width: 480px) {
  .cpc-panel { right: 8px; left: 8px; bottom: 150px; width: auto; height: 72vh; }
}
