/* FuturoGen UI (distinct theme + standardized flow) */

:root {
  --fg-ink: #0b1220;
  --fg-ink-2: #243049;
  --fg-muted: #5b6b84;
  /* Slightly darker than before for better contrast on vivid backgrounds */
  --fg-muted-2: #55657d;
  --fg-line: #d7e0ea;
  --fg-line-2: #eef2f7;
  --fg-paper: #fbfdff;
  --fg-paper-2: #f5f8fc;

  /* Brand */
  --primary: #0a7ea4;          /* deep teal */
  --primary-light: #10b3d3;
  --primary-dark: #075a75;
  --accent: #ff7a00;           /* orange */
  --accent-light: #ffb15a;

  --success: #14b86a;
  --danger: #e5484d;
  --warning: #f5a524;

  /* Legacy tokens (kept for compatibility with existing templates) */
  --bg-body: var(--fg-paper);
  --bg-card: rgba(251, 253, 255, 0.88);
  --border: var(--fg-line);
  --border-light: var(--fg-line-2);
  --text-primary: var(--fg-ink);
  --text-secondary: var(--fg-muted);
  --text-muted: var(--fg-muted-2);

  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-md: 0 10px 24px rgba(11, 18, 32, 0.10);
  --shadow-lg: 0 18px 50px rgba(11, 18, 32, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.18s ease;

  /* Vivid gradients */
  --v1: #00d4ff; /* cyan */
  --v2: #7c3aed; /* violet */
  --v3: #ff2ea6; /* magenta */
  --v4: #ffcc00; /* yellow */
  --v5: #00e887; /* green */
  --v6: #ff6a00; /* orange */
  --vivid-grad: linear-gradient(135deg, var(--v1), var(--v2), var(--v3), var(--v4));
  --vivid-grad-2: linear-gradient(135deg, var(--v5), var(--v1), var(--v3), var(--v6));
  /* Keep buttons vivid but avoid too-light yellow under white text */
  --vivid-grad-btn: linear-gradient(135deg, #0a7ea4 0%, #2563eb 35%, #7c3aed 70%, #ff2ea6 100%);
}

html, body { height: 100%; }

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--fg-ink);
  background: var(--fg-paper);
  padding-bottom: 64px; /* footer breathing room */
  -webkit-font-smoothing: antialiased;
}

/* Vivid animated background: colorful mesh + grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 10% 0%, rgba(0, 212, 255, 0.26), transparent 62%),
    radial-gradient(780px 520px at 90% 5%, rgba(255, 46, 166, 0.20), transparent 58%),
    radial-gradient(900px 600px at 85% 85%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(980px 540px at 15% 88%, rgba(255, 204, 0, 0.14), transparent 62%),
    /* neon fog layer */
    conic-gradient(from 180deg at 50% 50%, rgba(0, 232, 135, 0.10), rgba(0, 212, 255, 0.08), rgba(255, 106, 0, 0.08), rgba(124, 58, 237, 0.08), rgba(255, 46, 166, 0.10)),
    /* grid */
    repeating-linear-gradient(90deg, rgba(215, 224, 234, 0.30), rgba(215, 224, 234, 0.30) 1px, transparent 1px, transparent 22px),
    repeating-linear-gradient(0deg, rgba(215, 224, 234, 0.26), rgba(215, 224, 234, 0.26) 1px, transparent 1px, transparent 22px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 160% 160%, auto, auto;
  background-position: 0 0, 0 0, 0 0, 0 0, 50% 50%, 0 0, 0 0;
  /* Keep the vibe, but don't fight with content readability */
  opacity: 0.82;
  animation: fgMeshDrift 18s ease-in-out infinite alternate;
}

/* Soft veil to reduce background noise behind text-heavy pages */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(251, 253, 255, 0.55);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

