/* =============================================================================
   VARIABLES Y RESET
   ============================================================================= */
:root {
  /* Paleta marítima moderna */
  --primary-color: #0ea5e9; /* Azul océano */
  --primary-dark: #0284c7;
  --secondary-color: #06b6d4; /* Cyan marino */
  --accent-color: #f59e0b; /* Dorado/ámbar */
  --background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --user-bubble: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  --bot-bubble: #f1f5f9;
  --border: #e2e8f0;
  --shadow: rgba(15, 23, 42, 0.08);
  --shadow-lg: rgba(15, 23, 42, 0.15);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --quick-actions-height: 60px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Fondo con imagen del puerto */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #1a1a2e; /* Fallback color while image loads */
  background-image: var(--bg-image, url('https://i.imgur.com/93PeVLa.jpg'));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: -2;
  animation: fadeInBackground 1s ease-in;
  transition: background-image 0.8s ease-in-out;
}

/* Overlay semi-transparente */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: -1;
}

@keyframes fadeInBackground {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =============================================================================
   HEADER
   ============================================================================= */
.chat-header {
  background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  color: white;
  padding: 1.25rem 1rem;
  box-shadow: 0 4px 16px var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
  gap: 1rem;
}

.header-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.header-title p {
  font-size: 0.75rem;
  opacity: 0.9;
  margin: 0;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: white;
}

/* =============================================================================
   CHAT CONTAINER
   ============================================================================= */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 150px; /* Espacio para input area + quick actions */
  position: relative;
  z-index: 1;
  margin-bottom: 0;
}

.chat-container::-webkit-scrollbar {
  width: 10px;
}

.chat-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin: 4px 4px 150px 4px; /* Bottom margin para no solapar con input area */
}

.chat-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #5a6678 0%, #3d4758 100%);
}

.chat-container::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #6a7688 0%, #4d5768 100%);
}

/* Scrollbar para Firefox */
.chat-container {
  scrollbar-width: thin;
  scrollbar-color: #4a5568 rgba(255, 255, 255, 0.05);
}

/* =============================================================================
   WELCOME CARD
   ============================================================================= */
.welcome-card {
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
  animation: fadeInUp 0.6s ease;
  border: none;
}

.welcome-header {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.port-image {
  width: 100%;
  height: 100%;
}

.port-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.7);
}

.welcome-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  color: white;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.welcome-overlay h2 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.welcome-overlay h2 span {
  color: #fbbf24;
  font-weight: 700;
}

.subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.welcome-content {
  padding: 2rem 1.5rem;
  text-align: center;
}

.welcome-content > p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.capabilities-list {
  list-style: none;
  text-align: left;
  max-width: 320px;
  margin: 1.5rem auto;
}

.capabilities-list li {
  padding: 0.5rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tip {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.tip strong {
  color: var(--primary-color);
}

.examples-section {
  text-align: left;
  margin: 1.5rem 0;
}

.examples-section h4 {
  font-size: 0.9rem;
  color: var(--primary-color);
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
}

.examples-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 0.5rem 0;
}

.examples-list li {
  padding: 0.4rem 0.8rem;
  margin: 0.3rem 0;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #334155;
  border-left: 3px solid var(--primary-color);
  cursor: pointer;
  transition: all 0.2s;
}

.examples-list li:hover {
  background: #e0f2fe;
  transform: translateX(4px);
  color: #0f172a;
}

/* Títulos de sección dentro de examples-list */
.examples-list li.section-title {
  background: transparent;
  border-left: none;
  cursor: default;
  padding: 0.6rem 0 0.2rem 0;
  margin-top: 0.8rem;
  margin-bottom: 0.2rem;
  pointer-events: none;
  font-size: 0.9rem;
  color: #64748b;
}

.examples-list li.section-title:hover {
  background: transparent;
  transform: none;
  color: #64748b;
}

.tip-new {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  padding: 0.875rem 1rem;
  border-radius: 10px;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: center;
  border: 1px solid #fed7aa;
}

.tip-new strong {
  color: var(--accent-color);
}

/* =============================================================================
   MESSAGES
   ============================================================================= */
#messages-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: fadeInUp 0.4s ease;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.message.bot .message-avatar {
  background: linear-gradient(135deg, #0066ff 0%, #00d4ff 100%);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.message-content {
  max-width: 75%;
}

.message-bubble {
  padding: 0.875rem 1.125rem;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.bot .message-bubble {
  background: #ffffff;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
  border: none;
}

.message-time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 0.25rem;
  padding: 0 0.5rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.message.user .message-time {
  text-align: right;
}

/* Quick data cards within messages */
.data-card {
  background: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.data-card h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.data-card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.data-item {
  text-align: center;
}

.data-item .value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.data-item .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Action buttons in messages */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.action-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.action-btn.secondary {
  background: var(--bot-bubble);
  color: var(--text-primary);
}

.action-btn.secondary:hover {
  background: var(--border);
}

/* =============================================================================
   INPUT AREA
   ============================================================================= */
.input-area {
  position: fixed;
  bottom: var(--quick-actions-height); /* Espacio para quick actions */
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  z-index: 50;
}

.input-container {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.voice-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.voice-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.voice-btn.active {
  background: var(--error);
  animation: pulse 1.5s infinite;
}

.voice-btn svg {
  width: 24px;
  height: 24px;
}

#message-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 0.875rem 1.125rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  transition: all 0.3s ease;
  background: var(--background);
}

#message-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: white;
}

#message-input::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

/* Voice Indicator */
.voice-indicator {
  text-align: center;
  padding: 0.5rem 0;
  animation: fadeIn 0.3s ease;
}

.voice-indicator.hidden {
  display: none;
}

.voice-indicator p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.voice-animation {
  display: flex;
  justify-content: center;
  gap: 4px;
  height: 30px;
  align-items: center;
}

.voice-animation span {
  width: 4px;
  background: var(--primary-color);
  border-radius: 2px;
  animation: soundWave 1s ease-in-out infinite;
}

.voice-animation span:nth-child(1) { animation-delay: 0s; }
.voice-animation span:nth-child(2) { animation-delay: 0.1s; }
.voice-animation span:nth-child(3) { animation-delay: 0.2s; }
.voice-animation span:nth-child(4) { animation-delay: 0.3s; }

/* =============================================================================
   QUICK ACTIONS
   ============================================================================= */
.quick-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem;
  min-height: var(--quick-actions-height);
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  z-index: 40;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
  display: none;
}

.chip {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-primary);
  font-weight: 500;
}

.chip:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* =============================================================================
   LOADING & MODALS
   ============================================================================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 1rem;
}

.loading-overlay.hidden {
  display: none;
}

.loading-overlay p {
  color: white;
  font-size: 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.3s ease;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: var(--background);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.setting-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.setting-item select,
.setting-item input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  background: var(--background);
}

.setting-item select:focus,
.setting-item input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

@keyframes soundWave {
  0%, 100% {
    height: 8px;
  }
  50% {
    height: 24px;
  }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 480px) {
  :root {
    --quick-actions-height: 55px;
  }

  .chat-header {
    padding: 0.75rem;
  }

  .header-title h1 {
    font-size: 1.1rem;
  }

  .welcome-card {
    padding: 1.5rem 1rem;
  }

  .message-bubble {
    font-size: 0.85rem;
  }

  .input-area {
    padding: 0.75rem;
    bottom: var(--quick-actions-height);
  }

  .chat-container {
    padding-bottom: 150px; /* Más espacio para input + quick actions en móvil */
  }

  .quick-actions {
    padding: 0.5rem;
  }

  .chip {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
}
