/* ==========================================================================
   Konversa — Plataforma de chat en vivo
   Estilos compartidos (login, registro, panel de chat)
   ========================================================================== */

:root {
  /* Marca */
  --brand:      #5b3df5;
  --brand-2:    #7c3aed;
  --brand-dark: #4327c9;
  --accent:     #ec4899;
  --accent-2:   #f472b6;

  /* Neutros */
  --ink:     #0f1729;
  --ink-2:   #1e293b;
  --muted:   #64748b;
  --line:    #e6e8ef;
  --bg:      #ffffff;
  --soft:    #f4f3ff;
  --soft-2:  #faf9ff;

  /* Estados */
  --ok:      #16a34a;
  --warn:    #f59e0b;
  --danger:  #ef4444;

  /* Gradiente de marca */
  --grad: linear-gradient(135deg, #5b3df5 0%, #a855f7 55%, #ec4899 100%);

  --radius:   14px;
  --radius-lg: 22px;
  --shadow:   0 10px 40px rgba(30, 27, 75, .12);
  --shadow-sm: 0 4px 16px rgba(30, 27, 75, .08);

  --font: 'Poppins', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Selector de idioma ---------- */
.lang-select {
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 12px;
  background: #fff; cursor: pointer; transition: .15s;
}
.lang-select:hover { border-color: var(--brand); color: var(--brand); }
.lang-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,61,245,.12); }

/* ---------- Logo de marca ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -.5px;
  color: var(--ink);
}
.brand svg { width: 34px; height: 34px; flex: none; }
.brand.light { color: #fff; }
.brand .k-dot { color: var(--accent); }

/* ==========================================================================
   AUTH (login / registro)
   ========================================================================== */
.auth-shell { display: flex; flex-direction: column; min-height: 100%; }

.auth-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--line);
}
.auth-header .join-hint { color: var(--muted); font-size: 15px; }
.auth-header .join-hint b { color: var(--ink); font-weight: 600; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px;
  border: 1.5px solid var(--brand);
  color: var(--brand); font-weight: 600; font-size: 15px;
  background: #fff; transition: .18s;
}
.btn-ghost:hover { background: var(--soft); text-decoration: none; }

