/* ==========================================================================
   NQUESTIONS CMS COCKPIT — MODERN DESIGN SYSTEM & STYLES
   Tailored for NQuestions (nquestions.in) | Primary Tone: #5a9b92 (Teal)
   ========================================================================== */

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-focus: rgba(90, 155, 146, 0.5);

  --accent-primary: #5a9b92;
  --accent-hover: #48827a;
  --accent-glow: rgba(90, 155, 146, 0.25);
  --accent-secondary: #8b5cf6;

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --glass-blur: blur(14px);
}

body.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --card-border: #e2e8f0;
  --card-border-focus: rgba(90, 155, 146, 0.6);

  --accent-primary: #5a9b92;
  --accent-hover: #48827a;
  --accent-glow: rgba(90, 155, 146, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ================= LOGIN SCREEN ================= */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, rgba(90, 155, 146, 0.15), transparent 50%),
              radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.12), transparent 50%),
              var(--bg-primary);
  padding: 20px;
}

.glass-login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: slideUp 0.3s ease-out;
}

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

.nq-logo-badge {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #fff;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.login-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.login-hint {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.login-hint code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

/* ================= DASHBOARD SHELL ================= */
.dashboard-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top App Bar */
.top-nav {
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: var(--glass-blur);
}

.nav-left .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.brand-text .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text .website-link a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.brand-text .website-link a:hover {
  color: var(--accent-primary);
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-local .status-dot {
  background: #a855f7;
  box-shadow: 0 0 8px #a855f7;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
}

.admin-profile-pill .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.admin-profile-pill .name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.1;
}

.admin-profile-pill .role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ================= SIDEBAR & MAIN BODY ================= */
.dashboard-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.nav-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 12px 4px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}

.nav-item i {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(90, 155, 146, 0.14);
  color: var(--accent-primary);
  font-weight: 600;
  border: 1px solid rgba(90, 155, 146, 0.25);
}

.nav-counter {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.nav-counter.danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}

.api-status-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.75rem;
}

.api-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 2px;
}

.api-url {
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
}

/* ================= VIEWPORT PANELS ================= */
.content-viewport {
  flex: 1;
  padding: 28px 32px;
  background: var(--bg-primary);
  overflow-y: auto;
}

.view-panel {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

.panel-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ================= CARDS & METRICS ================= */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card {
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon.purple { background: rgba(139, 92, 246, 0.14); color: #8b5cf6; }
.metric-icon.blue { background: rgba(59, 130, 246, 0.14); color: #3b82f6; }
.metric-icon.green { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.metric-icon.amber { background: rgba(245, 158, 11, 0.14); color: #f59e0b; }

.metric-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 2px 0;
}

.metric-caption {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

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

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* ================= TABLES ================= */
.table-wrapper {
  overflow-x: auto;
}

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

.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 18px;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.pagination-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ================= BUTTONS & INPUTS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}
.btn-outline:hover {
  background: var(--bg-tertiary);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.icon-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.search-input {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  flex: 1;
  max-width: 420px;
}

.search-input input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  width: 100%;
}

.select-group {
  display: flex;
  gap: 10px;
}

select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="datetime-local"], textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--card-border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.two-col-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.three-col-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.code-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.4;
  width: 100%;
}

/* ================= SPLIT LATEX EDITOR ================= */
.split-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.pane-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--card-border);
}

.editor-pane textarea {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 0;
  resize: vertical;
}

.preview-pane {
  background: rgba(0, 0, 0, 0.15);
  border-left: 1px solid var(--card-border);
}

.math-preview-box {
  padding: 14px;
  min-height: 180px;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ================= BADGES & PILLS ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-accent {
  background: rgba(90, 155, 146, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(90, 155, 146, 0.3);
}

.badge-purple { background: rgba(139, 92, 246, 0.14); color: #8b5cf6; }
.badge-blue { background: rgba(59, 130, 246, 0.14); color: #3b82f6; }
.badge-green { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.badge-amber { background: rgba(245, 158, 11, 0.14); color: #f59e0b; }
.badge-red { background: rgba(239, 68, 68, 0.14); color: #ef4444; }

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-container.large {
  max-width: 900px;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

/* ================= TOAST NOTIFICATIONS ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  animation: slideInRight 0.25s ease-out;
  min-width: 280px;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
