/*
Archivo: ez/patsbot/css/catbot_widget.css
Módulo: PATS / CAT BOT
Propósito: Estilos mobile-first del widget reutilizable CAT BOT PATS.
Responsabilidad: Interfaz simple, premium, sólida y 100% responsive para app web.
Conexiones: catbot_widget.php y catbot_widget.js.
Tipo: Transversal reutilizable dentro de PATSBOT.
*/

.pats-cw,
.pats-cw * {
  box-sizing: border-box;
}

.pats-cw {
  --cw-bg: #f0f4fb;
  --cw-card: #ffffff;
  --cw-soft: #e2eaf6;
  --cw-line: rgba(37, 99, 235, 0.12);
  --cw-text: #1e3a5f;
  --cw-muted: #6b85a8;
  --cw-blue: #2563eb;
  --cw-indigo: #1e3a5f;
  --cw-violet: #60a5fa;
  --cw-green: #0e7a5f;
  --cw-warn: #d97706;
  --cw-danger: #dc2626;
  --cw-shadow: 0 8px 32px rgba(30, 58, 95, .14), 0 4px 12px rgba(30, 58, 95, .08);
  width: 100%;
  max-width: 100%;
  color: var(--cw-text);
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pats-cw-card {
  width: 100%;
  max-width: 100%;
  background: var(--cw-bg);
  border: 1px solid var(--cw-line);
  border-radius: 22px;
  box-shadow: var(--cw-shadow);
  overflow: hidden;
}

.pats-cw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  background: radial-gradient(circle at 90% 0%, rgba(0, 217, 200, .12), transparent 30%), linear-gradient(135deg, rgba(7, 17, 39, .96), rgba(11, 29, 83, .95) 54%, rgba(15, 48, 128, .94));
  color: #fff;
}

.pats-cw-brand {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: center;
}

.pats-cw-mark {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #e2eaf6;
  color: #2563eb;
  font-size: 25px;
  font-weight: 950;
}

.pats-cw-brand span {
  display: block;
  margin-bottom: 3px;
  color: rgba(255, 255, 255, .65);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 900;
}

.pats-cw-brand h2 {
  margin: 0;
  font-size: clamp(19px, 5vw, 25px);
  line-height: 1.08;
  font-weight: 950;
}

.pats-cw-brand p {
  margin: 5px 0 0;
  max-width: 580px;
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
}

.pats-cw-live {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 950;
}

.pats-cw-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
}

.pats-cw-modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
  background: #f0f4fb;
  border-bottom: 1px solid var(--cw-line);
}

.pats-cw.is-user-widget .pats-cw-modes {
  grid-template-columns: repeat(2, 1fr);
}

.pats-cw-modes button {
  min-height: 42px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  background: #e2eaf6;
  color: var(--cw-text);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  padding: 0 10px;
}

.pats-cw-modes button.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--cw-blue), var(--cw-violet));
  color: #fff;
}

.pats-cw-context {
  margin: 12px;
  border: 1px solid var(--cw-line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.pats-cw-context summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 13px 15px;
}

.pats-cw-context summary::-webkit-details-marker {
  display: none;
}

.pats-cw-context summary span {
  font-size: 13px;
  font-weight: 950;
  color: var(--cw-text);
}

.pats-cw-context summary b {
  min-width: 0;
  text-align: right;
  color: var(--cw-muted);
  font-size: 11px;
  font-weight: 850;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pats-cw-context-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0 15px 15px;
}

.pats-cw-context label {
  display: grid;
  gap: 6px;
}

.pats-cw-context label span {
  color: #526481;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 950;
}

.pats-cw-context input,
.pats-cw-context select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 14px;
  background: #fff;
  color: var(--cw-text);
  padding: 0 12px;
  font-size: 15px;
  font-weight: 750;
  outline: none;
}

