/* ═══════════════════════════════════════ */
/* LAYOUT — App shell, sidebar, topbar,   */
/* main area, content, chat panel, login  */
/* ═══════════════════════════════════════ */

/* ── APP SHELL ── */
.app { display: flex; height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  transition: background .3s;
}

.sidebar-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }

.brand-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }

.brand-mark {
  width: 32px; height: 32px; background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: #0a0b0f; letter-spacing: -1px;
}

.brand-name { font-family: var(--font-mono); font-size: 16px; font-weight: 700; letter-spacing: 3px; color: var(--text); }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; margin-top: 2px; padding-left: 42px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-section-title { font-size: 9px; font-weight: 700; letter-spacing: 2px; color: var(--text-dim); padding: 0 10px; margin-bottom: 6px; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  cursor: pointer; transition: all .15s; color: var(--text-muted); font-size: 13px; font-weight: 500; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0;
}

.nav-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-badge.warn { background: var(--orange); }

.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); }

.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.user-card:hover { background: var(--surface-2); }

.user-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #e8b828);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #0a0b0f;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-dim); }
.user-status { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

/* ── MAIN AREA ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; transition: background .3s;
}

.topbar-title { font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 1px; color: var(--text-muted); }
.topbar-breadcrumb { font-size: 12px; color: var(--text-dim); }
.topbar-breadcrumb span { color: var(--text-muted); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s; font-size: 15px; position: relative;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-hover); }

.topbar-btn .notif-dot {
  position: absolute; top: 6px; right: 6px; width: 7px; height: 7px;
  background: var(--red); border-radius: 50%; border: 2px solid var(--surface);
}

/* Theme toggle */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s; font-size: 15px;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--accent); border-color: var(--border-hover); }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; width: 240px; transition: border-color .15s;
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search input { background: none; border: none; outline: none; color: var(--text); font-size: 12px; font-family: var(--font-sans); width: 100%; }
.topbar-search input::placeholder { color: var(--text-dim); }
.topbar-search .search-icon { color: var(--text-dim); font-size: 13px; }
.topbar-search kbd { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); background: var(--surface); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--border); }

/* ── CONTENT ── */
.content { flex: 1; overflow-y: auto; padding: 24px; display: flex; gap: 0; }
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.content-main { flex: 1; min-width: 0; }

/* ── CHAT PANEL (NEXUS AI) ── */
.chat-panel {
  width: 360px; flex-shrink: 0; background: var(--chat-bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; margin: -24px -24px -24px 24px;
  transition: width .3s, opacity .3s, margin .3s;
  overflow: hidden;
}

.chat-panel.collapsed { width: 0; margin-left: 0; opacity: 0; pointer-events: none; }

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

.chat-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #e8b828);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: #0a0b0f;
  box-shadow: 0 0 12px var(--accent-glow);
}

.chat-header-info { flex: 1; }
.chat-header-title { font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--text); }
.chat-header-sub { font-size: 10px; color: var(--green); display: flex; align-items: center; gap: 4px; }
.chat-header-sub::before { content: ''; width: 5px; height: 5px; background: var(--green); border-radius: 50%; }

.chat-close {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.chat-close:hover { background: var(--surface-2); color: var(--text); }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.chat-msg {
  padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  max-width: 95%; animation: chatFadeIn .3s ease;
}

.chat-msg.user {
  background: var(--chat-user); align-self: flex-end; border-bottom-right-radius: 3px;
}

.chat-msg.ai {
  background: var(--chat-ai); border: 1px solid var(--chat-ai-border);
  align-self: flex-start; border-bottom-left-radius: 3px;
}

.chat-msg.ai .msg-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: 1px;
  color: var(--accent); text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}

.chat-msg.ai .msg-label::before {
  content: ''; width: 6px; height: 6px; background: var(--accent); border-radius: 2px;
}

.chat-msg strong { color: var(--text); font-weight: 600; }
.chat-msg .insight-tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin-top: 6px;
}

.chat-context {
  padding: 10px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; background: var(--accent-soft);
}

.chat-context-text { font-size: 11px; color: var(--accent); flex: 1; }
.chat-context-close { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

.chat-input-area {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-end;
}

.chat-input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; color: var(--text);
  font-family: var(--font-sans); font-size: 13px; outline: none;
  resize: none; min-height: 40px; max-height: 100px; transition: border-color .15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-dim); }

.chat-send {
  width: 40px; height: 40px; border-radius: 10px; border: none;
  background: var(--accent); color: #0a0b0f; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all .15s; flex-shrink: 0;
}
.chat-send:hover { background: #d4ad2f; box-shadow: 0 0 16px var(--accent-glow); }

/* Chat quick actions */
.chat-quick {
  padding: 8px 16px; display: flex; gap: 6px; flex-wrap: wrap;
}

.chat-quick-btn {
  padding: 5px 10px; border-radius: 16px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chat-quick-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── PAGE SECTIONS ── */
.page { display: none; }
.page.active { display: block; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-family: var(--font-serif); font-size: 28px; font-weight: 400; color: var(--text); font-style: italic; }
.page-actions { display: flex; gap: 8px; }

/* ── LOGIN OVERLAY ── */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 1000;
  display: flex; align-items: center; justify-content: center; transition: opacity .4s, visibility .4s;
}
.login-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-box { width: 380px; text-align: center; }
.login-logo { width: 64px; height: 64px; background: var(--accent); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: 26px; color: #0a0b0f; margin: 0 auto 16px; box-shadow: 0 0 40px var(--accent-glow); }
.login-title { font-family: var(--font-mono); font-size: 24px; font-weight: 700; letter-spacing: 6px; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 32px; letter-spacing: 1px; }
.login-field { margin-bottom: 12px; }
.login-field input, .login-field select { width: 100%; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-family: var(--font-sans); font-size: 13px; outline: none; transition: border-color .15s; -webkit-appearance: none; }
.login-field input:focus, .login-field select:focus { border-color: var(--accent); }
.login-field input::placeholder { color: var(--text-dim); }
.login-field select option { background: var(--surface); }
.login-btn { width: 100%; padding: 12px; background: var(--accent); color: #0a0b0f; border: none; border-radius: 10px; font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: 2px; cursor: pointer; margin-top: 8px; transition: all .15s; }
.login-btn:hover { background: #d4ad2f; box-shadow: 0 0 30px var(--accent-glow); }
.login-roles { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 20px; }
.login-role { font-size: 10px; padding: 4px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) { .chat-panel { width: 300px; } }
@media (max-width: 900px) { .sidebar { display: none; } .chat-panel { display: none; } }