@keyframes fgMeshDrift {
  0% {
    filter: saturate(1.05) contrast(1.02);
    background-position: 0% 0%, 100% 0%, 100% 100%, 0% 100%, 50% 50%, 0 0, 0 0;
  }
  100% {
    filter: saturate(1.22) contrast(1.03);
    background-position: 10% 6%, 92% 8%, 88% 92%, 6% 90%, 45% 55%, 0 0, 0 0;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Space Grotesk", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg-ink);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

.text-muted { color: var(--fg-muted-2) !important; }

/* Main content surface for readability (all pages) */
.container.mt-4 {
  background: rgba(251, 253, 255, 0.78);
  border: 1px solid rgba(215, 224, 234, 0.65);
  border-radius: 18px;
  padding-top: 1rem;
  padding-bottom: 1.15rem;
  box-shadow: 0 18px 60px rgba(11, 18, 32, 0.08);
  /* Avoid creating a stacking context that can break Bootstrap modals */
}

/* Bootstrap container: keep it wide, but consistent padding */
.container {
  max-width: 100% !important;
  width: 100% !important;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  box-sizing: border-box;
}
@media (min-width: 1200px) {
  .container { padding-left: 2.25rem; padding-right: 2.25rem; }
}

/* Navbar: dark glass, distinct from generic dashboards */
.navbar {
  background: rgba(11, 18, 32, 0.78) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(11, 18, 32, 0.18);
  padding: .70rem 0;
}
.navbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--vivid-grad);
  opacity: 0.9;
}
.navbar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}
.navbar-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--vivid-grad-2);
  box-shadow: 0 10px 22px rgba(0,0,0,0.25);
  position: relative;
  overflow: hidden;
}
.navbar-brand .brand-mark i { color: rgba(11, 18, 32, 0.9); }
.navbar-brand .brand-mark::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.55), transparent 45%);
  transform: rotate(18deg);
  animation: fgShine 2.8s ease-in-out infinite;
  opacity: 0.65;
}
@keyframes fgShine {
  0% { transform: translateX(-18%) rotate(18deg); opacity: 0.35; }
  45% { opacity: 0.75; }
  100% { transform: translateX(18%) rotate(18deg); opacity: 0.35; }
}
.navbar-dark .navbar-nav .nav-link {
  color: rgba(255,255,255,0.92) !important;
  font-weight: 600;
  transition: color var(--transition), transform var(--transition);
  text-shadow: 0 1px 10px rgba(0,0,0,0.25);
}
.navbar-dark .navbar-nav .nav-link:hover { color: #fff !important; transform: translateY(-1px); }

/* Breadcrumb */
.breadcrumb { background: transparent; padding: .45rem 0; margin-bottom: .5rem; }
.breadcrumb a, .breadcrumb .breadcrumb-item { color: var(--primary) !important; font-weight: 600; }
.breadcrumb .breadcrumb-item.active { color: var(--fg-muted) !important; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--fg-muted-2) !important; }

/* Tabs (if any pages use them) */
.nav-tabs { border-bottom: 2px solid var(--fg-line); }
.nav-tabs .nav-link {
  color: var(--fg-muted) !important;
  font-weight: 800;
  border: none !important;
  padding: .55rem 1rem;
  border-radius: 12px 12px 0 0;
  transition: background var(--transition), color var(--transition);
}
.nav-tabs .nav-link:hover { color: var(--primary-dark) !important; background: rgba(10, 126, 164, 0.06); }
.nav-tabs .nav-link.active { color: var(--primary-dark) !important; background: rgba(251, 253, 255, 0.92) !important; box-shadow: inset 0 -3px 0 var(--primary); }