.pats-cw-context input:focus,
.pats-cw-context select:focus,
.pats-cw-form textarea:focus,
.pats-cw-rbox textarea:focus {
  border-color: var(--cw-indigo);
  box-shadow: 0 0 0 3px rgba(49, 68, 199, .12);
}

.pats-cw-clear-context {
  width: calc(100% - 30px);
  margin: 0 15px 15px;
  min-height: 42px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 14px;
  background: #e2eaf6;
  color: var(--cw-blue);
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}

.pats-cw-quick {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  scrollbar-width: thin;
  background: #f0f4fb;
  border-bottom: 1px solid var(--cw-line);
}

.pats-cw-quick button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--cw-text);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.pats-cw-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
}

.pats-cw-chat,
.pats-cw-result {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--cw-line);
  border-radius: 18px;
  overflow: hidden;
}

.pats-cw-chat {
  display: flex;
  flex-direction: column;
  min-height: 430px;
}

.pats-cw-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--cw-line);
  background: #fff;
}

.pats-cw-chat-head span {
  display: block;
  color: var(--cw-blue);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 950;
}

.pats-cw-chat-head h3 {
  margin: 3px 0 0;
  color: var(--cw-text);
  font-size: 19px;
  line-height: 1.1;
  font-weight: 950;
}

.pats-cw-chat-head button {
  min-height: 36px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 13px;
  background: #e2eaf6;
  color: var(--cw-blue);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}

.pats-cw-messages {
  flex: 1;
  min-height: 250px;
  max-height: min(54vh, 520px);
  overflow: auto;
  padding: 15px;
  background: #f0f4fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.pats-cw-msg {
  width: 100%;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.pats-cw-msg.is-user {
  flex-direction: row-reverse;
}

.pats-cw-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: #e2eaf6;
  color: var(--cw-blue);
  font-size: 18px;
  font-weight: 950;
}

.pats-cw-msg.is-user .pats-cw-avatar {
  background: linear-gradient(135deg, var(--cw-blue), var(--cw-violet));
  color: #fff;
}

.pats-cw-bubble {
  max-width: min(86%, 640px);
  background: #fff;
  border: 1px solid var(--cw-line);
  border-radius: 16px;
  padding: 12px 13px;
}

.pats-cw-msg.is-user .pats-cw-bubble {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.pats-cw-bubble strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 950;
}

.pats-cw-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.47;
  font-weight: 650;
}

.pats-cw-bubble small {
  display: block;
  margin-top: 7px;
  color: var(--cw-muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 800;
}

.pats-cw-msg.is-user .pats-cw-bubble small {
  color: #dce7ff;
}

.pats-cw-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--cw-line);
}

.pats-cw-form textarea {
  width: 100%;
  min-height: 52px;
  max-height: 132px;
  resize: none;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 15px;
  background: #fff;
  color: var(--cw-text);
  padding: 14px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 650;
  outline: none;
}

.pats-cw-form button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--cw-blue), var(--cw-violet));
  color: #fff;
  font-size: 15px;
  font-weight: 950;
  cursor: pointer;
}

.pats-cw-form button:disabled {
  opacity: .65;
  cursor: wait;
}

.pats-cw-result {
  min-height: 220px;
  max-height: none;
  overflow: auto;
  background: #f0f4fb;
  padding: 12px;
}

.pats-cw-empty {
  min-height: 206px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 9px;
  background: #fff;
  border: 1px solid var(--cw-line);
  border-radius: 16px;
  padding: 22px;
}

.pats-cw-empty div {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--cw-blue), var(--cw-violet));
  color: #fff;
  font-size: 28px;
  font-weight: 950;
}

.pats-cw-empty h3 {
  margin: 4px 0 0;
  color: var(--cw-text);
  font-size: 20px;
  line-height: 1.1;
  font-weight: 950;
}

.pats-cw-empty p {
  margin: 0;
  max-width: 330px;
  color: var(--cw-muted);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 650;
}

.pats-cw-result-inner {
  display: grid;
  gap: 10px;
}

