/* ─── 1) Global & splash-screen centering ──────────────────────────────── */
* { 
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  color: #2d3436;
}

/* ─── 2) Simulation-selection UI ───────────────────────────────────────── */
#selection-container {
  text-align: center;
  width: 100%;
  max-width: 1200px;
  animation: fadeIn 0.8s ease-out;
  padding: 20px 0;
}

#selection-container h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #1a3a5a;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.subtitle {
  font-size: 1.05rem;
  color: #636e72;
  margin-bottom: 35px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.simulation-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns for desktop */
  gap: 20px;
  padding: 10px;
}

.simulation-logo {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px); /* Glassmorphism effect */
  padding: 25px 15px;
  border-radius: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  height: 210px;
  opacity: 0; /* For staggered fade-in */
  animation: slideUp 0.6s ease-out forwards;
}

/* Staggered load animation */
.simulation-logo:nth-child(1) { animation-delay: 0.1s; }
.simulation-logo:nth-child(2) { animation-delay: 0.2s; }
.simulation-logo:nth-child(3) { animation-delay: 0.3s; }
.simulation-logo:nth-child(4) { animation-delay: 0.4s; }
.simulation-logo:nth-child(5) { animation-delay: 0.5s; }
.simulation-logo:nth-child(6) { animation-delay: 0.6s; }
.simulation-logo:nth-child(7) { animation-delay: 0.7s; }

.simulation-logo::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  transition: none;
}

@media (hover:hover) {
  .simulation-logo:hover {
    transform: translateY(-10px);
    background: #ffffff;
    box-shadow: 0 15px 35px rgba(80, 148, 218, 0.15), 0 0 15px rgba(80, 148, 218, 0.1); /* Subtle blue glow */
    border-color: rgba(80, 148, 218, 0.4);
  }
  
  .simulation-logo:hover::after {
    animation: shine 0.8s ease-in-out;
  }
}

.simulation-logo img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: contain;
  margin-bottom: 15px;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.08));
  background: #fff;
  padding: 4px;
  border: 3px solid #f8f9fa;
  transition: transform 0.5s ease;
}

.simulation-logo:hover img {
  transform: scale(1.05) rotate(2deg);
}

.simulation-logo p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1a3a5a;
  line-height: 1.2;
}

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

@keyframes shine {
  100% { left: 150%; }
}

/* ─── Responsive tweaks ───────────────────────────────────────────── */
@media (max-width: 1000px) {
  .simulation-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .simulation-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  #selection-container h1 { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .simulation-grid {
    grid-template-columns: 1fr;
  }
  .simulation-logo { height: auto; padding: 20px; }
}

/* ─── 3) Hide chat by default ──────────────────────────────────────────── */
#chat-container {
  display: none;
  width: 100%;
  max-width: 800px;
  background-color: #fff;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
  overflow: hidden;
}

body.chat-active {
  display: block;
  margin: 0;
  padding: 0;
}

body.chat-active #chat-container {
  display: flex !important;
  flex-direction: column;
  height: 100vh !important;
  width: 100% !important;
  margin: 0 auto !important;
}

/* ─── Chat Header ──────────────────────────────────────────────────────── */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  z-index: 10;
}

#active-sim-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#header-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: contain;
  background: #f8f9fa;
  padding: 2px;
  border: 1px solid #eee;
}

#header-sim-name {
  font-weight: 700;
  color: #1a3a5a;
  font-size: 1rem;
}

.header-btn {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #636e72;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-btn:hover {
  background: #edf2f7;
  color: #1a3a5a;
  border-color: #ced4da;
}

/* ─── 5) Conversation & input styling ──────────────────────────────────── */
#conversation {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.suggestion-container {
  margin: auto;
  text-align: center;
  max-width: 500px;
  animation: fadeIn 0.8s ease-out;
}

.suggestion-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #a0aec0;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.chip {
  padding: 15px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d3748;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.chip:hover {
  border-color: #5094da;
  background: #f0f7ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(80, 148, 218, 0.12);
  color: #2b6cb0;
}

.chip.special-chip {
  background: #ebf8ff;
  border-color: #bee3f8;
  color: #2b6cb0;
  grid-column: span 2; /* Full width to stand out */
}

.chip.special-chip:hover {
  background: #bee3f8;
  border-color: #5094da;
}

#input-container {
  flex-shrink: 0;
  display: flex;
  padding: 15px 20px;
  background: #ffffff;
  border-top: 1px solid #edf2f7;
  gap: 12px;
  align-items: center;
}

#upload-btn {
  background: #ebf8ff;
  border: 2px solid #5094da;
  padding: 10px;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  animation: pulse-blue 2s infinite; /* Attention grabber */
}

#upload-btn:hover {
  background: #5094da;
  color: #fff;
  transform: scale(1.1);
  animation: none;
}

@keyframes pulse-blue {
  0% { box-shadow: 0 0 0 0 rgba(80, 148, 218, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(80, 148, 218, 0); }
  100% { box-shadow: 0 0 0 0 rgba(80, 148, 218, 0); }
}

#question-input {
  flex-grow: 1;
  padding: 12px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  outline: none;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
#question-input:focus { border-color: #5094da; }

#ask-button {
  padding: 0 25px;
  background-color: #5094da;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}
#ask-button:hover { background-color: #3182ce; }

/* ─── 6) Bubbles ─── */
.bubble p { margin: 0; }
.bubble {
  display: block;
  clear: both;
  line-height: 1.6;
  max-width: 85%;
  margin: 0.8rem 0;
  padding: 1rem 1.2rem;
  border-radius: 18px;
  word-wrap: break-word;
  font-size: 0.95rem;
  animation: fadeIn 0.3s ease-out;
}

/* Modern Thinking Animation */
.thinking-bubble {
  display: flex;
  gap: 4px;
  padding: 12px 18px;
  background: #f7fafc;
  border-radius: 18px;
  width: fit-content;
  border: 1px solid #edf2f7;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  background: #cbd5e0;
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.bubble.user {
  white-space: pre-wrap;
  background-color: #ebf8ff;
  color: #2c5282;
  margin-left: auto; /* User on right is standard best practice */
  margin-right: 0;
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  position: relative;
  background-color: #f7fafc;
  color: #2d3748;
  margin-left: 0;
  margin-right: auto;
  padding-left: 3.5rem;
  border-bottom-left-radius: 4px;
  border: 1px solid #edf2f7;
}

.bubble.assistant .avatar {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.copy-btn {
  margin-top: 10px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #718096;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.copy-btn:hover { background: #edf2f7; color: #2d3748; }

.loading-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(to right, #e0f7fa, #5094da, #387bbf, #234667);
  background-size: 200% 100%;
  animation: loading 4s ease-in-out infinite;
}

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

@keyframes loading {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
