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

:root {
  --bg: #0a0a0f;
  --bg2: #13131a;
  --bg3: #1a1a24;
  --border: #252530;
  --text: #eaeaf5;
  --text2: #7878a0;
  --claude: #e07a5f;
  --gpt: #10b981;
  --gemini: #3b82f6;
  --conductor: #22c55e;
  --radius: 14px;
}

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

.page { width: 100%; height: 100vh; }
.hidden { display: none !important; }
.error { color: #ff6b6b; font-size: 13px; margin-top: 8px; min-height: 20px; }

/* LOGIN */
#login-page {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1a0f2e 0%, #0d0d18 50%, var(--bg) 100%);
}
.login-container { width: 360px; }
.logo { text-align: center; margin-bottom: 40px; }
.logo-icon { font-size: 48px; color: var(--conductor); margin-bottom: 16px; }
.logo h1 { font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.logo p { color: var(--text2); font-size: 14px; }
.field { margin-bottom: 12px; }
.field input {
  width: 100%; padding: 14px 16px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 15px; outline: none; transition: border-color .2s;
}
.field input:focus { border-color: var(--conductor); }
.btn-primary {
  width: 100%; padding: 14px; background: var(--conductor);
  border: none; border-radius: var(--radius); color: white;
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: 0.85; }

/* APP LAYOUT */
#app-page { display: flex; }

/* SIDEBAR */
#sidebar {
  width: 240px; min-width: 240px;
  background: linear-gradient(180deg, #111118 0%, #0e0e14 100%);
  border-right: 1px solid var(--border); display: flex;
  flex-direction: column; height: 100vh;
}
.sidebar-header {
  padding: 20px 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.logo-small { font-size: 15px; font-weight: 600; color: var(--conductor); }
.btn-new {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 6px 12px; border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: background .2s;
}
.btn-new:hover { background: var(--border); }
.sidebar-section { padding: 12px 16px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); }
#history-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.history-item {
  padding: 10px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text2); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .2s, color .2s;
}
.history-item:hover { background: var(--bg3); color: var(--text); }
.history-item.active { background: var(--bg3); color: var(--text); }
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
#user-name { font-size: 13px; color: var(--text2); }
#logout-btn {
  background: none; border: none; color: var(--text2);
  font-size: 13px; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: background .2s;
}
#logout-btn:hover { background: var(--bg3); color: var(--text); }

/* MAIN */
#main {
  flex: 1; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden; position: relative;
}

/* EMPTY STATE */
#empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 40px;
}
.empty-icon { font-size: 56px; color: var(--border); margin-bottom: 20px; }
#empty-state h2 { font-size: 22px; margin-bottom: 10px; }
#empty-state p { color: var(--text2); font-size: 15px; line-height: 1.6; }

