/**
 * M.A.X.I.D. AI - Main Stylesheet
 *
 * @project       M.A.X.I.D. AI (Morally Absent X-ponentially Intelligent Disaster)
 * @version       1.1.0
 * @author        Strange Shapes Studio
 * @author_url    https://www.strangeshapes.com
 * @developer     Strange Shapes Studio
 * @developer_url info@strangeshapes.com
 * @license       Proprietary - Internal Use Only
 * @file          css/main.css
 */

/* ============================================================
   M.A.X.I.D. AI — Main Stylesheet
   Strange Shapes Studio
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;700;800&family=JetBrains+Mono:ital,wght@0,300;0,500;1,300&display=swap');

/* --- Variables --- */
:root {
  --navy:       #050a1a;
  --deep:       #080f24;
  --panel:      #0d1530;
  --panel2:     #111c38;
  --purple:     #7c3aed;
  --magenta:    #c026d3;
  --neon:       #d946ef;
  --neon2:      #a855f7;
  --glow:       rgba(192,38,211,0.35);
  --glow2:      rgba(124,58,237,0.25);
  --text:       #e2e8f0;
  --muted:      #94a3b8;
  --dim:        #475569;
  --border:     rgba(124,58,237,0.2);
  --border-hot: rgba(192,38,211,0.5);
  --font-mono:  'JetBrains Mono', monospace;
  --font-head:  'Syne', sans-serif;
  --sidebar-w:  260px;
  --topbar-h:   56px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* Circuit grid */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none; z-index: 0;
}

/* --- Scrollbars --- */
* { scrollbar-width: thin; scrollbar-color: rgba(124,58,237,0.4) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.4); border-radius: 4px; }

/* --- Layout --- */
.app-layout {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: width 0.3s ease;
}

.sidebar-header {
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
}

.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-brand {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(135deg, #fff 0%, var(--neon2) 50%, var(--neon) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.sidebar-brand small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--dim);
  -webkit-text-fill-color: var(--dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-new-chat {
  margin: 12px;
}

.btn-new-chat {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px;
  background: rgba(124,58,237,0.12);
  border: 1px solid var(--border-hot);
  border-radius: 10px;
  color: var(--neon2);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-new-chat:hover {
  background: rgba(192,38,211,0.18);
  box-shadow: 0 0 12px var(--glow);
  color: var(--neon);
}

.btn-new-chat svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Chat history list */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  padding: 8px 8px 4px;
}
.history-label::before { content: '// '; color: var(--neon); }

.history-item {
  display: flex; align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: all 0.15s;
  gap: 8px;
  overflow: hidden;
}

.history-item:hover, .history-item.active {
  background: rgba(124,58,237,0.1);
  color: var(--text);
  border-left: 2px solid var(--neon);
  padding-left: 8px;
}

.history-item svg { width: 12px; height: 12px; flex-shrink: 0; color: var(--dim); }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-item .arena-badge {
  font-size: 8px;
  padding: 1px 5px;
  background: rgba(192,38,211,0.15);
  border: 1px solid var(--border-hot);
  border-radius: 10px;
  color: var(--neon);
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  color: var(--text);
}
.user-card:hover { background: rgba(124,58,237,0.08); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--magenta));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
  border: 1px solid var(--border-hot);
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; }

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* --- TOPBAR --- */
.topbar {
  height: var(--topbar-h);
  background: rgba(8,15,36,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}

.model-selector {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  transition: all 0.2s;
  position: relative;
}
.model-selector:hover { border-color: var(--border-hot); box-shadow: 0 0 8px var(--glow2); }
.model-selector select {
  background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; padding-right: 4px;
}
.model-selector select option { background: var(--deep); }

.model-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--neon); box-shadow: 0 0 6px var(--neon);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

.mode-tabs {
  display: flex; gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.mode-tab {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--dim);
  border: none; background: none;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.mode-tab.active {
  background: rgba(124,58,237,0.2);
  color: var(--neon2);
  border: 1px solid var(--border-hot);
}
.mode-tab:hover:not(.active) { color: var(--text); }

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.icon-btn:hover {
  color: var(--neon); border-color: var(--border-hot);
  background: rgba(192,38,211,0.06);
}
.icon-btn svg { width: 16px; height: 16px; }

/* --- CHAT AREA --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Home screen (no messages) */
.home-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  animation: fadeUp 0.5s ease both;
}

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

.home-logo {
  width: 180px; height: 174px;
  margin-bottom: 20px;
}
.home-logo img { width: 100%; height: 100%; object-fit: contain; }

.home-letters {
  width: 100%; max-width: 600px;
  margin-bottom: 8px;
}
.home-letters img { width: 100%; height: auto; }

.home-subtitle {
  font-size: 12px;
  color: #c4b5fd;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-style: italic;
  margin-bottom: 36px;
  white-space: nowrap;
  text-align: center;
}

/* Suggested prompts */
.suggestions {
  width: 100%; max-width: 720px;
}
.suggestions-label {
  font-size: 10px; color: var(--dim);
  letter-spacing: 0.2em; text-transform: uppercase;
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.suggestions-label::before { content: '⚡'; color: var(--neon); }
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.suggestion-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 0;
}
.suggestion-card:hover {
  border-color: var(--border-hot);
  background: var(--panel2);
  box-shadow: 0 0 10px var(--glow2);
  transform: translateY(-1px);
}
.suggestion-title {
  font-family: var(--font-head);
  font-weight: 700; font-size: 12px;
  color: var(--text); margin-bottom: 3px;
}
.suggestion-sub { font-size: 10px; color: var(--dim); font-style: italic; }

/* Chat messages */
.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeUp 0.3s ease both;
}
.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.message-meta {
  font-size: 10px; color: var(--dim);
  display: flex; align-items: center; gap: 6px;
}
.message-meta .model-tag {
  padding: 1px 6px;
  background: rgba(124,58,237,0.1);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--neon2);
}

