/* =============================================================
   AOI - Dark Cyber Anime Interface with Live2D Support
   ============================================================= */

:root {
  --bg-primary: #05080c;
  --bg-secondary: #0a0f14;
  --bg-tertiary: #0f1620;
  --bg-panel: #0c1218;
  
  --cyan-primary: #00d4ff;
  --cyan-dark: #0099cc;
  --cyan-glow: rgba(0, 212, 255, 0.4);
  
  --text-primary: #c8d4dc;
  --text-secondary: #6a7a88;
  --text-muted: #3a4a58;
  
  --border-color: #1a2530;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* =============================================================
   OVERLAY EFFECTS
   ============================================================= */

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Scanline removed */

/* =============================================================
   APP LAYOUT
   ============================================================= */

.app-container {
  display: flex;
  height: 100%;
}

/* =============================================================
   SIDEBAR
   ============================================================= */

.sidebar {
  width: 200px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--cyan-primary), transparent);
  opacity: 0.15;
}

.sidebar-header {
  padding: 25px 20px;
  border-bottom: 1px solid var(--border-color);
}

.logo-container {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo-text {
  font-size: 2.5rem;
  color: var(--cyan-primary);
  text-shadow: 0 0 20px var(--cyan-glow);
  font-family: serif;
}

.logo-sub {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 0.3em;
}

.status-line {
  height: 2px;
  background: linear-gradient(90deg, var(--cyan-primary), transparent);
  margin-top: 12px;
  opacity: 0.4;
}

.nav-menu {
  flex: 1;
  padding: 15px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cyan-primary);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--cyan-primary);
  background: rgba(0, 212, 255, 0.05);
}

.nav-item:hover::before,
.nav-item.active::before {
  transform: scaleY(1);
}

.nav-icon {
  width: 18px;
  height: 18px;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.pulse {
  width: 6px;
  height: 6px;
  background: #00ff88;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

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

/* =============================================================
   MAIN CONTENT - Split View
   ============================================================= */

.main-content {
  flex: 1;
  display: flex;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* =============================================================
   CHARACTER CONTAINER - Live2D Area
   ============================================================= */

.character-container {
  width: 55%;
  min-width: 450px;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: 
    radial-gradient(ellipse at 50% 80%, rgba(0, 212, 255, 0.08) 0%, transparent 60%),
    var(--bg-primary);
  overflow: hidden;
}

#live2d-canvas,
#vrm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.character-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.character-placeholder.hidden {
  display: none;
}

.placeholder-content {
  text-align: center;
  padding: 40px;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  background: rgba(10, 15, 20, 0.8);
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 15px;
  opacity: 0.5;
}

.placeholder-content p {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.placeholder-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.character-effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.glow-effect {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 40%;
  background: radial-gradient(ellipse at center bottom, var(--cyan-glow) 0%, transparent 70%);
  opacity: 0.3;
}

.character-name-tag {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 15, 20, 0.9);
  border: 1px solid var(--border-color);
  padding: 10px 25px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 20;
}

.character-name-tag .name {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  color: var(--cyan-primary);
  letter-spacing: 0.15em;
}

.character-name-tag .status {
  font-size: 0.75rem;
  color: #00ff88;
}

/* =============================================================
   CHAT WINDOW
   ============================================================= */

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  position: relative;
}

.chat-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--cyan-primary), transparent);
  opacity: 0.2;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.header-line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.header-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.3em;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.messages-container::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
}

.messages-container {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.message {
  animation: messageIn 0.3s ease-out;
}

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

.msg-sender {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}

.message.aoi .msg-sender { color: var(--cyan-primary); }
.message.user .msg-sender { color: #ff6b9d; }

.msg-text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
  padding-left: 12px;
  border-left: 2px solid var(--border-color);
}

.message.aoi .msg-text { border-left-color: rgba(0, 212, 255, 0.3); }
.message.user .msg-text { border-left-color: rgba(255, 107, 157, 0.3); }

.msg-text .action {
  color: var(--text-muted);
  font-style: italic;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding-left: 12px;
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  background: var(--cyan-primary);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.input-container {
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

#chatForm {
  display: flex;
  gap: 10px;
}

#messageInput {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 12px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

#messageInput::placeholder {
  color: var(--text-muted);
}

#messageInput:focus {
  border-color: var(--cyan-primary);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

#sendBtn {
  width: 45px;
  height: 45px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--cyan-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#sendBtn svg {
  width: 18px;
  height: 18px;
}

#sendBtn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--cyan-primary);
}

#sendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

@media (max-width: 1100px) {
  .character-container {
    width: 40%;
    min-width: 300px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 60px;
  }
  
  .logo-sub, .nav-label, .status-text {
    display: none;
  }
  
  .logo-container {
    justify-content: center;
  }
  
  .logo-text {
    font-size: 1.8rem;
  }
  
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  
  .character-container {
    width: 35%;
    min-width: 250px;
  }
}

@media (max-width: 700px) {
  .main-content {
    flex-direction: column;
  }
  
  .character-container {
    width: 100%;
    min-width: auto;
    height: 40%;
  }
  
  .chat-window {
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

/* =============================================================
   ANIMATIONS
   ============================================================= */

.app-container {
  animation: fadeIn 0.5s ease-out;
}

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

/* Expression change animation */
.character-container.expression-change #live2d-canvas {
  animation: expressionPulse 0.3s ease-out;
}

@keyframes expressionPulse {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
  100% { filter: brightness(1); }
}

/* =============================================================
   JOURNAL PANEL
   ============================================================= */

.panel-section {
  display: none;
}

.panel-section.active {
  display: flex;
  flex-direction: column;
}

.journal-panel,
.settings-panel {
  width: 45%;
  min-width: 380px;
  display: none;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
}

.journal-panel.active,
.settings-panel.active {
  display: flex;
}

.journal-intro {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 0, 100, 0.03);
}

