/* ============================================================
   CAPITAN / CAPICO — Premium Marine Chat Interface
   Manual de Identidad: fondo blanco, azul institucional, agua sutil
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  /* Paleta institucional Capitan */
  --blue-deep: #011B6C;
  --blue-logo: #212D65;
  --blue-mid: #3B4570;
  --blue-gray: #565B7B;
  --gray-blue: #727586;
  --silver: #8E9191;
  --off-white: #F7FAFD;
  --border-soft: #EEF2F5;
  --white: #FFFFFF;
  --text-deep: #1E2A44;

  /* Funcionales */
  --bg: #FFFFFF;
  --bg-subtle: #F7FAFD;
  --text: #1E2A44;
  --text-muted: #727586;
  --accent: #011B6C;
  --accent-hover: #021F7A;
  --border: #EEF2F5;
  --shadow-sm: 0 1px 3px rgba(1, 27, 108, 0.06);
  --shadow-md: 0 4px 16px rgba(1, 27, 108, 0.08);
  --shadow-lg: 0 8px 32px rgba(1, 27, 108, 0.12);
  --radius: 16px;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   HEADER — Hero marino premium con olas azul fuerte
   ============================================================ */

.site-header {
  position: relative;
  height: 220px;
  flex-shrink: 0;
  background: #FFFFFF;
  overflow: hidden;
}

/* --- Olas SVG azul fuerte animadas --- */

.wave-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 90px;
  z-index: 2;
  pointer-events: none;
}

.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100%;
}

.wave-1 {
  fill: rgba(1, 27, 108, 0.08);
  animation: waveSlide 9s linear infinite;
}

.wave-2 {
  fill: rgba(1, 27, 108, 0.14);
  animation: waveSlide 7s linear infinite reverse;
  animation-delay: -2s;
}

.wave-3 {
  fill: rgba(1, 27, 108, 0.22);
  animation: waveSlide 11s linear infinite;
  animation-delay: -4s;
}

.wave-4 {
  fill: rgba(1, 27, 108, 0.35);
  animation: waveSlide 5s linear infinite reverse;
  animation-delay: -1s;
}

@keyframes waveSlide {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- Logo con efecto de luz --- */

.header-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding-bottom: 30px;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.logo-shine-container {
  position: relative;
  display: inline-block;
  overflow: hidden;
  border-radius: 8px;
}

.logo-img {
  height: 150px;
  width: auto;
  display: block;
  position: relative;
  z-index: 1;
  cursor: pointer;
}

/* Rayo de luz que recorre el logo */
.logo-shine {
  position: absolute;
  top: -20%;
  left: -100%;
  width: 60%;
  height: 140%;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0) 35%,
    rgba(255, 255, 255, 0.4) 42%,
    rgba(200, 220, 255, 0.6) 48%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(200, 220, 255, 0.6) 52%,
    rgba(255, 255, 255, 0.4) 58%,
    rgba(255, 255, 255, 0) 65%,
    transparent 80%
  );
  z-index: 2;
  pointer-events: none;
  animation: shineSwipe 4s ease-in-out infinite;
  animation-delay: 1s;
  transform: skewX(-15deg);
}

@keyframes shineSwipe {
  0% {
    left: -100%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    left: 180%;
    opacity: 1;
  }
  55% {
    opacity: 0;
  }
  100% {
    left: 180%;
    opacity: 0;
  }
}

/* Segundo destello mas sutil */
.logo-shine-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 30%,
    rgba(255, 255, 255, 0.3) 0%,
    transparent 60%
  );
  opacity: 0;
  animation: glintPulse 4s ease-in-out infinite;
  animation-delay: 2.5s;
}