.message-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.7;
  font-size: 13px;
}
.message.user .message-bubble {
  background: rgba(124,58,237,0.15);
  border: 1px solid var(--border-hot);
  color: var(--text);
  border-radius: 12px 12px 4px 12px;
}
.message.assistant .message-bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px 12px 12px 4px;
}

/* Code blocks in messages */
.message-bubble pre {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 12px;
}
.message-bubble code { font-family: var(--font-mono); }

/* Arena mode */
.arena-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  overflow: hidden;
}
.arena-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.arena-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--neon2);
  background: rgba(124,58,237,0.05);
}
.arena-panel-header select {
  background: none; border: none; outline: none;
  color: var(--neon2); font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.arena-panel-header select option { background: var(--deep); }
.arena-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* --- INPUT AREA --- */
.input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: rgba(8,15,36,0.8);
  backdrop-filter: blur(8px);
}

.input-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-width: 900px;
  margin: 0 auto;
}
.input-wrap:focus-within {
  border-color: var(--border-hot);
  box-shadow: 0 0 20px var(--glow), 0 0 40px var(--glow2);
}

.chat-textarea {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font-mono); font-size: 13px;
  line-height: 1.6; resize: none; min-height: 24px; max-height: 180px;
}
.chat-textarea::placeholder { color: var(--dim); font-style: italic; }

.input-bar {
  display: flex; align-items: center;
  justify-content: space-between; margin-top: 8px; gap: 6px;
}
.input-actions { display: flex; gap: 4px; }

.input-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.input-action-btn:hover { color: var(--neon); border-color: var(--border-hot); background: rgba(192,38,211,0.06); }
.input-action-btn svg { width: 13px; height: 13px; }

.send-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: linear-gradient(135deg, var(--purple), var(--magenta));
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 0 10px var(--glow);
}
.send-btn:hover { box-shadow: 0 0 20px var(--glow); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.send-btn svg { width: 15px; height: 15px; }

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 4px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px; width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--neon2); animation: typing 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,60%,100% { transform:translateY(0); } 30% { transform:translateY(-6px); } }

/* --- STATUS BAR --- */
.status-bar {
  height: 24px;
  background: var(--deep);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 16px;
  font-size: 10px; color: var(--dim);
  flex-shrink: 0;
}
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.status-item { display: flex; align-items: center; gap: 5px; }
.status-bar-spacer { flex: 1; }
.status-version { color: #c4b5fd; opacity: 0.9; font-style: italic; }

.status-ss-logo {
  height: 32px;
  opacity: 0.85;
}
.status-ss-logo img { height: 100%; width: auto; object-fit: contain; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--magenta));
  color: #fff; box-shadow: 0 0 10px var(--glow);
}
.btn-primary:hover { box-shadow: 0 0 20px var(--glow); transform: translateY(-1px); }
.btn-secondary {
  background: var(--panel); border-color: var(--border); color: var(--text);
}
.btn-secondary:hover { border-color: var(--border-hot); background: var(--panel2); }
.btn-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* --- FORMS --- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 10px; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 6px;
}
.form-label::before { content: '// '; color: var(--neon); }
.form-control {
  width: 100%; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: var(--font-mono); font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--border-hot);
  box-shadow: 0 0 12px var(--glow);
}
.form-control::placeholder { color: var(--dim); }
select.form-control option { background: var(--deep); }

/* --- ALERTS --- */
.alert {
  padding: 10px 14px; border-radius: 8px;
  font-size: 12px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid;
}
.alert-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: #86efac; }
.alert-info { background: rgba(124,58,237,0.1); border-color: var(--border-hot); color: #c4b5fd; }

/* --- MODALS --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--deep); border: 1px solid var(--border-hot);
  border-radius: 16px; width: 90%; max-width: 520px; max-height: 85vh;
  overflow-y: auto; transform: translateY(20px); transition: transform 0.3s;
  box-shadow: 0 0 60px rgba(124,58,237,0.3);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--deep); z-index: 1;
}
.modal-title { font-family: var(--font-head); font-weight: 700; font-size: 16px; color: var(--text); }
.modal-title span { color: var(--neon); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { color: var(--neon); border-color: var(--border-hot); }
.modal-body { padding: 20px; }

/* --- UTILITIES --- */
.hidden { display: none !important; }
.text-neon { color: var(--neon); }
.text-muted { color: var(--muted); }
.text-dim { color: var(--dim); }
.font-head { font-family: var(--font-head); }