.auth-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 40px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 56px 40px;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 460px;
}
.auth-card .card-body { padding: 40px 40px 30px; }
.auth-card h1 { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.auth-card .sub { color: var(--muted); margin-top: 6px; margin-bottom: 26px; }

.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.field .control { position: relative; }
.field input {
  width: 100%;
  padding: 15px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px; font-family: inherit;
  transition: .15s; background: #fff;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(91,61,245,.12); }
.field input::placeholder { color: #9aa2b1; }
.field .toggle-eye {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--muted); background: none; border: none; padding: 4px;
  display: flex;
}
.field .toggle-eye:hover { color: var(--ink); }

.link-row { margin: -6px 0 8px; }
.link-row a { font-weight: 600; font-size: 15px; }

.card-foot { background: var(--soft); padding: 22px 40px 26px; }
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none; border-radius: 12px;
  background: var(--grad);
  color: #fff; font-weight: 700; font-size: 16px; font-family: inherit;
  cursor: pointer; transition: .18s;
  box-shadow: 0 8px 22px rgba(91,61,245,.32);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.form-msg { font-size: 14px; margin-top: 14px; min-height: 18px; text-align: center; }
.form-msg.err { color: var(--danger); }
.form-msg.ok  { color: var(--ok); }

/* Ilustración lateral */
.auth-illus { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.auth-illus .art { width: 100%; max-width: 460px; }
.auth-illus h2 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.auth-illus p { color: var(--muted); max-width: 380px; }
.pill-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.pill { background: var(--soft); color: var(--brand-2); font-weight: 600; font-size: 13px; padding: 7px 14px; border-radius: 999px; }

/* Footer */
.site-footer {
  background: var(--ink);
  color: #cbd2e0;
  padding: 54px 40px 40px;
}
.footer-grid {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 30px;
}
.site-footer h4 { color: #fff; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 18px; }
.site-footer a { color: #cbd2e0; display: block; margin-bottom: 12px; font-size: 15px; }
.site-footer a:hover { color: #fff; }
.site-footer .contact { font-size: 15px; margin: 6px 0 18px; }
.site-footer .contact b { color: #fff; display: block; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.footer-bottom { max-width: 1180px; margin: 34px auto 0; padding-top: 22px; border-top: 1px solid #26324a; font-size: 13px; color: #8a94a8; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* Responsive auth */
@media (max-width: 900px) {
  .auth-main { grid-template-columns: 1fr; }
  .auth-illus { display: none; }
  .auth-card { margin: 0 auto; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .auth-header { padding: 18px 20px; }
  .auth-header .join-hint { display: none; }
  .auth-main { padding: 30px 18px; }
  .auth-card .card-body { padding: 30px 24px 22px; }
  .card-foot { padding: 20px 24px 24px; }
  .auth-card h1 { font-size: 32px; }
  .footer-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   APP — Panel de chat en vivo
   ========================================================================== */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 340px 1fr 300px; grid-template-rows: 100vh; grid-template-rows: 100dvh; overflow: hidden; }

/* Columna 1: conversaciones */
.side {
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.side-top { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.side-brandrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.side-brandrow .brand { font-size: 21px; }
.side-brandrow .brand svg { width: 26px; height: 26px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; display: grid; place-items: center; color: var(--muted); transition: .15s; }
.icon-btn:hover { background: var(--soft); color: var(--brand); }

.search { position: relative; }
.search input { width: 100%; padding: 11px 14px 11px 40px; border: 1.5px solid var(--line); border-radius: 11px; font-family: inherit; font-size: 14px; }
.search input:focus { outline: none; border-color: var(--brand); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tab { flex: 1; text-align: center; padding: 9px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; border: none; background: none; transition: .15s; }
.tab.active { background: var(--soft); color: var(--brand); }
.tab .count { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 5px; }

/* Selector de modelos que atiende el operador */
.model-switch { margin: 12px 0 4px; }
.model-switch .ms-label { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 7px; }
.model-switch .ms-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
.ms-chip { flex: none; display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer; font-family: inherit; position: relative; transition: .14s; }
.ms-chip:hover { border-color: var(--brand); }
.ms-chip.active { border-color: var(--brand); background: var(--soft); box-shadow: 0 2px 8px rgba(91,61,245,.18); }
.ms-chip .ms-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.ms-chip .ms-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.ms-chip .ms-badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 999px; display: grid; place-items: center; padding: 0 5px; }

/* Barra de ganancias del modelo */
.earn-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(135deg, #f0fdf4, #ecfdf5); border: 1px solid #bbf7d0; }
.earn-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: #dcfce7; }
.earn-info .earn-lbl { font-size: 12px; color: #15803d; font-weight: 600; }
.earn-info .earn-val { font-size: 18px; font-weight: 800; color: #166534; letter-spacing: -.3px; }

.convo-list { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.convo {
  display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 13px;
  cursor: pointer; transition: .12s; position: relative;
}
.convo:hover { background: var(--soft-2); }
.convo.active { background: var(--soft); }
.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; position: relative; }
.avatar .dot { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid #fff; background: #cbd5e1; }
.avatar .dot.on { background: var(--ok); }
.convo-main { flex: 1; min-width: 0; }
.convo-main .name { font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; }
.convo-main .name .time { color: var(--muted); font-weight: 400; font-size: 12px; }
.convo-main .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }

/* Columna 2: chat */
.chat { display: flex; flex-direction: column; background: var(--soft-2); min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who .name { font-weight: 700; font-size: 16px; }
.chat-head .who .status { font-size: 13px; color: var(--ok); }
.chat-head .who .status.off { color: var(--muted); }
.chat-head .head-actions { display: flex; gap: 8px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 26px 10px; display: flex; flex-direction: column; gap: 10px; }
.day-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0; }
.msg { max-width: 62%; padding: 11px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; position: relative; word-wrap: break-word; }
.msg .meta { font-size: 11px; margin-top: 5px; opacity: .7; }
.msg.in  { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.typing { align-self: flex-start; background: #fff; border: 1px solid var(--line); padding: 14px 16px; border-radius: 16px; display: none; }
.typing.show { display: block; }
.typing span { display: inline-block; width: 7px; height: 7px; background: var(--muted); border-radius: 50%; margin: 0 2px; animation: blink 1.2s infinite both; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.2;transform:translateY(0)} 40%{opacity:1;transform:translateY(-3px)} }

.composer { padding: 14px 22px 18px; background: #fff; border-top: 1px solid var(--line); }
.composer .box { display: flex; align-items: flex-end; gap: 10px; background: var(--soft-2); border: 1.5px solid var(--line); border-radius: 16px; padding: 6px 8px 6px 14px; }
.composer textarea { flex: 1; border: none; background: none; resize: none; font-family: inherit; font-size: 15px; padding: 9px 0; max-height: 120px; }
.composer textarea:focus { outline: none; }
.send-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--grad); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; transition: .15s; }
.send-btn:hover { filter: brightness(1.06); }
.quick-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.quick-row::-webkit-scrollbar { height: 5px; }
.quick-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.quick { flex: none; white-space: nowrap; background: var(--soft); color: var(--brand-2); border: none; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: .12s; }
.quick:hover { background: #e9e6ff; }

/* Multimedia del modelo */
.media-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.media-row::-webkit-scrollbar { height: 5px; }
.media-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.media-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink); transition: .12s; white-space: nowrap; }
.media-btn:hover { border-color: var(--brand); color: var(--brand); }
.media-btn b { color: var(--ok); font-weight: 700; }
.attach-btn { border: none; background: none; cursor: pointer; color: var(--muted); padding: 8px; border-radius: 10px; flex: none; }
.attach-btn:hover { color: var(--brand); background: var(--soft); }

/* Burbuja de multimedia enviada */
.msg.media { padding: 8px; }
.media-card { width: 190px; border-radius: 12px; overflow: hidden; }
.media-thumb { height: 120px; display: grid; place-items: center; font-size: 40px; position: relative; }
.media-thumb .lock { position: absolute; inset: 0; background: rgba(15,23,41,.55); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; text-align: center; padding: 10px; backdrop-filter: blur(3px); transition: .3s; }
.media-thumb .lock.unlocked { opacity: 0; pointer-events: none; }
.media-card .media-cap { padding: 8px 4px 2px; font-size: 12px; }

/* Traducción automática */
.trans-note { font-size: 12px; color: var(--brand-2); background: var(--soft); border-radius: 999px; padding: 3px 10px; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.trans-badge { font-size: 11px; margin-top: 5px; opacity: .85; }
.msg.in .trans-badge { color: var(--brand-2); }
.msg.out .trans-badge { color: rgba(255,255,255,.85); }
.trans-badge.out { color: rgba(255,255,255,.8); }
.see-orig { text-decoration: underline; cursor: pointer; font-weight: 600; }
.see-orig:hover { opacity: .8; }

/* Evento de ganancia dentro del chat */
.earn-event { align-self: center; background: #dcfce7; color: #15803d; font-size: 12.5px; font-weight: 700; padding: 6px 14px; border-radius: 999px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 100; opacity: 0; transition: .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Columna 3: perfil */
.profile { background: #fff; border-left: 1px solid var(--line); padding: 26px 22px; overflow-y: auto; min-height: 0; }
.profile .big-avatar { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 30px; }
.profile .p-name { text-align: center; font-weight: 700; font-size: 19px; }
.profile .p-loc { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.p-section { margin-top: 22px; }
.p-section h5 { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.p-item { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--soft); font-size: 14px; }
.p-item span:first-child { color: var(--muted); }
.p-item span:last-child { font-weight: 600; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--soft); color: var(--brand-2); font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; }

/* Menú de actividad (estilo TalkyTimes "My Activity") */
.activity-menu { display: flex; flex-direction: column; gap: 2px; }
.act-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: none; border: none; font-family: inherit; font-size: 14px; color: var(--ink); padding: 10px 10px; border-radius: 10px; cursor: pointer; transition: .12s; }
.act-row:hover { background: var(--soft); color: var(--brand); }
.act-row .act-count { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
.act-row .act-badge { font-size: 10px; font-weight: 700; color: var(--muted); background: var(--soft); padding: 2px 7px; border-radius: 6px; }

/* Rompehielos + pie del composer */
.ice-btn { flex: none; background: var(--soft); color: var(--brand-2); border: none; border-radius: 12px; padding: 9px 12px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; transition: .12s; }
.ice-btn:hover { background: #e9e6ff; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding: 0 4px; }
.enter-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.enter-toggle input { accent-color: var(--brand); }
.char-count { font-size: 12px; color: var(--muted); }

.empty-chat { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty-chat svg { width: 70px; height: 70px; color: var(--line); margin-bottom: 16px; }

/* Responsive app */
@media (max-width: 1080px) { .app { grid-template-columns: 300px 1fr; } .profile { display: none; } }
@media (max-width: 720px)  {
  .app { grid-template-columns: 1fr; }
  .app.viewing .side { display: none; }
  .app:not(.viewing) .chat, .app:not(.viewing) .profile { display: none; }
  .msg { max-width: 82%; }
}
