/* Copland OS - Serial Experiments Lain Interface */
/* Tachibana General Laboratories */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&family=Share+Tech+Mono&display=swap');

:root {
  --bg-deep: #0a0a1a;
  --bg-primary: #0d1525;
  --bg-panel: rgba(20, 40, 80, 0.6);
  --bg-window: rgba(30, 60, 120, 0.4);
  --border-glow: rgba(100, 160, 255, 0.5);
  --text-primary: #c0d8ff;
  --text-secondary: #6090c0;
  --text-dim: #405880;
  --accent-blue: #4080ff;
  --accent-light: #80c0ff;
  --accent-cyan: #40e0ff;
  --hologram: linear-gradient(135deg, rgba(64, 128, 255, 0.1), rgba(128, 192, 255, 0.05), rgba(64, 200, 255, 0.1));
  --glow-blue: 0 0 20px rgba(64, 128, 255, 0.4), 0 0 40px rgba(64, 128, 255, 0.2);
  --font-system: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-mono);
  background: var(--bg-deep);
  color: var(--text-primary);
  position: relative;
}

/* Animated background grid */
.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(64, 128, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 128, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: gridMove 20s linear infinite;
  z-index: 0;
}

@keyframes gridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

/* Floating particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-light);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 15s infinite ease-in-out;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 18s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 14s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1s; animation-duration: 16s; }
.particle:nth-child(5) { left: 50%; animation-delay: 3s; animation-duration: 20s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; animation-duration: 13s; }
.particle:nth-child(7) { left: 70%; animation-delay: 2s; animation-duration: 17s; }
.particle:nth-child(8) { left: 80%; animation-delay: 4s; animation-duration: 15s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1s; animation-duration: 19s; }

@keyframes float {
  0%, 100% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.4;
    transform: translateY(90vh) scale(1);
  }
  90% {
    opacity: 0.4;
    transform: translateY(10vh) scale(1);
  }
  100% {
    transform: translateY(0) scale(0);
    opacity: 0;
  }
}

/* Holographic scanline overlay */
.holo-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(64, 128, 255, 0.02) 2px,
    rgba(64, 128, 255, 0.02) 4px
  );
  animation: holoShift 8s linear infinite;
}

@keyframes holoShift {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* Main container */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 10;
}

/* Header - Copland OS style */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 25px;
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--glow-blue), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: windowFloat 6s ease-in-out infinite;
}

@keyframes windowFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(64, 128, 255, 0.5);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(64, 128, 255, 0.5); }
  50% { box-shadow: 0 0 30px rgba(64, 128, 255, 0.8), 0 0 50px rgba(64, 200, 255, 0.3); }
}

.logo-icon svg {
  width: 30px;
  height: 30px;
  fill: white;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-family: var(--font-system);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.2em;
  text-shadow: 0 0 10px rgba(128, 192, 255, 0.5);
}

.logo-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  margin-top: 2px;
}

.system-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #40ff80;
  box-shadow: 0 0 10px #40ff80;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-label {
  font-family: var(--font-system);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

/* Main chat window */
.main-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: var(--glow-blue), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
}

/* Window title bar */
.window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(64, 128, 255, 0.2), transparent);
  border-bottom: 1px solid var(--border-glow);
}

.window-title {
  font-family: var(--font-system);
  font-size: 0.8rem;
  color: var(--accent-light);
  letter-spacing: 0.15em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.window-title::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--accent-cyan);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent-cyan);
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s;
}

.window-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: var(--hologram);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(64, 128, 255, 0.1);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 3px;
  box-shadow: 0 0 5px var(--accent-blue);
}

/* Message styles */
.system-message {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(64, 128, 255, 0.05);
}

.system-message .timestamp {
  color: var(--accent-blue);
  font-family: var(--font-system);
  font-size: 0.7rem;
}

.user-message,
.lain-message {
  max-width: 80%;
  padding: 15px 20px;
  border-radius: 12px;
  animation: messageIn 0.4s ease;
  position: relative;
  font-size: 1.05rem;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(40, 80, 140, 0.6), rgba(30, 60, 100, 0.6));
  border: 1px solid rgba(100, 160, 255, 0.3);
}

.user-message .sender {
  color: var(--accent-light);
  font-family: var(--font-system);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 6px;
}

.lain-message {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(64, 128, 255, 0.15), rgba(64, 200, 255, 0.1));
  border: 1px solid rgba(64, 200, 255, 0.3);
  box-shadow: 0 0 20px rgba(64, 200, 255, 0.1);
}