/* Cards */
.card {
  background: rgba(251, 253, 255, 0.88) !important;
  border: 1px solid var(--fg-line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
  color: var(--fg-ink);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius) + 2px);
  background: var(--vivid-grad);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 0;
  pointer-events: none;
}
.card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--radius) - 1px);
  background: rgba(251, 253, 255, 0.975);
  z-index: 0;
  pointer-events: none;
}
.card > * { position: relative; z-index: 1; }
.card:hover { box-shadow: var(--shadow-md); border-color: rgba(10, 126, 164, 0.35) !important; }
.card:hover::before { opacity: 0.22; }
.card-header {
  background: rgba(245, 248, 252, 0.98) !important;
  border-bottom: 1px solid var(--fg-line) !important;
  font-weight: 700;
  color: var(--fg-ink) !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card.light-green { border-left: 4px solid var(--success) !important; }
.card.light-green .card-header { background: rgba(20, 184, 106, 0.08) !important; }

/* Buttons */
.btn { border-radius: var(--radius-sm); font-weight: 700; letter-spacing: 0.01em; transition: all var(--transition); }
.btn-primary {
  background: var(--vivid-grad-btn) !important;
  border: none !important;
  color: #fff !important;
  box-shadow: 0 14px 34px rgba(124, 58, 237, 0.18);
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 10px rgba(0,0,0,0.25);
}
/* Override legacy `.card .card-body a { color: ... !important; }` so primary buttons stay white */
.card .card-body a.btn { color: inherit !important; }
.card .card-body a.btn-primary,
.card .card-body a.btn-success,
.card .card-body a.btn-danger { color: #fff !important; }
.card .card-body a.btn-info,
.card .card-body a.btn-warning { color: #081320 !important; }
.card .card-body a.btn-outline-primary { color: var(--primary) !important; }
.card .card-body a.btn-outline-danger { color: var(--danger) !important; }
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: translateX(-120%);
  transition: transform 0.7s ease;
  pointer-events: none;
}
.btn-primary:hover::before { transform: translateX(120%); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 44px rgba(255, 46, 166, 0.18); }

/* Index "进入项目" button: slightly larger text weight on small buttons */
.btn.btn-sm.btn-primary { font-weight: 800; letter-spacing: 0.02em; }

/* Auth pages */
.auth-shell {
  max-width: 860px;
  margin: 1.25rem auto 0;
}
.auth-card {
  border-radius: 22px !important;
  overflow: hidden;
}
.auth-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 420px;
}
.auth-hero {
  position: relative;
  padding: 1.5rem 1.5rem;
  color: rgba(255,255,255,0.92);
  background: radial-gradient(1200px 500px at 20% 0%, rgba(255,255,255,0.18), transparent 55%),
              var(--vivid-grad-btn);
  overflow: hidden; /* prevent glow layer from covering the form column */
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 210deg at 50% 50%, rgba(0,212,255,0.30), rgba(255,46,166,0.22), rgba(255,106,0,0.20), rgba(124,58,237,0.26), rgba(0,232,135,0.22));
  filter: blur(40px);
  opacity: 0.55;
  animation: fgAuthGlow 10s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: .82rem;
  letter-spacing: .02em;
  color: rgba(11,18,32,0.92);
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.65);
}
.auth-title {
  margin-top: 1rem;
  font-size: 1.6rem;
  line-height: 1.15;
  color: #fff;
}
.auth-subtitle {
  margin-top: .65rem;
  max-width: 28ch;
  color: rgba(255,255,255,0.86);
}
.auth-form {
  padding: 1.5rem 1.5rem;
  background: rgba(251, 253, 255, 0.985);
}
.auth-form h4 {
  margin-bottom: .9rem;
}

/* Smaller input boxes (less tall + less padding) */
.auth-form .form-control {
  padding: .45rem .65rem;
  font-size: .95rem;
}
.auth-form .form-label {
  font-weight: 800;
  font-size: .86rem;
  color: var(--fg-muted);
}

@keyframes fgAuthGlow {
  0% { transform: translate(-2%, -2%) rotate(0deg); }
  100% { transform: translate(2%, 2%) rotate(14deg); }
}