/* RESULTS */
#results-area {
  flex: 1; overflow-y: auto; padding: 24px 28px 0;
}
#question-display {
  font-size: 18px; font-weight: 600; color: var(--text);
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* AI GRID */
.ai-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 16px; margin-bottom: 20px;
}
.ai-card {
  background: linear-gradient(160deg, var(--bg2) 0%, #111118 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  transition: box-shadow .2s, transform .2s;
}
.ai-card:hover { box-shadow: 0 8px 32px rgba(0,0,0,0.4); transform: translateY(-1px); }
.ai-header {
  padding: 12px 16px; display: flex; align-items: center;
  gap: 8px; border-bottom: 1px solid var(--border);
}
.ai-header.claude { border-top: 3px solid var(--claude); }
.ai-header.gpt { border-top: 3px solid var(--gpt); }
.ai-header.gemini { border-top: 3px solid var(--gemini); }
.ai-icon { font-size: 16px; }
.ai-header.claude .ai-icon { color: var(--claude); }
.ai-header.gpt .ai-icon { color: var(--gpt); }
.ai-header.gemini .ai-icon { color: var(--gemini); }
.ai-name { font-weight: 600; font-size: 14px; flex: 1; }
.ai-badge { font-size: 11px; color: var(--text2); }
.ai-body {
  padding: 16px; font-size: 14px; line-height: 1.65;
  color: var(--text); min-height: 120px; white-space: pre-wrap;
}
.ai-body.loading { color: var(--text2); font-style: italic; }
.ai-body.loading::after {
  content: ''; display: inline-block; width: 6px; height: 14px;
  background: var(--text2); margin-left: 2px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* CONDUCTOR */
#conductor-section {
  background: linear-gradient(135deg, #16102a 0%, #1a1430 50%, #1e1a38 100%);
  border: 1px solid rgba(34,197,94,0.25); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 24px;
  box-shadow: 0 0 40px rgba(34,197,94,0.08), 0 4px 24px rgba(0,0,0,0.4);
}
.conductor-header {
  padding: 14px 20px; display: flex; align-items: center;
  gap: 10px; font-weight: 600; font-size: 15px;
  color: var(--conductor); border-bottom: 1px solid #3d2d6e;
}
.conductor-icon { font-size: 20px; }
.conductor-body {
  padding: 20px; font-size: 14px; line-height: 1.7;
  color: var(--text); white-space: pre-wrap;
}

/* INPUT */
#input-area {
  padding: 16px 110px 20px 28px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.input-wrapper {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 10px 10px 16px;
  transition: border-color .2s;
}
.input-wrapper:focus-within { border-color: var(--conductor); }
#question-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px; resize: none;
  max-height: 150px; font-family: inherit; line-height: 1.5;
}
#question-input::placeholder { color: var(--text2); }
.btn-send {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--conductor); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
  transition: opacity .2s;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: white; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* BIOLAR AI Robot */
#biolar-robot {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 100; cursor: pointer;
  animation: robot-float 3s ease-in-out infinite;
}
#biolar-robot:hover { animation-play-state: paused; }
#biolar-robot:hover .robot-body { filter: drop-shadow(0 0 14px #22c55e); }
.robot-body {
  position: relative;
  filter: drop-shadow(0 0 6px rgba(34,197,94,0.4));
  transition: filter .3s;
}
.robot-label {
  font-size: 10px; font-weight: 700; letter-spacing: 2px;
  color: var(--conductor); text-shadow: 0 0 8px rgba(34,197,94,0.8);
  background: rgba(10,10,15,0.9); padding: 3px 10px; border-radius: 6px;
  border: 1px solid rgba(34,197,94,0.3); position: relative; z-index: 2;
  margin-top: 2px;
}
.robot-glow {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 8px;
  background: radial-gradient(ellipse, rgba(34,197,94,0.35) 0%, transparent 70%);
  border-radius: 50%; animation: glow-pulse 3s ease-in-out infinite;
}
.robot-antenna-dot { animation: antenna-pulse 2s ease-in-out infinite; }
.robot-eye-left { animation: eye-blink 4s ease-in-out infinite; }
.robot-eye-right { animation: eye-blink 4s ease-in-out infinite 0.1s; }
.robot-chest { animation: chest-pulse 1.5s ease-in-out infinite; }
@keyframes robot-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow-pulse { 0%,100% { opacity:.4; transform:translateX(-50%) scaleX(1); } 50% { opacity:.9; transform:translateX(-50%) scaleX(1.4); } }
@keyframes antenna-pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }
@keyframes eye-blink { 0%,88%,100% { transform:scaleY(1); } 92% { transform:scaleY(0.08); } }
@keyframes chest-pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* File attachment */
.btn-file {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; font-size: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.btn-file:hover { background: var(--border); }
.btn-file:disabled { opacity: 0.4; cursor: not-allowed; }

#file-tag {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--conductor);
  border-radius: 8px; padding: 6px 12px; margin-bottom: 8px;
  font-size: 13px; color: var(--conductor);
}
#file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#remove-file-btn {
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 14px; padding: 0 2px;
  transition: color .2s;
}
#remove-file-btn:hover { color: var(--text); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 900px) {
  .ai-grid { grid-template-columns: 1fr; }
  #sidebar { display: none; }
}