.pats-cw-result-head {
  padding: 16px;
  border-radius: 16px;
  color: #fff;
  background: radial-gradient(circle at 90% 0%, rgba(0, 217, 200, .12), transparent 30%), linear-gradient(135deg, rgba(7, 17, 39, .96), rgba(11, 29, 83, .95) 54%, rgba(15, 48, 128, .94));
}

.pats-cw-result-head.is-user {
  display: none;
}

.pats-cw-result-head span {
  display: block;
  color: rgba(255, 255, 255, .65);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 950;
}

.pats-cw-result-head h3 {
  margin: 6px 0 10px;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 950;
}

.pats-cw-result-head div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pats-cw-result-head b {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.24);
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
}

.pats-cw-rbox {
  border: 1px solid var(--cw-line);
  border-left: 5px solid var(--cw-indigo);
  border-radius: 16px;
  background: #fff;
  padding: 14px;
}

.pats-cw.is-user-widget .pats-cw-rbox {
  border-left-color: var(--cw-blue);
}

.pats-cw-rbox.is-whatsapp {
  border-left-color: var(--cw-green);
}

.pats-cw-rbox.is-warning {
  border-left-color: var(--cw-warn);
}

.pats-cw-rbox.is-critical {
  border-left-color: var(--cw-danger);
}

.pats-cw-rbox header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 9px;
}

.pats-cw-rbox h4 {
  margin: 0 0 8px;
  color: var(--cw-text);
  font-size: 14px;
  line-height: 1.22;
  font-weight: 950;
}

.pats-cw-rbox header h4 {
  margin: 0;
}

.pats-cw-rbox p,
.pats-cw-rbox li {
  margin: 0;
  color: #2d4a6e;
  font-size: 14px;
  line-height: 1.52;
  font-weight: 650;
}

.pats-cw-rbox ul {
  margin: 0;
  padding-left: 18px;
}

.pats-cw-rbox header button {
  min-height: 32px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  background: #e2eaf6;
  color: var(--cw-blue);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.pats-cw-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.pats-cw-feedback button {
  min-height: 34px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  background: #e2eaf6;
  color: var(--cw-text);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.pats-cw-feedback button.is-selected {
  background: var(--cw-blue);
  border-color: var(--cw-blue);
  color: #fff;
}

.pats-cw-rbox textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 13px;
  background: #fff;
  color: var(--cw-text);
  padding: 11px;
  font-size: 13px;
  font-weight: 650;
  outline: none;
}

.pats-cw-rbox small[data-cw-feedback-status] {
  display: block;
  margin-top: 7px;
  color: var(--cw-muted);
  font-size: 12px;
  font-weight: 800;
}

.pats-cw-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 5px;
}

.pats-cw-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cw-indigo);
  animation: patsCwDot 1s infinite ease-in-out;
}

.pats-cw-dots i:nth-child(2) {
  animation-delay: .12s;
}

.pats-cw-dots i:nth-child(3) {
  animation-delay: .24s;
}

@keyframes patsCwDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (min-width: 560px) {
  .pats-cw-context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pats-cw-form {
    grid-template-columns: 1fr 118px;
  }

  .pats-cw-form button {
    width: auto;
  }
}

@media (min-width: 980px) {
  .pats-cw-body {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .82fr);
    align-items: stretch;
  }

  .pats-cw.is-user-widget .pats-cw-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .pats-cw-chat,
  .pats-cw-result {
    min-height: 420px;
  }

  .pats-cw.is-user-widget .pats-cw-result {
    min-height: 180px;
  }
}

@media (max-width: 430px) {
  .pats-cw-card {
    border-radius: 18px;
  }

  .pats-cw-head {
    padding: 15px;
  }

  .pats-cw-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 22px;
  }

  .pats-cw-live {
    display: none;
  }

  .pats-cw-modes {
    grid-template-columns: repeat(2, 1fr);
  }

  .pats-cw-bubble {
    max-width: 88%;
  }
}
