/* frank2.css — SuperFrank UI v2 */
/* Dark theme, Inter font, clean and modern like Claude/ChatGPT */

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

:root {
  --bg:          #0a0a0f;
  --bg-surface:  #111118;
  --bg-elevated: #18181f;
  --bg-hover:    #1e1e28;
  --bg-active:   #24242f;
  --border:      rgba(255,255,255,0.08);
  --border-hover:rgba(255,255,255,0.14);
  --text:        #ececec;
  --text-2:      #9999aa;
  --text-3:      #55556a;
  --accent:      #7c3aed;
  --accent-h:    #6d28d9;
  --accent-glow: rgba(124,58,237,0.25);
  --success:     #22c55e;
  --warn:        #f59e0b;
  --danger:      #ef4444;
  --sidebar-w:   260px;
  --topbar-h:    52px;
  --input-h:     56px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }

/* ── SCREENS ──────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ── LOGIN ────────────────────────────────────────────────── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.15) 0%, var(--bg) 70%);
}
.login-box {
  width: 100%; max-width: 380px; padding: 48px 40px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
}
.login-logo {
  display: flex; align-items: baseline; gap: 4px; margin-bottom: 8px;
  justify-content: center;
}
.login-logo-f {
  font-size: 48px; font-weight: 700; color: var(--accent);
  line-height: 1;
}
.login-logo-name { font-size: 32px; font-weight: 300; color: var(--text); }
.login-tagline { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 32px; }
.login-box input {
  width: 100%; padding: 12px 16px; margin-bottom: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  outline: none; transition: border 0.15s;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button[type=submit] {
  width: 100%; padding: 12px; margin-top: 4px;
  background: var(--accent); border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 15px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.login-box button[type=submit]:hover { background: var(--accent-h); }
.login-box button[type=submit]:active { transform: scale(0.98); }
.error-msg { margin-top: 10px; color: var(--danger); font-size: 13px; text-align: center; }

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

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  z-index: 100;
}
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 99; backdrop-filter: blur(2px);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 12px;
}
.sidebar-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.logo-f { font-size: 18px; font-weight: 700; color: #fff; }
.new-chat-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.new-chat-btn:hover { background: var(--bg-hover); color: var(--text); }
.new-chat-btn svg { width: 16px; height: 16px; }

.sidebar-section {
  padding: 8px 8px 4px; flex-shrink: 0;
}
.sidebar-section-sessions {
  flex: 1; overflow: hidden; display: flex; flex-direction: column;
}
.sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 6px; color: var(--text-3); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sidebar-add-btn {
  background: none; border: none; color: var(--text-2); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 2px;
  transition: color 0.15s;
}
.sidebar-add-btn:hover { color: var(--text); }

.project-list { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.project-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  color: var(--text-2); transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-item:hover { background: var(--bg-hover); color: var(--text); }
.project-item.active { background: var(--bg-active); color: var(--text); }
.project-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
}

.session-list {
  flex: 1; overflow-y: auto; padding: 0 2px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.session-item {
  padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; color: var(--text-2); transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; flex-direction: column; gap: 2px;
}
.session-item:hover { background: var(--bg-hover); color: var(--text); }
.session-item.active { background: var(--bg-active); color: var(--text); }
.session-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.session-date { font-size: 11px; color: var(--text-3); }

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
}
.sidebar-user-name { font-size: 13px; color: var(--text-2); }
.sidebar-logout {
  width: 30px; height: 30px; background: none; border: none;
  color: var(--text-3); cursor: pointer; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.15s, color 0.15s;
}
.sidebar-logout:hover { background: var(--bg-hover); color: var(--danger); }
.sidebar-logout svg { width: 16px; height: 16px; }

/* ── MAIN AREA ────────────────────────────────────────────── */
.main-area {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  height: 100vh; position: relative; overflow: hidden;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center;
  padding: 0 12px; gap: 8px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--bg);
}
.topbar-menu { flex-shrink: 0; }
.topbar-center {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
}
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-project {
  font-size: 11px; color: var(--accent); font-weight: 500;
  letter-spacing: 0.03em;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn[data-active="true"] { color: var(--accent); background: var(--accent-glow); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── VISION PANEL ─────────────────────────────────────────── */
.vision-panel {
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  padding: 12px 16px; flex-shrink: 0;
}
.vision-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 13px; color: var(--text-2);
}
.vision-controls { display: flex; gap: 6px; }
.vision-ctrl-btn {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  cursor: pointer; transition: all 0.15s;
}
.vision-ctrl-btn.active { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.vision-ctrl-btn:hover:not(.active) { background: var(--bg-hover); color: var(--text); }
.vision-stop { color: var(--danger) !important; border-color: var(--danger) !important; }
.vision-preview-wrap { position: relative; }
.vision-video {
  width: 100%; max-height: 160px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg);
}
.vision-status {
  position: absolute; bottom: 6px; right: 8px; font-size: 11px;
  color: var(--success); background: rgba(0,0,0,0.6); padding: 2px 8px;
  border-radius: 4px;
}

/* ── DASHBOARD ────────────────────────────────────────────── */
.dashboard-panel {
  position: absolute; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 50; overflow-y: auto; padding: 24px;
}
.dashboard-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.dashboard-header h2 { font-size: 20px; font-weight: 600; }
.dashboard-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.dash-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.dash-card-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 12px;
}
.dash-card-body { font-size: 13px; color: var(--text-2); line-height: 1.6; }

