/* Misma paleta y tipografía que chat.css (mismos valores hex, para que
   Bitácora, login y registro se vean como una sola app junto con el chat). */
:root {
  --wa-header: #2f4a3e; /* verde bosque, era el teal de WhatsApp */
  --wa-header-dark: #22362d;
  --wa-bg: #f6f0e4; /* crema cálido, era blanco puro */
  --wa-out: #dde6d3; /* tinte salvia suave, era verde WhatsApp claro */
  --wa-in: #ede3ce; /* crema más profundo, era gris frío */
  --wa-accent: #2f4a3e; /* mismo verde bosque que el header */
  --wa-text: #2e2a22; /* tinta cálida, era casi negro frío */
  --wa-subtext: #7a6e58; /* marrón apagado, era gris frío */
  --wa-border: #ddd0b0; /* línea cálida, era gris frío */
  --wa-error: #8c3b2e; /* tono tierra, no rojo puro */
  --wa-error-bg: #f3e2da;

  --font-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino,
    'Noto Serif', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-serif);
  /* Fondo de página con imagen: solo se ve donde el body queda "desnudo"
     (Bitácora). En login/registro, .auth-body (más específico) lo pisa con
     su propio color, así que esta imagen no aparece ahí. */
  background: var(--wa-in) url('images/page-background.png') center / cover no-repeat fixed;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

@media (min-width: 540px) {
  .phone {
    height: 90vh;
    margin: 5vh 0;
    border-radius: 12px;
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--wa-header);
  color: var(--wa-bg);
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-in);
  color: var(--wa-header);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  font-family: var(--font-sans);
  font-size: 12px;
  color: rgba(246, 240, 228, 0.72);
}

.header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--wa-bg);
  font-family: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-btn:hover {
  opacity: 1;
}

/* Toolbar lateral: solo existe (y solo tiene sentido) cuando la tarjeta deja
   espacio vacío a los costados. En mobile no hay ese espacio, así que se
   oculta y los mismos botones aparecen dentro del header en su lugar. */
.side-actions {
  display: none;
}

@media (min-width: 800px) {
  .side-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: fixed;
    top: 50%;
    right: max(24px, calc((100vw - 480px) / 2 - 68px));
    transform: translateY(-50%);
  }

  .side-actions .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--wa-header);
    color: var(--wa-bg);
    opacity: 1;
    box-shadow: 0 2px 10px rgba(46, 42, 34, 0.18);
  }

  .side-actions .icon-btn:hover {
    background: var(--wa-header-dark);
  }

  .header-only,
  .chat-header .header-actions {
    display: none;
  }
}

/* Chat body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 8%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: var(--wa-bg);
}

.bubble-row {
  display: flex;
}

.bubble-row.out {
  justify-content: flex-end;
}

.bubble-row.in {
  justify-content: flex-start;
}

.bubble {
  max-width: 78%;
  padding: 7px 9px 8px 10px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bubble.out {
  background: var(--wa-out);
  color: var(--wa-text);
  border-top-right-radius: 0;
}

.bubble.in {
  background: var(--wa-in);
  color: var(--wa-text);
  border-top-left-radius: 0;
}

.bubble .time {
  display: block;
  text-align: right;
  font-size: 10.5px;
  color: var(--wa-subtext);
  margin-top: 2px;
}

.typing .bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wa-subtext);
  opacity: 0.6;
  animation: blink 1.2s infinite ease-in-out;
}

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

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Footer */
.chat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--wa-bg);
  border-top: 1px solid var(--wa-border);
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14.5px;
  background: var(--wa-in);
  color: var(--wa-text);
}

#messageInput::placeholder {
  color: var(--wa-subtext);
}

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--wa-accent);
  color: var(--wa-bg);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: default;
}

.error-banner {
  background: var(--wa-error-bg);
  color: var(--wa-error);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 6px;
  align-self: center;
  max-width: 90%;
  text-align: center;
}

/* Auth pages (login / register) */
.auth-body {
  background: var(--wa-in);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 16px;
  font-family: var(--font-serif);
}

/* En mobile es solo la tarjeta (mismo layout de siempre); la imagen se
   suma como columna izquierda a partir del breakpoint de escritorio. */
.auth-split {
  display: flex;
  width: 100%;
  max-width: 900px;
  align-items: stretch;
  justify-content: center;
}

.auth-hero {
  display: none;
}

.auth-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-card {
  background: var(--wa-bg);
  width: 100%;
  max-width: 360px;
  padding: 32px 28px;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  text-align: center;
  margin: 16px;
}

/* Aviso de Privacidad: prosa corrida, se lee mejor alineada a la izquierda
   que centrada como el resto de las tarjetas de auth. */
.auth-card--text {
  text-align: left;
}

.auth-card--text h1 {
  text-align: center;
  font-size: 19px;
}

.auth-card--text p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--wa-text);
}

.auth-card--text .auth-switch {
  text-align: center;
}

