/* NileAI · Dark Professional Theme · ShacksTech */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:          #0f0f13;
  --bg2:         #16161e;
  --bg3:         #1e1e2a;
  --bg4:         #252535;
  --border:      #2a2a3a;
  --border2:     #363650;
  --text:        #f0f0f5;
  --text2:       #a0a0b8;
  --text3:       #606075;
  --accent:      #7c3aed;
  --accent2:     #6d28d9;
  --accent-soft: rgba(124,58,237,0.15);
  --green:       #10b981;
  --green-soft:  rgba(16,185,129,0.12);
  --blue:        #3b82f6;
  --blue-soft:   rgba(59,130,246,0.12);
  --yellow:      #f59e0b;
  --red:         #ef4444;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:        'JetBrains Mono', 'Courier New', monospace;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
}

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

html { height: 100%; background: var(--bg); }

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; }

/* ── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── APP SHELL ─── */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ── SIDEBAR ─── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}
.sidebar-logo:hover { background: var(--bg3); }

.logo-mark {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(124,58,237,0.4);
}

.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.logo-tag {
  font-size: 10.5px;
  color: var(--text3);
  line-height: 1.2;
}

.icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }

.sidebar-new-chat {
  padding: 12px 12px 8px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.new-chat-btn:hover { background: var(--bg4); border-color: var(--accent); }

.sidebar-section-label {
  padding: 10px 18px 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
  overflow: hidden;
}
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item:hover { background: var(--bg3); color: var(--text); }

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 8px 10px 12px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.sidebar-nav-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-nav-item.active-page { background: var(--accent-soft); color: var(--text); }
.sidebar-nav-item.active-page svg { color: var(--accent); }

/* ── MAIN ─── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

/* ── TOPBAR ─── */
.topbar {
  height: 54px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
}
.model-badge .dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s ease infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

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

/* ── CHAT AREA ─── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* ── WELCOME ─── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 48px 24px 24px;
  text-align: center;
}

.welcome-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(124,58,237,0.35);
}

.welcome-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.6px;
  margin-bottom: 10px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--text2);
  margin-bottom: 40px;
  max-width: 400px;
  line-height: 1.7;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 560px;
  width: 100%;
}

.suggestion-card {
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.suggestion-card:hover {
  background: var(--bg3);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.suggestion-icon { font-size: 22px; margin-bottom: 9px; }
.suggestion-main { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.suggestion-sub  { font-size: 12px; color: var(--text3); line-height: 1.5; }

/* ── MESSAGES ─── */
.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px 0;
  width: 100%;
}

.message-row {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.msg-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  flex-shrink: 0;
}
.msg-avatar.user-av {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.msg-avatar.ai-av {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

.msg-content { flex: 1; min-width: 0; }
.msg-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-name .name-badge {
  font-size: 10px;
  padding: 1px 7px;
  background: var(--accent-soft);
  color: #a78bfa;
  border-radius: 10px;
  font-weight: 500;
}

.msg-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.78;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-text code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 2px 7px;
  border-radius: 5px;
  color: #a78bfa;
}
.msg-text pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.7;
  color: #e0e0e0;
  font-family: var(--mono);
}
.msg-text pre code { background: none; border: none; padding: 0; color: inherit; }

.msg-actions { display: flex; gap: 4px; margin-top: 10px; opacity: 0; transition: opacity 0.15s; }
.message-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.msg-action-btn:hover { background: var(--bg3); border-color: var(--border); color: var(--text2); }

/* Cursor */
.typing-cursor {
  display: inline-block;
  width: 2px; height: 17px;
  background: var(--accent);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.7s step-end infinite;
}
@keyframes cursorBlink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Thinking */
.thinking-row { display: flex; gap: 14px; padding: 16px 0; }
.thinking-dots { display: flex; align-items: center; gap: 5px; padding-top: 5px; }
.thinking-dots span {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotBounce 1.4s ease-in-out infinite;
  opacity: 0.7;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-7px)} }

.generated-image {
  max-width: 480px; width: 100%;
  border-radius: var(--radius);
  margin-top: 12px; display: block;
  border: 1px solid var(--border);
}

/* ── INPUT AREA ─── */
.input-area {
  flex-shrink: 0;
  padding: 12px 20px 20px;
  background: var(--bg);
}

.input-box-wrap { max-width: 800px; margin: 0 auto; }

.input-box {
  position: relative;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

.chat-textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 200px;
  padding: 15px 58px 15px 18px;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  resize: none;
  line-height: 1.6;
  overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--text3); }

.send-btn {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 36px; height: 36px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(124,58,237,0.4);
  transition: opacity 0.15s, transform 0.15s;
}
.send-btn:disabled { background: var(--bg4); box-shadow: none; cursor: not-allowed; color: var(--text3); }
.send-btn:not(:disabled):hover { opacity: 0.9; transform: scale(1.04); }

.input-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 9px;
}

/* ── PAGE LAYOUT ─── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px;
  background: var(--bg);
}

.page-header { margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -0.4px; }
.page-desc  { font-size: 14px; color: var(--text2); margin-top: 6px; line-height: 1.65; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--bg4); border-color: var(--border2); }
.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-green:hover { opacity: 0.9; }

/* Fields */
.field-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text3); }

/* Key box */
.key-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg3);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  margin: 14px 0;
}
.key-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #a78bfa;
  word-break: break-all;
  line-height: 1.6;
}
.key-notice {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: #fcd34d;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.key-list { display: flex; flex-direction: column; gap: 8px; }
.key-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
  transition: border-color 0.15s;
}
.key-item:hover { border-color: var(--accent); }
.key-item-name { font-size: 14px; font-weight: 600; color: var(--text); }
.key-item-date { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.key-item-preview {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  word-break: break-all;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
  gap: 0;
}
.tabs::-webkit-scrollbar { height: 0; }
.tab-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: #a78bfa; border-bottom-color: var(--accent); }

/* Code wrap */
.code-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 10px 0; }
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
}
.code-header span { font-family: var(--mono); font-size: 12px; color: var(--text2); }
.code-body {
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  color: #c4b5fd;
  line-height: 1.75;
  overflow-x: auto;
  white-space: pre;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-purple { background: var(--accent-soft); color: #a78bfa; }
.badge-blue  { background: var(--blue-soft); color: var(--blue); }

/* Docs table */
.docs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.docs-table th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600;
  color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.docs-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: top;
}
.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: var(--bg3); }
.td-param { font-family: var(--mono); font-size: 12.5px; color: #a78bfa; }
.td-type  { color: var(--text3); }
.td-req   { color: var(--green); font-weight: 600; }

/* Animations */
@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
.fade-up { animation: fadeUp 0.3s ease forwards; }

/* Mobile */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .page-content { padding: 18px 16px; }
  .input-area { padding: 10px 14px 18px; }
  .messages { padding: 16px 14px 0; }
  .suggestion-grid { grid-template-columns: 1fr; max-width: 100%; }
  .welcome-title { font-size: 24px; }
}