@keyframes glintPulse {
  0%, 100% { opacity: 0; }
  30% { opacity: 0.6; }
  60% { opacity: 0; }
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0px) scale(1) rotate(0deg);
  }
  25% {
    transform: translateY(-5px) scale(1.015) rotate(0.4deg);
  }
  50% {
    transform: translateY(-9px) scale(1.03) rotate(0deg);
  }
  75% {
    transform: translateY(-5px) scale(1.015) rotate(-0.4deg);
  }
}

@keyframes logoGlow {
  0%, 100% {
    filter:
      drop-shadow(0 4px 12px rgba(1, 27, 108, 0.2))
      drop-shadow(0 0 4px rgba(33, 45, 101, 0.1));
  }
  50% {
    filter:
      drop-shadow(0 6px 20px rgba(1, 27, 108, 0.35))
      drop-shadow(0 0 12px rgba(33, 45, 101, 0.15))
      drop-shadow(0 0 30px rgba(1, 27, 108, 0.08));
  }
}

/* Hover: logo se eleva mas y brilla fuerte */
.logo-shine-container:hover .logo-img {
  animation: logoFloatHover 0.5s ease forwards, logoGlowBurst 0.5s ease forwards;
}

.logo-shine-container:hover .logo-shine {
  animation: shineSwipeHover 0.8s ease-out forwards;
}

@keyframes logoFloatHover {
  to {
    transform: translateY(-14px) scale(1.08);
  }
}

@keyframes logoGlowBurst {
  to {
    filter:
      drop-shadow(0 10px 30px rgba(1, 27, 108, 0.45))
      drop-shadow(0 0 20px rgba(33, 45, 101, 0.25))
      drop-shadow(0 0 50px rgba(1, 27, 108, 0.12));
  }
}

@keyframes shineSwipeHover {
  0% { left: -100%; opacity: 0; }
  20% { opacity: 1; }
  100% { left: 180%; opacity: 0; }
}

/* ============================================================
   MAIN — CHAT
   ============================================================ */

.chat-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================================
   MESSAGES
   ============================================================ */

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar {
  width: 5px;
}
.messages-area::-webkit-scrollbar-track {
  background: transparent;
}
.messages-area::-webkit-scrollbar-thumb {
  background: rgba(1, 27, 108, 0.12);
  border-radius: 3px;
}

/* Message row */
.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeSlideUp 0.35s ease forwards;
  opacity: 0;
}

.message-user {
  flex-direction: row-reverse;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Avatar */
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-logo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(1, 27, 108, 0.2);
}

.message-user .message-avatar {
  background: linear-gradient(135deg, var(--silver), #A0A3A3);
  color: #fff;
  font-size: 0.6rem;
  box-shadow: 0 2px 8px rgba(142, 145, 145, 0.25);
}

/* Bubbles */
.message-bubble {
  max-width: 70%;
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.92rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message-ai .message-bubble {
  background: var(--off-white);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.message-user .message-bubble {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-logo));
  border-top-right-radius: 4px;
  color: #fff;
  box-shadow: 0 2px 12px rgba(1, 27, 108, 0.2);
}

.message-bubble p { margin: 0; }
.message-bubble p + p { margin-top: 8px; }
.message-bubble strong { color: var(--blue-deep); font-weight: 600; }

.message-user .message-bubble strong {
  color: rgba(255, 255, 255, 0.95);
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  animation: fadeSlideUp 0.2s ease forwards;
  opacity: 0;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--off-white);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
  border-top-left-radius: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-deep);
  opacity: 0.3;
  animation: dotBounce 1.2s ease-in-out infinite;
}

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

@keyframes dotBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-7px);
    opacity: 0.8;
  }
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.input-area {
  padding: 12px 0 20px;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.25s, box-shadow 0.25s;
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--blue-deep);
  box-shadow: 0 0 0 3px rgba(1, 27, 108, 0.08), var(--shadow-md);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input::-webkit-scrollbar { width: 4px; }
.chat-input::-webkit-scrollbar-thumb { background: rgba(1, 27, 108, 0.1); border-radius: 2px; }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-logo));
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(1, 27, 108, 0.25);
}