@media (max-width: 992px) {
  .auth-shell { max-width: 520px; }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-hero { padding: 1.25rem 1.25rem; }
}
.btn-info { background: linear-gradient(135deg, var(--primary-light), var(--accent)) !important; border: none !important; color: #081320 !important; }
.btn-danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }
.btn-warning { background: var(--warning) !important; border-color: var(--warning) !important; color: #081320 !important; }
.btn-success { background: var(--success) !important; border-color: var(--success) !important; color: #fff !important; }

.btn-outline-primary { color: var(--primary) !important; border-color: rgba(10, 126, 164, 0.6) !important; }
.btn-outline-primary:hover { background: rgba(10, 126, 164, 0.08) !important; color: var(--primary-dark) !important; border-color: rgba(10, 126, 164, 0.9) !important; }
.btn-outline-danger { color: var(--danger) !important; border-color: rgba(229, 72, 77, 0.7) !important; }
.btn-outline-danger:hover { background: rgba(229, 72, 77, 0.10) !important; color: #8d1a1f !important; border-color: rgba(229, 72, 77, 0.95) !important; }

.btn:disabled, .btn.disabled { opacity: 0.55; transform: none !important; }

/* Inputs */
.form-control, .form-select {
  border: 1px solid var(--fg-line);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  background: rgba(255,255,255,0.92);
}
.form-control:focus, .form-select:focus {
  border-color: rgba(16, 179, 211, 0.85);
  box-shadow: 0 0 0 4px rgba(16, 179, 211, 0.14);
}

/* Badges */
.badge { font-weight: 700; border-radius: 999px; padding: .35em .70em; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-secondary { background: var(--fg-muted-2) !important; }

/* Pagination */
.page-link { color: var(--primary); border-color: var(--fg-line); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Project layout */
.project-layout {
  display: flex;
  gap: 1rem;
  min-height: calc(100vh - 140px);
}
.project-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: rgba(251, 253, 255, 0.78);
  border: 1px solid var(--fg-line);
  border-radius: var(--radius);
  padding: .85rem .75rem;
  position: sticky;
  top: 74px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.project-main { flex: 1; min-width: 0; overflow-x: hidden; }

/* Flow header (inside sidebar) */
.project-aside-title { font-family: "Space Grotesk", "Noto Sans SC", sans-serif; font-weight: 800; font-size: 1.05rem; }
.project-aside-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--fg-ink-2);
  background: rgba(16, 179, 211, 0.10);
  border: 1px solid rgba(16, 179, 211, 0.22);
  padding: .25rem .50rem;
  border-radius: 999px;
}
.meta-chip i { opacity: .85; }
.meta-chip.is-warn { background: rgba(245, 165, 36, 0.12); border-color: rgba(245, 165, 36, 0.28); }
.meta-chip.is-ok { background: rgba(20, 184, 106, 0.12); border-color: rgba(20, 184, 106, 0.26); }

/* Flow nav */
.flow-nav {
  list-style: none;
  padding: .85rem 0 0 0;
  margin: .85rem 0 0 0;
  border-top: 1px dashed rgba(91, 107, 132, 0.30);
}
.flow-item { position: relative; }
.flow-link {
  display: grid;
  grid-template-columns: 28px 1fr 18px;
  gap: .65rem;
  align-items: center;
  padding: .55rem .55rem;
  border-radius: 12px;
  color: var(--fg-ink) !important;
  transition: background var(--transition), transform var(--transition), border-color var(--transition);
  border: 1px solid transparent;
}
.flow-link:hover {
  background: rgba(10, 126, 164, 0.06);
  border-color: rgba(10, 126, 164, 0.18);
  transform: translateY(-1px);
}
.flow-marker {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: .85rem;
  color: rgba(11, 18, 32, 0.92);
  background: rgba(215, 224, 234, 0.75);
  border: 1px solid rgba(215, 224, 234, 0.95);
}
.flow-title { font-weight: 800; font-size: .95rem; line-height: 1.1; }
.flow-desc { font-size: .76rem; color: var(--fg-muted); margin-top: .10rem; }
.flow-caret { color: rgba(91,107,132,0.75); }
.flow-item.is-done .flow-marker {
  background: rgba(20, 184, 106, 0.16);
  border-color: rgba(20, 184, 106, 0.30);
  color: #0a3b22;
}
.flow-item.is-active .flow-link {
  background: rgba(16, 179, 211, 0.12);
  border-color: rgba(16, 179, 211, 0.28);
}
.flow-item.is-active .flow-marker {
  background: var(--vivid-grad-2);
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(11, 18, 32, 0.92);
}

/* Mobile: stack layout */
@media (max-width: 992px) {
  .project-layout { flex-direction: column; }
  .project-sidebar { width: 100%; position: relative; top: 0; max-height: none; }
}

/* Annotate sidebar list tweaks (keep existing behavior) */
.annotation-sidebar .list-group .list-group-item,
.image-list-column .list-group .list-group-item {
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  padding: .50rem .65rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--fg-ink) !important;
  background: rgba(255,255,255,0.88) !important;
  border: 1px solid var(--fg-line) !important;
}
.annotation-sidebar .list-group .list-group-item:hover,
.image-list-column .list-group .list-group-item:hover {
  background: rgba(10, 126, 164, 0.05) !important;
  border-color: rgba(10, 126, 164, 0.22) !important;
}
.annotation-sidebar .list-group .list-group-item .text-truncate,
.image-list-column .list-group .list-group-item .text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* Footer */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(251, 253, 255, 0.86);
  border-top: 1px solid var(--fg-line);
  padding: .60rem 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}
footer p { color: var(--fg-muted) !important; font-size: .84rem; margin: 0; }
