/* ==========================================================================
   Millisa AI Platform - Design System & Stylesheet
   Modern Glassmorphic Dark UI | Fully Mobile Responsive
   ========================================================================== */

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #101522;
  --bg-card: rgba(19, 26, 42, 0.75);
  --bg-card-hover: rgba(28, 38, 62, 0.85);
  --bg-input: rgba(14, 20, 33, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --border-glow: rgba(56, 189, 248, 0.3);

  --accent-primary: #6366f1; /* Indigo */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #38bdf8 50%, #10b981 100%);
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --sidebar-width: 260px;
  --header-height: 64px;
  --bottom-nav-height: 62px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background Ambient Glows */
.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(140px);
  opacity: 0.15;
  z-index: 0;
}
.glow-1 { top: -100px; left: -100px; background: #6366f1; }
.glow-2 { bottom: -100px; right: -100px; background: #10b981; }

/* Main App Wrapper */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ──────────────────────────────────────────────────────────────────────────
   SIDEBAR (Desktop)
   ────────────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(14, 18, 30, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 40;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(99, 102, 241, 0.4);
  text-transform: uppercase;
  font-weight: 600;
}

.nav-menu {
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
}

button {
  background: transparent;
  color: inherit;
  border: none;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
}

.nav-item {
  background: rgba(255, 255, 255, 0.03) !important;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: #cbd5e1 !important;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
  outline: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.28) !important;
  color: #38bdf8 !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: inherit;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--accent-emerald);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ──────────────────────────────────────────────────────────────────────────
   MAIN CONTENT VIEWPORT
   ────────────────────────────────────────────────────────────────────────── */
.main-viewport {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

/* Top Mobile / Tablet Header Bar */
.top-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 30;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.4rem;
}

.top-header-title {
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Tab Views Container */
.tab-content {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  padding: 1.5rem;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ──────────────────────────────────────────────────────────────────────────
   VIEW 1: CHAT WEB APP
   ────────────────────────────────────────────────────────────────────────── */
#tab-chat {
  padding: 0;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.chat-subbar {
  padding: 0.75rem 1.25rem;
  background: rgba(16, 21, 34, 0.7);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.model-badge-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  gap: 1rem;
  max-width: 85%;
  animation: fadeIn 0.2s ease-in;
}

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

.message-row.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.avatar.ai {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.4);
}

.avatar.user {
  background: #334155;
  color: #cbd5e1;
}

.message-bubble {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: #4f46e5;
  color: #fff;
  border: none;
  border-top-right-radius: 4px;
}

.message-row.ai .message-bubble {
  border-top-left-radius: 4px;
  background: rgba(20, 27, 45, 0.8);
}

.message-bubble pre {
  background: #090c14;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.85rem;
  position: relative;
}

.message-bubble code {
  font-family: 'Consolas', monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.quick-prompts {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 1.25rem 0.25rem;
  scrollbar-width: none;
}
.quick-prompts::-webkit-scrollbar { display: none; }

.prompt-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}

.prompt-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(99, 102, 241, 0.3);
}

.chat-input-wrapper {
  padding: 0.75rem 1.25rem 1rem;
  background: rgba(10, 13, 20, 0.95);
  border-top: 1px solid var(--border-color);
}

.chat-input-bar {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.4rem 0.6rem 0.4rem 1rem;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.chat-input-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.2);
}

.chat-textarea {
  flex-grow: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  padding: 0.4rem 0;
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background: #4f46e5;
  transform: scale(1.04);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ──────────────────────────────────────────────────────────────────────────
   VIEW 2: API KEYS & DASHBOARD
   ────────────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.stat-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.dashboard-card {
  background: var(--bg-card);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

/* Responsive Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  color: #94a3b8 !important;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.05em;
}

.data-table td {
  color: #f1f5f9 !important;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-revoked {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-tier {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.key-code {
  font-family: 'Consolas', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   VIEW 3: DOCUMENTATION HUB
   ────────────────────────────────────────────────────────────────────────── */
.docs-header {
  margin-bottom: 1.5rem;
}

.docs-title {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.docs-sub {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   VIEW 3: PROFESSIONAL DOCUMENTATION DASHBOARD
   ────────────────────────────────────────────────────────────────────────── */
.docs-nav-bar {
  display: flex;
  gap: 0.5rem;
  background: rgba(16, 21, 34, 0.85);
  padding: 0.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.docs-nav-bar::-webkit-scrollbar { display: none; }

.docs-nav-btn {
  background: transparent !important;
  color: #94a3b8 !important;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  white-space: nowrap;
  border: 1px solid transparent !important;
}

.docs-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #ffffff !important;
}

.docs-nav-btn.active {
  background: rgba(99, 102, 241, 0.25) !important;
  color: #38bdf8 !important;
  border-color: rgba(99, 102, 241, 0.4) !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.doc-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(15px);
}

.doc-card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.doc-card-desc {
  font-size: 0.95rem;
  color: #94a3b8;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.method-tag {
  font-family: 'Consolas', monospace;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  text-transform: uppercase;
}
.method-post {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.method-get {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.endpoint-url {
  font-family: 'Consolas', monospace;
  font-size: 1rem;
  color: #f1f5f9;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}
.param-table th {
  text-align: left;
  color: #94a3b8;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.param-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
  color: #cbd5e1;
}

.param-name {
  font-family: 'Consolas', monospace;
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.9rem;
}

.param-type {
  font-family: 'Consolas', monospace;
  font-size: 0.75rem;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.param-req {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fb7185;
  background: rgba(244, 63, 94, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 0.4rem;
}

.param-opt {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 0.4rem;
}

.code-container {
  position: relative;
  background: #090c14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  margin: 1rem 0 1.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  color: #cbd5e1;
}

.code-content {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: 'Consolas', 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #e2e8f0;
}

.copy-code-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #f1f5f9 !important;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}
.copy-code-btn:hover {
  background: rgba(99, 102, 241, 0.3) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}

.sdk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.sdk-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}
.sdk-card:hover {
  background: rgba(99, 102, 241, 0.05);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
}
.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Playground Section */
.playground-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

/* ──────────────────────────────────────────────────────────────────────────
   VIEW 4: MASTER SETTINGS
   ────────────────────────────────────────────────────────────────────────── */
.settings-section {
  max-width: 800px;
}

.setting-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* User Profile in Header */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.user-avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.role-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 700;
}
.role-super-admin {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}
.role-developer {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* Auth Gatecard (when logged out in keys portal) */
.auth-gatecard {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(15px);
  margin-bottom: 2rem;
}

.auth-gate-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.2);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}
.auth-tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.auth-tab-btn.active {
  color: #fff;
  border-color: var(--accent-primary);
}

.auth-error-banner {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-backdrop.show .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 200;
}

.toast {
  background: rgba(16, 21, 34, 0.95);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(15px);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────────────────
   MOBILE RESPONSIVENESS (Phones & Tablets)
   ────────────────────────────────────────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -100%;
    width: 280px;
    z-index: 150;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 140;
    display: none;
  }
  .sidebar-backdrop.show { display: block; }

  .mobile-menu-btn {
    display: block;
  }

  .tab-content {
    padding: 1rem;
    padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
  }

  #tab-chat {
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
    height: calc(100dvh - var(--header-height) - var(--bottom-nav-height));
    padding: 0;
  }

  .chat-messages {
    padding: 1rem;
  }

  .message-row {
    max-width: 95%;
  }

  /* Fixed Bottom Bar on Mobile */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(14, 18, 30, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mob-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 0.2rem;
    flex: 1;
    height: 100%;
    cursor: pointer;
  }

  .mob-nav-item.active {
    color: var(--accent-cyan);
  }

  .mob-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .btn {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .card-header-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .prompt-chip {
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
  }
}
