/* ================================================
   ResiliencIA - Main CSS v2
   Fuente: Poppins (Google Fonts)
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --green-dark:   #0d4a28;
  --green-main:   #155d36;
  --green-mid:    #1a7040;
  --green-accent: #3cb54a;
  --green-light:  #5bc96a;
  --teal:         #00bfa5;
  --blue:         #1976d2;
  --white:        #ffffff;
  --bg-overlay:   rgba(8, 40, 18, 0.72);
  --sidebar-w:    320px;
  --radius:       14px;
  --shadow:       0 8px 32px rgba(0,0,0,0.25);
}

html, body {
  height: 100%;
  font-family: 'Poppins', sans-serif;
  overflow: hidden;
}

/* ── Background ──────────────────────────────────── */
.bg {
  position: fixed;
  inset: 0;
  background: url('/assets/fondo_home.jpg') center/cover no-repeat;
  background-color: #0d2818;
  z-index: -2;
}
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
}

/* ================================================
   AUTH PAGES (login / register)
   ================================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  overflow-y: auto;
}

.auth-card {
  background: var(--white);
  border-radius: 20px;
  padding: 44px 40px;
  width: 480px;
  max-width: 100%;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}
.auth-logo img { height: 80px; object-fit: contain; }
.auth-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green-main);
  margin-top: 8px;
}
.auth-logo .subtitle {
  font-size: 0.85rem;
  color: #555;
  text-align: center;
  margin-top: 4px;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green-main);
  margin: 20px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.section-title.teal { color: var(--teal); }

.form-field {
  margin-bottom: 14px;
}
.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 5px;
}
.form-field input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Poppins', sans-serif;
  color: #333;
  transition: border-color 0.2s;
  outline: none;
}
.form-field input:focus {
  border-color: var(--green-mid);
}
.form-field input::placeholder { color: #aaa; }

.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 8px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-green { background: var(--green-accent); color: var(--white); }
.btn-green:hover:not(:disabled) { background: var(--green-light); }
.btn-blue  { background: var(--blue); color: var(--white); }
.btn-blue:hover:not(:disabled)  { background: #2196f3; }

.auth-error {
  background: #ffeaea;
  border: 1px solid #f44336;
  color: #c62828;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.83rem;
  margin-bottom: 12px;
  display: none;
}
.auth-error.show { display: block; }

.auth-link {
  text-align: center;
  margin-top: 16px;
  font-size: 0.82rem;
  color: #666;
}
.auth-link a { color: var(--green-mid); font-weight: 600; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ================================================
   CHAT PAGE
   ================================================ */
.chat-page {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: 100vh;
  overflow: hidden;
}

/* ── Left panel ─────────────────────────────────── */
.chat-main {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Left icon bar */
.left-icons {
  position: absolute;
  left: 18px;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}
.left-icon-btn {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--white);
}
.left-icon-btn:hover { background: rgba(255,255,255,0.25); }
.left-icon-btn svg { width: 18px; height: 18px; }

/* ── Welcome state ──────────────────────────────── */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 60px 20px;
  text-align: center;
}
.chat-welcome h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1.15;
  margin-bottom: 12px;
}
.chat-welcome h1 .accent { color: var(--green-light); }
.chat-welcome .subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.82);
  margin-bottom: 32px;
}

/* Suggestion chips */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.suggestion-chip {
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}
.suggestion-chip:hover { background: rgba(255,255,255,0.22); }