.send-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 16px rgba(1, 27, 108, 0.35);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-hint {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.input-hint kbd {
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.68rem;
  color: var(--blue-gray);
}

/* ============================================================
   FOOTER — Ola invertida + logo Capico
   ============================================================ */

.site-footer {
  position: relative;
  flex-shrink: 0;
  background: linear-gradient(180deg, #E8EDF5 0%, #DDE3EF 100%);
  padding: 28px 20px 18px;
  overflow: hidden;
}

.footer-wave {
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 20px;
  fill: var(--white);
}

.footer-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-logo {
  height: 28px;
  width: auto;
  opacity: 0.7;
  margin-bottom: 4px;
  transition: opacity 0.2s;
}

.footer-logo:hover {
  opacity: 1;
}

.footer-text {
  font-size: 0.72rem;
  color: var(--blue-gray);
}

.footer-powered {
  font-size: 0.66rem;
  color: var(--gray-blue);
  opacity: 0.7;
}

.footer-link {
  color: var(--blue-deep);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.footer-link:hover { opacity: 0.7; }

/* ============================================================
   QUICK OPTIONS — Welcome buttons
   ============================================================ */

.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-btn {
  background: rgba(1, 27, 108, 0.04);
  border: 1px solid rgba(1, 27, 108, 0.15);
  border-radius: 24px;
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.quick-btn:hover {
  background: rgba(1, 27, 108, 0.08);
  border-color: rgba(1, 27, 108, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(1, 27, 108, 0.1);
}

/* ============================================================
   LEAD CAPTURE FORM
   ============================================================ */

.lead-bubble {
  max-width: 88% !important;
}

.lead-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.lead-input {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lead-input:focus {
  border-color: var(--blue-deep);
  box-shadow: 0 0 0 3px rgba(1, 27, 108, 0.06);
}

.lead-input::placeholder {
  color: var(--text-muted);
}

.lead-submit {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue-logo));
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 11px 22px;
  align-self: flex-start;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(1, 27, 108, 0.2);
}

.lead-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(1, 27, 108, 0.3);
}

.lead-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   INPUT FOOTER
   ============================================================ */

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.new-chat-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  padding: 2px 0;
  flex-shrink: 0;
  transition: color 0.2s;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: transparent;
}

.new-chat-btn:hover {
  color: var(--blue-deep);
  text-decoration-color: var(--blue-deep);
}

/* ============================================================
   FAB — Boton flotante
   ============================================================ */

.fab-home {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 10px 16px 10px 12px;
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-md);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.01em;
  transition: box-shadow 0.2s, transform 0.15s;
}

.fab-home:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.fab-home svg {
  flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
  /* Header compacto */
  .site-header { height: 150px; }
  .logo-img { height: 95px; }
  .wave-container { height: 50px; }

  /* Footer oculto */
  .site-footer { display: none; }

  /* Mensajes */
  .messages-area {
    gap: 12px;
    padding: 14px 0 8px;
  }
  .message-bubble {
    max-width: 88%;
    font-size: 0.88rem;
  }

  /* Avatar */
  .message-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    font-size: 0.48rem;
  }
  .message-avatar svg {
    width: 13px;
    height: 13px;
  }

  .chat-container { padding: 0 14px; }

  .chat-input {
    font-size: 16px;
    max-height: 100px;
  }
  .input-hint { display: none; }
  .input-footer { justify-content: flex-end; }

  .input-area {
    padding: 10px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .quick-btn {
    font-size: 0.8rem;
    padding: 8px 14px;
  }

  .lead-bubble { max-width: 95% !important; }
  .lead-input {
    font-size: 16px;
    padding: 12px 14px;
  }
  .lead-submit { padding: 12px 20px; }

  .fab-home {
    bottom: 16px;
    right: 16px;
    padding: 8px 12px 8px 10px;
    font-size: 0.72rem;
  }
}