.lain-message .sender {
  color: var(--accent-cyan);
  font-family: var(--font-system);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 6px;
  text-shadow: 0 0 10px var(--accent-cyan);
}

.lain-message .text {
  line-height: 1.7;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 15px 20px;
  background: linear-gradient(135deg, rgba(64, 128, 255, 0.15), rgba(64, 200, 255, 0.1));
  border: 1px solid rgba(64, 200, 255, 0.3);
  border-radius: 12px;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  animation: typingPulse 1.4s infinite;
  box-shadow: 0 0 10px var(--accent-cyan);
}

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

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Streaming cursor animation */
#streaming-text::after {
  content: '▋';
  animation: cursorBlink 0.8s infinite;
  color: var(--accent-cyan);
  margin-left: 2px;
}

@keyframes cursorBlink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* Input area */
.input-area {
  padding: 15px 20px;
  background: linear-gradient(0deg, rgba(64, 128, 255, 0.1), transparent);
  border-top: 1px solid var(--border-glow);
}

.chat-input {
  display: flex;
  gap: 12px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(20, 40, 80, 0.8);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 0 15px;
  transition: all 0.3s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(64, 200, 255, 0.3);
}

.input-icon {
  color: var(--accent-blue);
  margin-right: 10px;
  font-size: 1.1rem;
}

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 12px 0;
  outline: none;
}

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

.send-btn {
  background: linear-gradient(135deg, var(--accent-blue), #3060c0);
  border: none;
  color: white;
  font-family: var(--font-system);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 12px 25px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
  box-shadow: 0 0 15px rgba(64, 128, 255, 0.3);
}

.send-btn:hover {
  background: linear-gradient(135deg, #5090ff, var(--accent-blue));
  box-shadow: 0 0 25px rgba(64, 128, 255, 0.5);
  transform: translateY(-2px);
}

.send-btn:active {
  transform: translateY(0);
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  margin-top: 15px;
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid rgba(64, 128, 255, 0.2);
  border-radius: 8px;
  backdrop-filter: blur(5px);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 5px var(--accent-blue);
}

.footer-right {
  font-family: var(--font-system);
  letter-spacing: 0.15em;
  color: var(--text-secondary);
}

/* Error message */
.error-message {
  background: linear-gradient(135deg, rgba(255, 60, 60, 0.2), rgba(200, 40, 40, 0.1));
  border: 1px solid rgba(255, 100, 100, 0.4);
  color: #ff8080;
  padding: 15px 20px;
  border-radius: 12px;
}

/* Image upload */
.image-btn {
  background: rgba(20, 40, 80, 0.8);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(64, 200, 255, 0.3);
}

.image-preview {
  padding: 10px 20px;
  background: rgba(20, 40, 80, 0.5);
  border-bottom: 1px solid var(--border-glow);
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.image-preview img {
  max-height: 120px;
  max-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--border-glow);
}

.remove-image {
  background: rgba(255, 60, 60, 0.3);
  border: 1px solid rgba(255, 100, 100, 0.4);
  color: #ff8080;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.remove-image:hover {
  background: rgba(255, 60, 60, 0.5);
  box-shadow: 0 0 10px rgba(255, 100, 100, 0.3);
}

/* Image in messages (user uploads) */
.message-image {
  max-width: 300px;
  max-height: 200px;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--border-glow);
}

/* Images in Lain's responses */
.response-image-container {
  margin: 15px 0;
  display: inline-block;
}

.response-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  border: 1px solid var(--border-glow);
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 15px rgba(64, 128, 255, 0.2);
}

.response-image:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 25px rgba(64, 200, 255, 0.4);
  transform: scale(1.02);
}

.response-image.image-error {
  border-color: rgba(255, 100, 100, 0.4);
  padding: 20px;
  font-size: 0.8rem;
  color: #ff8080;
}

.image-caption {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 5px;
  font-style: italic;
  text-align: center;
}

/* Drag and drop overlay */
.drag-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 20, 40, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border: 3px dashed var(--accent-cyan);
}

.drag-overlay-text {
  color: var(--accent-cyan);
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px var(--accent-cyan);
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  .header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .system-status {
    align-items: center;
  }

  .chat-input {
    flex-direction: column;
  }

  .send-btn {
    width: 100%;
    justify-content: center;
  }

  .footer {
    flex-direction: column;
    gap: 10px;
  }
}