/* ── CHAT AREA ────────────────────────────────────────────── */
.chat-area {
  flex: 1; overflow-y: auto; padding: 0;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.messages { max-width: 760px; margin: 0 auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 0; }

/* Message rows */
.msg { display: flex; gap: 12px; padding: 6px 0; }
.msg-user { flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; margin-top: 2px;
}
.msg-frank .msg-avatar { background: var(--accent); color: #fff; }
.msg-user .msg-avatar { background: var(--bg-active); color: var(--text); }
.msg-body { max-width: calc(100% - 54px); display: flex; flex-direction: column; gap: 4px; }
.msg-user .msg-body { align-items: flex-end; }
.msg-name { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 0 4px; }
.msg-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65;
  color: var(--text); word-break: break-word;
}
.msg-frank .msg-bubble { background: transparent; padding-left: 0; border-radius: 0; }
.msg-user .msg-bubble { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px 14px 2px 14px; }

/* Attachment in bubble */
.msg-attachment {
  margin-top: 6px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); max-width: 320px;
}
.msg-attachment img { width: 100%; display: block; }

/* Markdown inside bubbles */
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { margin: 12px 0 6px; font-weight: 600; }
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 15px; }
.msg-bubble h3 { font-size: 14px; }
.msg-bubble p { margin: 6px 0; }
.msg-bubble ul,.msg-bubble ol { margin: 6px 0 6px 20px; }
.msg-bubble li { margin: 2px 0; }
.msg-bubble code {
  background: var(--bg-active); border-radius: 4px;
  padding: 1px 5px; font-family: 'JetBrains Mono','Fira Code',monospace; font-size: 12px;
}
.msg-bubble pre {
  background: var(--bg-active); border-radius: var(--radius-sm);
  padding: 12px 14px; overflow-x: auto; margin: 10px 0;
  border: 1px solid var(--border);
}
.msg-bubble pre code { background: none; padding: 0; font-size: 12px; }
.msg-bubble blockquote {
  border-left: 3px solid var(--accent); padding-left: 12px;
  margin: 8px 0; color: var(--text-2);
}
.msg-bubble table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.msg-bubble th,.msg-bubble td { border: 1px solid var(--border); padding: 6px 10px; }
.msg-bubble th { background: var(--bg-active); font-weight: 600; }
.msg-bubble a { color: var(--accent); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }

/* Thinking / streaming indicator */
.msg-thinking .msg-bubble::after {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent); margin-left: 4px;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:0.2} 50%{opacity:1} }

/* Vision analysis message */
.msg-vision { opacity: 0.85; }
.msg-vision .msg-bubble { font-size: 13px; color: var(--text-2); font-style: italic; }
.msg-vision-label {
  font-size: 11px; color: var(--accent); font-weight: 600;
  display: flex; align-items: center; gap: 4px; margin-bottom: 4px; padding-left: 4px;
}

/* ── INPUT BAR ────────────────────────────────────────────── */
.input-bar {
  padding: 10px 16px 16px; display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg); border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-wrap {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; transition: border 0.15s;
}
.input-wrap:focus-within { border-color: var(--border-hover, rgba(255,255,255,0.14)); }
.attachment-preview {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0;
}
.attach-thumb {
  position: relative; width: 50px; height: 50px; border-radius: 6px;
  overflow: hidden; border: 1px solid var(--border);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb-name {
  width: 80px; height: 50px; border-radius: 6px; padding: 4px 6px;
  background: var(--bg-active); border: 1px solid var(--border);
  font-size: 10px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center;
}
.attach-remove {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: rgba(0,0,0,0.7); border: none;
  color: #fff; font-size: 10px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.chat-input {
  width: 100%; padding: 11px 14px; background: transparent;
  border: none; color: var(--text); font-size: 14px; resize: none;
  outline: none; line-height: 1.5; max-height: 160px; font-family: inherit;
}
.chat-input::placeholder { color: var(--text-3); }

.input-action-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.15s; align-self: flex-end;
}
.input-action-btn:hover { background: var(--bg-hover); color: var(--text); }
.input-action-btn svg { width: 17px; height: 17px; }
.voice-toggle[data-active="true"] { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.voice-toggle[data-active="true"]:hover { background: var(--accent); color: #fff; }

.send-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent); border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s; align-self: flex-end;
}
.send-btn:hover { background: var(--accent-h); }
.send-btn:active { transform: scale(0.94); }
.send-btn svg { width: 16px; height: 16px; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── VOICE OVERLAY ────────────────────────────────────────── */
.voice-overlay {
  position: fixed; inset: 0; background: rgba(5,5,10,0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(12px);
}
.voice-overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.voice-orb { display: block; }
.voice-label { font-size: 15px; color: var(--text-2); letter-spacing: 0.03em; }
.voice-transcript-live {
  max-width: 480px; text-align: center; font-size: 15px; color: var(--text);
  line-height: 1.6; min-height: 48px; padding: 0 20px;
}
.voice-end-btn {
  margin-top: 8px; padding: 10px 28px; border-radius: 24px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-2); font-size: 14px; cursor: pointer;
  transition: all 0.15s;
}
.voice-end-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── PROJECT MODAL ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; backdrop-filter: blur(6px);
}
.modal-box {
  width: 100%; max-width: 440px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.modal-box h3 { font-size: 17px; font-weight: 600; }
.modal-input {
  width: 100%; padding: 10px 14px; background: var(--bg-active);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; resize: none; transition: border 0.15s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-textarea { min-height: 72px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary {
  padding: 9px 20px; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: #fff; font-size: 14px;
  font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost {
  padding: 9px 16px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

/* ── RESPONSIVE — mobile sidebar ─────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-menu { display: flex; }
}
@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
  .topbar-menu { display: none; }
}