.auth-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--wa-header);
  color: var(--wa-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  margin: 0 auto 12px;
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--wa-text);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--wa-subtext);
  margin: 0 0 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 4px;
}

.auth-form label {
  font-size: 12.5px;
  color: var(--wa-subtext);
  margin-top: 10px;
}

.auth-form input {
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  color: var(--wa-text);
  background: var(--wa-bg);
}

.auth-form input:focus {
  border-color: var(--wa-accent);
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 0;
  font-size: 12.5px;
  color: var(--wa-subtext);
  cursor: pointer;
  min-height: 44px;
  box-sizing: border-box;
}

.auth-checkbox input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--wa-accent);
}

.auth-checkbox a {
  color: var(--wa-header);
  font-weight: 600;
  text-decoration: none;
}

.auth-checkbox a:hover {
  text-decoration: underline;
}

.auth-error {
  color: var(--wa-error);
  font-size: 12.5px;
  min-height: 16px;
  margin-top: 8px;
}

.auth-form button {
  margin-top: 16px;
  background: var(--wa-accent);
  color: var(--wa-bg);
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--wa-subtext);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--wa-border);
}

.auth-google-btn {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 10px;
  min-height: 44px;
  background: var(--wa-bg);
  color: var(--wa-text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}

.auth-google-btn:hover {
  border-color: var(--wa-accent);
}

.auth-switch {
  margin-top: 18px;
  font-size: 13px;
  color: var(--wa-subtext);
}

.auth-switch a {
  color: var(--wa-header);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-footer-link {
  margin-top: 10px;
  font-size: 11.5px;
}

.auth-footer-link a {
  color: var(--wa-subtext);
  text-decoration: underline;
}

/* Desktop: imagen a la izquierda, formulario a la derecha, como una sola
   tarjeta partida al medio. */
@media (min-width: 800px) {
  .auth-split {
    min-height: 620px;
    border-radius: 16px;
    box-shadow: 0 4px 32px rgba(46, 42, 34, 0.12);
    overflow: hidden;
  }

  .auth-hero {
    display: block;
    flex: 1 1 46%;
  }

  .auth-card {
    flex: 1 1 54%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Bitácora */
.bitacora-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--wa-in);
}

.bitacora-card {
  background: var(--wa-bg);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.bitacora-card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--wa-text);
  margin: 0 0 12px;
}

.bitacora-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bitacora-form label {
  font-size: 12.5px;
  color: var(--wa-subtext);
  margin-top: 10px;
}

.bitacora-form input[type='date'],
.bitacora-form input[type='text'],
.bitacora-form select,
.bitacora-form textarea {
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--wa-text);
  background: var(--wa-bg);
  width: 100%;
}

.bitacora-form input:focus,
.bitacora-form select:focus,
.bitacora-form textarea:focus {
  border-color: var(--wa-accent);
}

.bitacora-form textarea {
  resize: vertical;
}

.bitacora-form button {
  margin-top: 16px;
  background: var(--wa-accent);
  color: var(--wa-bg);
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.bitacora-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.toggle-group {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.toggle-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 9px;
  font-size: 14px;
  color: var(--wa-text);
  cursor: pointer;
  user-select: none;
}

.toggle-option input {
  display: none;
}

.toggle-option.checked,
.toggle-option:has(input:checked) {
  background: var(--wa-out);
  border-color: var(--wa-accent);
  font-weight: 600;
}

.streak-box {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--wa-out);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.streak-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--wa-header);
  line-height: 1;
}

.streak-label {
  font-size: 13px;
  color: var(--wa-text);
}

.pattern-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pattern-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pattern-row-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--wa-text);
}

.pattern-row-label .count {
  color: var(--wa-subtext);
  font-weight: 600;
  flex-shrink: 0;
}

.pattern-bar-track {
  background: var(--wa-in);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}

.pattern-bar-fill {
  background: var(--wa-accent);
  height: 100%;
  border-radius: 6px;
}

.pattern-empty,
.entry-empty {
  font-size: 13px;
  color: var(--wa-subtext);
  text-align: center;
  padding: 12px 0;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-item {
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 10px 12px;
}

.entry-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.entry-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--wa-text);
  flex-shrink: 0;
}

.entry-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  flex: 1;
  text-align: center;
}

.entry-badge.yes {
  background: var(--wa-out);
  color: var(--wa-header);
}

.entry-badge.no {
  background: var(--wa-error-bg);
  color: var(--wa-error);
}

.entry-delete {
  background: none;
  border: none;
  color: var(--wa-subtext);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
}

.entry-delete:hover {
  color: var(--wa-error);
}

.entry-pattern {
  font-size: 13px;
  color: var(--wa-header);
  font-weight: 600;
  margin-top: 6px;
}

.entry-note {
  font-size: 13px;
  color: var(--wa-subtext);
  margin-top: 4px;
  white-space: pre-wrap;
}