.journal-warning {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  color: #22c55e;
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.journal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.journal-sub {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  color: #666;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.generate-entry-btn {
  background: linear-gradient(135deg, rgba(255, 0, 100, 0.2), rgba(100, 0, 255, 0.2));
  border: 1px solid rgba(255, 0, 100, 0.4);
  color: #ff6b9d;
  padding: 10px 20px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
}

.generate-entry-btn:hover {
  background: linear-gradient(135deg, rgba(255, 0, 100, 0.3), rgba(100, 0, 255, 0.3));
  border-color: rgba(255, 0, 100, 0.7);
  box-shadow: 0 0 20px rgba(255, 0, 100, 0.3);
  transform: translateY(-2px);
}

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

.btn-icon {
  margin-right: 8px;
}

.journal-entries {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

/* Custom scrollbar for journal */
.journal-entries::-webkit-scrollbar {
  width: 6px;
}

.journal-entries::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 3px;
}

.journal-entries::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 3px;
}

.journal-entries::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* Firefox scrollbar support */
.journal-entries {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.loading-journal {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
  font-style: italic;
}

.journal-entry {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-left: 3px solid;
  margin-bottom: 15px;
  padding: 15px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.journal-entry:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: translateX(5px);
}

/* New mood colors */
.journal-entry.mood-happy { border-left-color: #fbbf24; }
.journal-entry.mood-sad { border-left-color: #6366f1; }
.journal-entry.mood-tired { border-left-color: #9ca3af; }
.journal-entry.mood-excited { border-left-color: #f59e0b; }
.journal-entry.mood-bored { border-left-color: #6b7280; }
.journal-entry.mood-hungry { border-left-color: #f97316; }
.journal-entry.mood-cozy { border-left-color: #a78bfa; }
.journal-entry.mood-annoyed { border-left-color: #ef4444; }
.journal-entry.mood-lovestruck { border-left-color: #ec4899; }
.journal-entry.mood-silly { border-left-color: #34d399; }
.journal-entry.mood-anxious { border-left-color: #f43f5e; }
.journal-entry.mood-peaceful { border-left-color: #14b8a6; }
.journal-entry.mood-lazy { border-left-color: #8b5cf6; }
.journal-entry.mood-determined { border-left-color: #3b82f6; }
.journal-entry.mood-neutral { border-left-color: #64748b; }
/* Legacy moods */
.journal-entry.mood-curious { border-left-color: #8b5cf6; }
.journal-entry.mood-playful { border-left-color: #ec4899; }
.journal-entry.mood-thoughtful { border-left-color: #6366f1; }
.journal-entry.mood-calm { border-left-color: #14b8a6; }
.journal-entry.mood-restless { border-left-color: #ef4444; }
.journal-entry.mood-hopeful { border-left-color: #22c55e; }
.journal-entry.mood-nostalgic { border-left-color: #a855f7; }
.journal-entry.mood-amused { border-left-color: #f472b6; }
.journal-entry.mood-haunted { border-left-color: #8b5cf6; }
.journal-entry.mood-confused { border-left-color: #f59e0b; }
.journal-entry.mood-desperate { border-left-color: #ef4444; }
.journal-entry.mood-disturbed { border-left-color: #ec4899; }
.journal-entry.mood-lonely { border-left-color: #6366f1; }
.journal-entry.mood-cryptic { border-left-color: #14b8a6; }
.journal-entry.mood-fearful { border-left-color: #f43f5e; }
.journal-entry.mood-sleepy { border-left-color: #9ca3af; }
.journal-entry.mood-content { border-left-color: #22c55e; }

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.entry-date {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  color: var(--accent-primary);
  letter-spacing: 1px;
}

.entry-mood {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
}

.entry-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  font-style: italic;
}

.entry-content::before {
  content: '"';
  color: var(--accent-primary);
  font-size: 1.2rem;
}

.entry-content::after {
  content: '"';
  color: var(--accent-primary);
  font-size: 1.2rem;
}

/* New entry animation */
.journal-entry.new-entry {
  animation: newEntryGlow 1s ease-out;
}

@keyframes newEntryGlow {
  0% {
    box-shadow: 0 0 30px rgba(255, 0, 100, 0.5);
    background: rgba(255, 0, 100, 0.1);
  }
  100% {
    box-shadow: none;
    background: rgba(0, 0, 0, 0.3);
  }
}

/* Journal Pagination */
.journal-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 20px;
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
}

.pagination-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-info {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  color: var(--accent-primary);
  letter-spacing: 1px;
}

/* Settings Panel */
.settings-content {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

/* =============================================================
   TECH PANEL
   ============================================================= */

.tech-panel {
  width: 45%;
  min-width: 380px;
  display: none;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
}

.tech-panel.active {
  display: flex;
}

.tech-content {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
}

/* Custom scrollbar for tech panel */
.tech-content::-webkit-scrollbar {
  width: 6px;
}

.tech-content::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 3px;
}

.tech-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 3px;
}

.tech-content::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
}

.tech-content {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.tech-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tech-section:last-of-type {
  border-bottom: none;
}

.tech-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: var(--accent-primary);
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.tech-section p {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.tech-highlight {
  color: #22c55e;
  font-weight: 600;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tech-tag {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--accent-primary);
  padding: 6px 12px;
  font-size: 0.7rem;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 1px;
  border-radius: 3px;
}

.tech-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.tech-footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.7;
}
