/* RESET */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

/* BODY – DARK MODE */
.dark-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #020617;
  color: #e5e7eb;
  line-height: 1.5;
}

/* DEMO BANNER */
.demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
}

.demo-banner.dark {
  background: radial-gradient(circle at left, #0ea5e9, #0b1120 55%);
  color: #e5e7eb;
}

.demo-banner .logo-text {
  font-weight: 600;
}

.demo-banner .demo-note {
  opacity: 0.85;
}

/* MAIN LAYOUT */
.page {
  position: relative;
  min-height: calc(100vh - 52px);
}

/* BACKGROUND */
.hero-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
}

.hero-bg-dark {
  background-image:
    radial-gradient(circle at top left, #047857 0, transparent 45%),
    radial-gradient(circle at bottom right, #1d4ed8 0, transparent 50%),
    radial-gradient(circle at center, #020617 0, #000 60%);
  opacity: 0.96;
}

/* APP SHELL */
.app-shell {
  max-width: 1180px;
  margin: 1.3rem auto;
  padding: 1.5rem;
  border-radius: 1.4rem;
  backdrop-filter: blur(16px);
}

.dark-shell {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
}

/* HEADER */
.app-header {
  margin-bottom: 1rem;
}

.app-title-block {
  margin-bottom: 0.75rem;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-subtitle {
  font-size: 0.95rem;
  color: #9ca3af;
}

/* TABS */
.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.nav-tab {
  border: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: #020617;
  color: #cbd5f5;
  border: 1px solid #111827;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease,
    border-color 0.15s ease;
}

.nav-tab:hover {
  background: #020617;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.nav-tab.active {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #f9fafb;
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6);
}

/* GRID: CONTENT + SIDEBAR */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

.content-column {
  min-width: 0;
}

.sidebar {
  min-width: 0;
}

/* CARDS */
.card {
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.dark-card {
  background: radial-gradient(circle at top, #020617, #020617);
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.card p {
  font-size: 0.9rem;
  color: #cbd5f5;
}

/* PANELS */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.tab-panel h3 {
  font-size: 1rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.bullet-list {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.92rem;
  color: #e5e7eb;
}

.bullet-list li + li {
  margin-top: 0.25rem;
}

.numbered-list {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  color: #e5e7eb;
}

/* WARNING BOX */
.warning-box {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  font-size: 0.9rem;
}

.dark-warning {
  background: rgba(248, 250, 252, 0.04);
  border: 1px solid rgba(251, 191, 36, 0.9);
  color: #fef9c3;
}

/* TEXT */
.cta-text {
  margin-top: 0.75rem;
  font-size: 0.92rem;
  color: #e5e7eb;
}

.small-note {
  font-size: 0.82rem;
  color: #9ca3af;
  margin-top: 0.35rem;
}

/* LINKS */
a {
  color: #38bdf8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* BUTTONS */
.primary-btn {
  border: none;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #f9fafb;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.8);
  transition:
    transform 0.05s ease,
    box-shadow 0.1s ease,
    background 0.1s ease;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #4338ca);
  box-shadow: 0 22px 60px rgba(37, 99, 235, 0.95);
}

.primary-btn:active {
  transform: translateY(1px);
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.7);
}

/* UPLOAD BUTTON */
.upload-label {
  display: inline-flex;
  margin-top: 0.45rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: #020617;
  border: 1px solid #374151;
  font-size: 0.85rem;
  cursor: pointer;
  color: #e5e7eb;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.9);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.upload-label:hover {
  background: #020617;
  border-color: #1d4ed8;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 1);
}

/* ASSISTANT LAYOUT */
.assistant-layout {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 1rem;
}

.assistant-actions {
  font-size: 0.9rem;
}

/* UPLOADED PREVIEW */
.uploaded-preview {
  margin-top: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.8rem;
  background: #020617;
  border: 1px solid #111827;
}

.uploaded-preview.hidden {
  display: none;
}

.preview-title {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.uploaded-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 0.6rem;
}

/* ASSISTANT PANEL */
.assistant-panel {
  border-radius: 1.1rem;
  background: radial-gradient(circle at top, #020617, #020617);
  color: #e5e7eb;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 1);
}

.assistant-panel.hidden {
  display: none;
}

/* CHAT */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.25rem 0.5rem;
  font-size: 0.86rem;
}

.chat-message {
  margin-bottom: 0.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.75rem;
  max-width: 100%;
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #f9fafb;
}

.chat-message.bot {
  align-self: flex-start;
  background: #020617;
  border: 1px solid #111827;
  color: #e5e7eb;
}

.chat-input-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.chat-input-row input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #374151;
  padding: 0.4rem 0.7rem;
  font-size: 0.86rem;
  background: #020617;
  color: #e5e7eb;
}

.chat-input-row input:focus {
  outline: none;
  border-color: #60a5fa;
}

.chat-hint {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* DEFECT GALLERY */
.defect-gallery {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
}

.defect-card {
  background: #020617;
  border-radius: 0.9rem;
  border: 1px solid #111827;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.defect-card:hover {
  transform: translateY(-2px);
  border-color: #2563eb;
  box-shadow: 0 18px 52px rgba(37, 99, 235, 0.6);
}

.defect-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.defect-card-body {
  padding: 0.45rem 0.55rem 0.55rem;
}

.defect-card-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.defect-card-sub {
  font-size: 0.76rem;
  color: #9ca3af;
}

/* DEFECT DETAIL PANEL */
.defect-detail {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  background: radial-gradient(circle at top, #020617, #020617);
  border: 1px solid #111827;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 1);
}

.defect-detail.hidden {
  display: none;
}

.defect-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.defect-detail-code {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #020617;
  border: 1px solid #1d4ed8;
  font-size: 0.8rem;
  color: #bfdbfe;
}

.defect-detail-title {
  font-size: 0.98rem;
  font-weight: 500;
}

.defect-detail-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.defect-detail-column h4 {
  font-size: 0.86rem;
  margin-bottom: 0.25rem;
  color: #9ca3af;
}

.defect-detail-list {
  list-style: none;
  font-size: 0.86rem;
}

.defect-detail-list li + li {
  margin-top: 0.2rem;
}

.defect-detail-list li::before {
  content: "• ";
  color: #38bdf8;
}

/* RESPONSIVE */
@media (max-width: 960px) {
  .app-shell {
    margin: 0.75rem;
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .assistant-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    order: -1;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 640px) {
  .demo-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-nav {
    overflow-x: auto;
  }

  .app-title {
    font-size: 1.2rem;
  }

  .assistant-panel {
    min-height: 220px;
  }
}
