 :root {
  --bg-main-light: #020617;
  --bg-card-light: #020617;
  --text-main-light: #111827;
  --accent-light: #2563eb;
  --accent-soft-light: #e0ecff;

  --bg-main-dark: #020617;
  --bg-card-dark: #020617;
  --text-main-dark: #e5e7eb;
  --accent-dark: #38bdf8;
  --accent-soft-dark: #0f172a;
}

/* Smooth transitions */
body,
.sidebar,
.topbar,
.card-ui,
.chat-window,
.chat-bubble {
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main-light);
  color: var(--text-main-light);
}

body[data-theme="dark"] {
  background: radial-gradient(circle at top, #1f2937, #020617 60%);
  color: var(--text-main-dark);
}

.app-wrapper {
  min-height: 100vh;
  display: flex;
}

/* Sidebar – glassmorphism / neon */
.sidebar {
  width: 240px;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), rgba(15, 23, 42, 0.96));
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(148, 163, 184, 0.3);
  backdrop-filter: blur(18px);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.45);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  padding: 10px 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.4);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: conic-gradient(from 180deg, #38bdf8, #6366f1, #ec4899, #38bdf8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0b1120;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.8);
}

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.sidebar-sub {
  font-size: 11px;
  opacity: 0.7;
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin: 12px 6px 6px;
}

.nav-link-btn {
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  padding: 10px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.15s;
}

.nav-link-btn i {
  font-size: 16px;
  opacity: 0.9;
}

.nav-link-btn span {
  flex: 1;
}

.nav-link-btn:hover {
  background: rgba(148, 163, 184, 0.18);
  transform: translateX(2px);
}

.nav-link-btn.active {
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  color: #f9fafb;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.55);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  opacity: 0.7;
  padding: 8px 4px 0;
  border-top: 1px dashed rgba(148, 163, 184, 0.4);
}

.sidebar-footer a {
  color: #38bdf8;
  text-decoration: none;
}

/* Topbar + main content */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(18px);
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(30, 64, 175, 0.6);
}

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

.topbar-title {
  font-weight: 600;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e5e7eb;
}

.topbar-small {
  font-size: 12px;
  opacity: 0.7;
  color: #9ca3af;
}

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

.chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft-dark);
  color: var(--accent-dark);
}

.icon-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #020617;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.15s;
  color: #e5e7eb;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.content-area {
  padding: 18px 22px 26px;
}

/* Cards / common elements */
.card-ui {
  background: radial-gradient(circle at top left, #1f2937, #020617 65%);
  border-radius: 18px;
  padding: 22px 20px 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(55, 65, 81, 0.9);
  animation: fadeIn 0.3s ease;
  color: #e5e7eb;
}

.card-ui h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 10px;
}

textarea.form-control,
input.form-control,
select.form-select {
  border-radius: 12px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 10px 11px;
  font-size: 14px;
  box-shadow: none !important;
  resize: vertical;
  background-color: #020617;
  color: #e5e7eb;
}

.btn-primary {
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(90deg, #2563eb, #4f46e5);
  border: none;
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.6);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 9px 22px rgba(37, 99, 235, 0.75);
}

.response-box {
  background: #020617;
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 14px;
  border-left: 4px solid #38bdf8;
  max-height: 400px;
  overflow-y: auto;
}

/* Chat window – WhatsApp style */
.chat-window {
  max-height: 430px;
  min-height: 260px;
  overflow-y: auto;
  padding: 10px 4px 4px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, #e5f6ff, #f9fafb 55%, #eff6ff);
  border: 1px solid rgba(209, 213, 219, 0.8);
}

body[data-theme="dark"] .chat-window {
  background: radial-gradient(circle at top left, #020617, #020617 65%, #020617);
  border-color: rgba(55, 65, 81, 0.9);
}

.chat-row {
  display: flex;
  padding: 2px 10px;
}

.chat-meta {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  font-size: 13px;
  font-weight: 600;
}

.chat-avatar.ai {
  background: #2563eb;
  color: #f9fafb;
}

.chat-avatar.user {
  background: #0f9f5b;
  color: #f9fafb;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 11px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
}

.chat-bubble-inner {
  display: flex;
  flex-direction: column;
}

.chat-user-wrap {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.chat-ai-wrap {
  margin-right: auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.chat-user {
  background: #0f9f5b;
  color: #f9fafb;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 6px rgba(16, 185, 129, 0.3);
}

.chat-ai {
  background: #ffffff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.1);
  color: #111827;
}

body[data-theme="dark"] .chat-ai {
  background: #111827;
  color: #e5e7eb;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  min-height: 60px;
  max-height: 140px;
}

/* Loader overlay */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader-overlay.hidden {
  display: none;
}

.loader-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(148, 163, 184, 0.6);
  border-top-color: #2563eb;
  animation: spin 0.9s linear infinite;
}

body[data-theme="dark"] .loader-spinner {
  border-color: rgba(51, 65, 85, 0.9);
  border-top-color: #38bdf8;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* Bottom nav – mobile style */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  height: 52px;
  background: #020617;
  border-top: 1px solid rgba(30, 64, 175, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 40;
}

.bottom-nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #9ca3af;
}

.bottom-nav-btn i {
  font-size: 16px;
}

.bottom-nav-btn.active {
  color: #38bdf8;
}

/* PWA prompt */
.pwa-prompt {
  position: fixed;
  inset: auto 0 70px 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}

.pwa-prompt.hidden {
  display: none;
}

.pwa-card {
  pointer-events: auto;
  max-width: 420px;
  width: calc(100% - 32px);
  background: #020617;
  border-radius: 16px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.8);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pwa-text {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #e5e7eb;
}

.pwa-text span {
  opacity: 0.7;
  margin-top: 2px;
  font-size: 12px;
}

.pwa-actions {
  display: flex;
  gap: 6px;
}

/* Footer */
.app-footer {
  font-size: 13px;
  opacity: 0.7;
  padding: 10px 12px 68px;
}

/* Responsive */
@media (max-width: 991px) {

  .app-wrapper {
    flex-direction: column;
    min-height: 100vh;
    position: relative;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    max-width: 80%;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.24s ease-out;
    z-index: 30;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 25;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .content-area {
    padding: 14px 14px 70px;
  }

  .card-ui {
    padding: 16px;
  }

  .chat-window {
    max-height: 320px;
    min-height: 220px;
  }

  .chat-input-row {
    flex-direction: column;
    gap: 10px;
  }

  .chat-input-row textarea {
    min-height: 70px;
    max-height: 150px;
    width: 100%;
  }

  .chat-input-row button {
    width: 100%;
    padding: 12px;
  }

  textarea.form-control,
  input.form-control,
  select.form-select {
    font-size: 14px;
    padding: 10px;
  }

  .app-footer {
    padding-bottom: 60px;
  }
}

@media (max-width: 480px) {
  .card-ui h3 {
    font-size: 17px;
  }

  .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
  }
}