/* ── Conversation area ──────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 64px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }

/* Message bubbles */
.msg {
  max-width: 75%;
  animation: fadeUp 0.25s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  background: var(--green-main);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.msg-ai {
  align-self: flex-start;
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
  padding: 16px 20px;
  border-radius: 18px 18px 18px 4px;
  font-size: 0.88rem;
  line-height: 1.65;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.msg-ai h2, .msg-ai h3 { color: var(--green-main); margin: 10px 0 4px; }
.msg-ai ul, .msg-ai ol { padding-left: 20px; margin: 6px 0; }
.msg-ai li { margin-bottom: 4px; }
.msg-ai strong { color: var(--green-dark); }
.msg-ai a { color: var(--green-mid); }
.msg-ai code {
  background: #f0f4f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
}
.msg-ai pre {
  background: #f0f4f0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

/* Typing indicator */
.msg-typing {
  align-self: flex-start;
  background: rgba(255,255,255,0.9);
  padding: 14px 18px;
  border-radius: 18px 18px 18px 4px;
}
.typing-dots { display: flex; gap: 5px; align-items: center; }
.typing-dots span {
  width: 8px; height: 8px;
  background: var(--green-mid);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Input area ─────────────────────────────────── */
.chat-input-area {
  padding: 16px 64px 20px;
}
.input-box {
  background: rgba(13, 60, 30, 0.82);
  border: 1.5px solid rgba(60, 181, 74, 0.3);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(8px);
}
.input-box textarea {
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: 'Poppins', sans-serif;
  font-size: 0.92rem;
  resize: none;
  min-height: 52px;
  max-height: 140px;
  line-height: 1.5;
}
.input-box textarea::placeholder { color: rgba(255,255,255,0.5); }

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.input-left-actions { display: flex; gap: 8px; }
.input-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  transition: background 0.2s;
}
.input-btn:hover { background: rgba(255,255,255,0.2); }
.input-btn svg { width: 17px; height: 17px; }

.send-btn {
  background: var(--green-accent);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 9px 22px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex; align-items: center; gap: 6px;
}
.send-btn:hover { background: var(--green-light); }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

/* ── Ticker bar ─────────────────────────────────── */
.ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: var(--sidebar-w);
  background: rgba(0,0,0,0.6);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20;
  backdrop-filter: blur(4px);
}
.ticker-bar svg { width: 20px; height: 20px; color: #25d366; flex-shrink: 0; }
.ticker-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
}

/* ── Right Sidebar ───────────────────────────────── */
.chat-sidebar {
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 24px;
  overflow-y: auto;
  border-left: 1px solid rgba(0,0,0,0.06);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}
.sidebar-logo img { height: 64px; object-fit: contain; }
.sidebar-logo h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green-accent);
  margin-top: 6px;
}

.sidebar-nav {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--green-main);
  color: var(--white);
  border-radius: 12px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
  font-family: 'Poppins', sans-serif;
  width: 100%;
  text-align: left;
}
.nav-btn:hover { background: var(--green-mid); }
.nav-btn .nav-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-btn .nav-icon svg { width: 18px; height: 18px; }

/* Frog mascot */
.sidebar-mascot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  margin-bottom: 16px;
}
.thought-bubble {
  background: var(--white);
  border: 1.5px solid #ddd;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.75rem;
  color: #444;
  text-align: center;
  max-width: 220px;
  line-height: 1.4;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  animation: fadeIn 0.5s ease;
  position: relative;
}
.thought-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #ddd;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.frog-img {
  height: 100px;
  object-fit: contain;
  animation: frogBounce 3s ease-in-out infinite;
}
@keyframes frogBounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* Social icons */
.sidebar-social {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.social-btn {
  width: 34px; height: 34px;
  background: #eee;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  color: #555;
  border: none;
}
.social-btn:hover { background: #ddd; }
.social-btn svg { width: 16px; height: 16px; }
.social-btn.whatsapp { background: #25d366; color: var(--white); }
.social-btn.whatsapp:hover { background: #20bc5a; }

/* ── New chat button in sidebar ─────────────────── */
.new-chat-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1.5px solid var(--green-accent);
  border-radius: 10px;
  color: var(--green-accent);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  margin-bottom: 16px;
  transition: background 0.2s, color 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.new-chat-btn:hover {
  background: var(--green-accent);
  color: var(--white);
}
.new-chat-btn svg { width: 15px; height: 15px; }

/* User info bar */
.user-info {
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  margin-bottom: 12px;
}
.user-info strong { color: var(--green-main); }

.logout-link {
  font-size: 0.75rem;
  color: #999;
  cursor: pointer;
  text-decoration: underline;
  border: none;
  background: none;
  font-family: 'Poppins', sans-serif;
}
.logout-link:hover { color: #c62828; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .chat-page {
    grid-template-columns: 1fr;
  }
  .chat-sidebar { display: none; }
  .ticker-bar { right: 0; }

  .chat-welcome h1 { font-size: 1.9rem; }
  .chat-welcome { padding: 30px 24px 20px; }
  .chat-messages { padding: 16px 20px; }
  .chat-input-area { padding: 12px 20px 50px; }
  .left-icons { left: 10px; bottom: 70px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 30px 22px; }
  .auth-logo h1 { font-size: 1.7rem; }
  .chat-welcome h1 { font-size: 1.5rem; }
  .suggestions { gap: 7px; }
  .suggestion-chip { font-size: 0.73rem; padding: 6px 12px; }
}
