/* ============================================================
 *  AI Physics Tutor — Design System
 *  Paleta oscura premium con acentos neón (cyan + verde)
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables Globales ── */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #101018;
  --bg-card: #14141e;
  --bg-card-hover: #1a1a28;
  --bg-input: #0e0e16;
  --border: #1e1e2e;
  --border-hover: #2a2a40;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent-cyan: #00d4ff;
  --accent-cyan-dim: rgba(0,212,255,0.15);
  --accent-green: #00ff88;
  --accent-green-dim: rgba(0,255,136,0.12);
  --accent-red: #ff4757;
  --accent-yellow: #ffd32a;
  --accent-purple: #6c5ce7;
  --glass: rgba(20,20,30,0.75);
  --glass-border: rgba(255,255,255,0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow-cyan: 0 0 20px rgba(0,212,255,0.15);
  --shadow-glow-green: 0 0 20px rgba(0,255,136,0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; width: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Layout Principal ── */
.app { display: flex; flex-direction: column; height: 100vh; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px; min-height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.app-header__brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}

.app-header__logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 16px; color: #000; font-weight: 700;
}

.app-header__actions { display: flex; gap: 8px; }

/* ── Split Panel ── */
.split-container {
  display: flex; flex: 1; overflow: hidden;
  position: relative;
}

.panel {
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

.panel--chat { flex: 0 0 55%; min-width: 340px; border-right: 1px solid var(--border); }
.panel--sim { flex: 1; min-width: 300px; background: #08080c; }

/* ── Divider Draggable ── */
.divider {
  width: 5px; cursor: col-resize;
  background: var(--border);
  transition: background var(--transition);
  z-index: 50; position: relative;
  flex-shrink: 0;
}
.divider:hover, .divider.active { background: var(--accent-cyan); box-shadow: var(--shadow-glow-cyan); }

/* ── Chat Panel ── */
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.chat-header__title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.chat-header__subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
}

/* ── Mensajes ── */
.message { display: flex; gap: 12px; animation: msgFadeIn 0.35s ease; max-width: 100%; }
.message--user { flex-direction: row-reverse; }
.message--user .message__bubble {
  background: linear-gradient(135deg, rgba(0,212,255,0.12), rgba(0,255,136,0.08));
  border-color: rgba(0,212,255,0.2);
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}
.message--assistant .message__bubble {
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

.message__avatar {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 16px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border);
}
.message--user .message__avatar { background: var(--accent-cyan-dim); }
.message--assistant .message__avatar { background: var(--accent-green-dim); }

.message__bubble {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px; line-height: 1.6;
  max-width: 85%; word-break: break-word;
}

.message__bubble pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 8px 0; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13px;
}

.message__bubble code {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg-primary); padding: 2px 6px; border-radius: 4px;
  color: var(--accent-cyan);
}

.message__sim-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 6px 12px;
  background: var(--accent-green-dim);
  border: 1px solid rgba(0,255,136,0.25);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--accent-green);
  cursor: pointer; transition: all var(--transition);
}
.message__sim-badge:hover {
  background: rgba(0,255,136,0.2);
  box-shadow: var(--shadow-glow-green);
}

/* ── Typing indicator ── */
.typing-indicator { display: flex; gap: 4px; padding: 8px 0; }
.typing-indicator span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

/* ── Sugerencias ── */
.suggestions {
  padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--border);
}

.suggestion-chip {
  padding: 7px 14px; font-size: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
  font-family: var(--font-sans); white-space: nowrap;
}
.suggestion-chip:hover {
  background: var(--accent-cyan-dim);
  border-color: rgba(0,212,255,0.3);
  color: var(--accent-cyan);
}

/* ── Input Area ── */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-wrapper {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px; transition: border-color var(--transition);
}
.chat-input-wrapper:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
}

.chat-input {
  flex: 1; border: none; outline: none;
  background: transparent; color: var(--text-primary);
  font-family: var(--font-sans); font-size: 14px;
  padding: 10px 14px; resize: none;
  max-height: 120px; line-height: 1.5;
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent-cyan), #0099cc);
  color: #000; display: grid; place-items: center;
  transition: all var(--transition); flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-glow-cyan); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-send-btn svg { width: 18px; height: 18px; }

/* ── Sim Panel ── */
.sim-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.sim-header__title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sim-header__controls { display: flex; gap: 6px; }

.sim-canvas-wrap { flex: 1; position: relative; overflow: hidden; }
.sim-canvas-wrap canvas { display: block; width: 100%; height: 100%; }

/* ── HUD Overlay ── */
.sim-hud {
  position: absolute; top: 12px; left: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 18px; min-width: 180px;
  font-size: 12px; z-index: 10;
  animation: hudSlideIn 0.4s ease;
}
.sim-hud__title {
  font-weight: 600; font-size: 13px;
  margin-bottom: 10px; color: var(--accent-cyan);
  display: flex; align-items: center; gap: 6px;
}
.sim-hud__row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 3px 0; color: var(--text-secondary);
}
.sim-hud__value { color: var(--text-primary); font-family: var(--font-mono); font-weight: 500; }

/* ── Placeholder (sin simulación) ── */
.sim-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--text-muted); text-align: center; padding: 40px;
}
.sim-placeholder__icon { font-size: 48px; opacity: 0.5; }
.sim-placeholder__text { font-size: 14px; max-width: 280px; line-height: 1.6; }

/* ── Control Buttons ── */
.ctrl-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition); font-size: 14px;
}
.ctrl-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-hover); }
.ctrl-btn--active { background: var(--accent-cyan-dim); color: var(--accent-cyan); border-color: rgba(0,212,255,0.3); }

/* ── Icon Buttons (header) ── */
.icon-btn {
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer;
  font-family: var(--font-sans); font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── Welcome Screen ── */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px; text-align: center; gap: 20px;
}
.welcome__icon {
  width: 64px; height: 64px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-cyan-dim), var(--accent-green-dim));
  border: 1px solid var(--glass-border);
  display: grid; place-items: center; font-size: 28px;
}
.welcome__title { font-size: 20px; font-weight: 600; }
.welcome__desc { font-size: 14px; color: var(--text-secondary); max-width: 380px; line-height: 1.7; }

/* ── History sidebar ── */
.history-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 280px; background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 200; transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex; flex-direction: column;
}
.history-panel.open { transform: translateX(0); }
.history-panel__header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 14px;
}
.history-panel__list { flex: 1; overflow-y: auto; padding: 8px; }
.history-item {
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
  transition: all var(--transition); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item:hover { background: var(--bg-card); color: var(--text-primary); }
.history-item--active { background: var(--accent-cyan-dim); color: var(--accent-cyan); }
.history-item__date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Animations ── */
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}
@keyframes hudSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse { animation: pulse 2s infinite; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .split-container { flex-direction: column; }
  .panel--chat { flex: 0 0 55%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); }
  .panel--sim { min-width: unset; }
  .divider { width: 100%; height: 5px; cursor: row-resize; }
  .suggestions { overflow-x: auto; flex-wrap: nowrap; }
  .history-panel { width: 100%; }
}
