/* ============================================================
   COMPONENTS.CSS — nav, cards, buttons, forms, tabs, tables
   ============================================================ */

/* ---- Global Navigation ---- */
.global-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 100;
  background: rgba(251, 249, 247, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}

.global-nav-inner {
  max-width: var(--nav-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 48px;
  display: flex;
  align-items: center;
  gap: 48px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--accent);
  font-family: "Noto Serif SC", "Noto Serif", "Bodoni Moda", "Songti SC", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: opacity 200ms ease;
}

.nav-brand:hover { opacity: 0.65; }

.nav-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7a583b, #6c4c30);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(196, 137, 108, 0.28);
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 200ms ease;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(15, 20, 40, 0.04);
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

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

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.nav-mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.nav-mobile-toggle:hover {
  background: rgba(15, 20, 40, 0.05);
}

/* ---- Card System ---- */
.hero-panel,
.card,
.sub-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 24px 48px rgba(15, 20, 40, 0.06),
    0 2px 6px rgba(15, 20, 40, 0.03);
}

.hero-panel {
  padding: 26px;
  margin-bottom: 16px;
  background:
    linear-gradient(125deg, var(--accent-soft), var(--card) 50%, var(--accent-2-soft)),
    var(--card);
  animation: revealUp 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card {
  margin-bottom: 14px;
  padding: 28px 24px;
  animation: revealUp 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 280ms ease, box-shadow 280ms ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 32px 64px rgba(15, 20, 40, 0.08),
    0 4px 12px rgba(15, 20, 40, 0.04);
}

.card-elevated {
  background: var(--card-elevated);
}

.card-accent {
  background:
    linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0.9)),
    var(--card);
  border-color: rgba(196, 137, 108, 0.2);
}

/* ---- Buttons ---- */
.btn-primary,
.btn-secondary {
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 240ms ease;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-ambient);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  color: var(--accent-text);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: none;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--accent-2-soft);
  color: var(--accent-2-hover);
  border: none;
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(249, 221, 200, 0.7);
  color: var(--accent);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-btn);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms ease;
}

.btn-ghost:hover {
  background: rgba(15, 20, 40, 0.05);
  color: var(--text);
}

.btn-large {
  padding: 13px 28px;
  font-size: 16px;
  border-radius: 16px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 10px;
}

/* Shell buttons (fallback for plain <button> inside .shell) */
.shell button {
  border: none;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: var(--accent-text);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 240ms ease;
  box-shadow: 0 8px 24px rgba(196, 137, 108, 0.25);
}

.shell button:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.shell button:active { transform: scale(0.98); }
.shell button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shell button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- Forms ---- */
.shell select,
.shell textarea,
.shell input[type="text"],
.shell input[type="password"],
.shell input[type="email"],
.shell input[type="number"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  padding: 10px 13px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  transition: border-color 200ms ease, box-shadow 200ms ease;
  outline: none;
}

.shell select:focus,
.shell textarea:focus,
.shell input:focus {
  border-color: rgba(196, 137, 108, 0.5);
  box-shadow: 0 0 0 3px rgba(196, 137, 108, 0.10);
}

.shell textarea {
  min-height: 132px;
  line-height: 1.7;
  resize: vertical;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* ---- Badges ---- */
.feature-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  align-self: flex-start;
}

.feature-badge-muted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  background: var(--bg-depth);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  align-self: flex-start;
  border: 1px solid var(--line);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}

.status-badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge-gold {
  background: var(--gold-soft);
  color: #8a6830;
}

/* ---- Section Headers ---- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 24px);
  font-weight: 700;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.section-head-center {
  text-align: center;
  margin-bottom: 32px;
}

.section-head-center h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 42px);
}

/* ---- Stat Cards ---- */
.stat-card {
  background: var(--card-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 20, 40, 0.05);
  transition: transform 320ms ease, box-shadow 320ms ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(15, 20, 40, 0.09);
}

.stat-card-accent {
  background: linear-gradient(135deg, var(--accent-soft), rgba(201, 169, 110, 0.06));
  border-color: rgba(196, 137, 108, 0.2);
}

.stat-number {
  font-family: "Bodoni Moda", "Songti SC", serif;
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.stat-card-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
  background: var(--card-elevated);
  transition: all 240ms ease;
}

.stat-card-inline:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 20, 40, 0.06);
}

.stat-card-primary {
  background: linear-gradient(135deg, var(--accent-soft), var(--gold-soft));
  border-color: rgba(196, 137, 108, 0.2);
}

.stat-icon {
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  color: var(--accent);
}

.stat-value {
  font-family: "Bodoni Moda", "Songti SC", serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-label-inline {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---- Suggestion Cards ---- */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 4px;
}

.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-inner);
  background: var(--card-elevated);
  transition: all 240ms ease;
}

.suggestion-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 20, 40, 0.07);
  border-color: rgba(196, 137, 108, 0.25);
}

.suggestion-icon {
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  color: var(--accent);
}

.suggestion-content { flex: 1; }

.suggestion-label {
  font-size: 11px;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  font-weight: 600;
}

.suggestion-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

/* ---- Feature Cards ---- */
.feature-grid-v2 {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.feature-card-v2 {
  position: relative;
  padding: 32px 28px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: var(--card-elevated);
  transition: all 280ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.feature-card-v2::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-soft), transparent 60%);
  opacity: 0;
  transition: opacity 280ms ease;
}

.feature-card-v2:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 56px rgba(15, 20, 40, 0.10);
  border-color: rgba(196, 137, 108, 0.25);
}

.feature-card-v2:hover::before { opacity: 1; }

.feature-card-primary {
  background: linear-gradient(135deg, var(--accent-soft), var(--gold-soft));
  border-color: rgba(196, 137, 108, 0.22);
}

.feature-card-primary .feature-icon { color: var(--accent); }
.feature-card-secondary .feature-icon { color: var(--accent-2); }

.feature-icon {
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
  color: var(--accent);
}

.feature-card-v2 h3 {
  margin: 0 0 8px;
  font-size: 22px;
  position: relative;
  z-index: 1;
}

.feature-card-v2 p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  position: relative;
  z-index: 1;
  flex: 1;
}

/* ---- Tabs ---- */
.tab-bar {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--bg-depth);
  border-radius: var(--radius-inner);
  border: 1px solid var(--line);
  width: fit-content;
  margin-bottom: 28px;
}

.tab-btn {
  padding: 8px 20px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 220ms ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(196, 137, 108, 0.25);
}

.tab-content {
  animation: tabFadeIn 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---- Data Table ---- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--subtle);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}

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

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
  background: rgba(196, 137, 108, 0.04);
}

/* Grade chips */
.grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  font-family: "Bodoni Moda", serif;
}

.grade-A { background: var(--success-soft); color: var(--success); }
.grade-B { background: var(--gold-soft); color: #7a5c20; }
.grade-C { background: var(--warning-soft); color: #8a5a1a; }
.grade-D { background: var(--danger-soft); color: var(--danger); }

/* ---- Text link ---- */
.text-link {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid rgba(61, 90, 128, 0.35);
  padding-bottom: 1px;
  font-weight: 600;
  transition: border-color 200ms ease, color 200ms ease;
}

.text-link:hover {
  color: var(--accent-2-hover);
  border-color: var(--accent-2);
}

/* ---- Progress Bar ---- */
.progress-bar {
  height: 6px;
  background: var(--bg-depth);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 400ms ease;
}

.progress-fill-success { background: linear-gradient(90deg, var(--success), #5bc49a); }
.progress-fill-danger  { background: linear-gradient(90deg, var(--danger), #e8756e); }

/* ---- Mobile Responsive ---- */
@media (max-width: 920px) {
  .feature-grid-v2 { grid-template-columns: 1fr 1fr; }
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .global-nav-inner { padding: 0 16px; gap: 16px; }

  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(250, 251, 253, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 16px;
    gap: 4px;
  }

  .nav-menu.open { display: flex; }
  .nav-link { padding: 10px 14px; border-radius: var(--radius-inner); min-height: 44px; display: flex; align-items: center; }
  .nav-mobile-toggle { display: flex; }

  .feature-grid-v2 { grid-template-columns: 1fr; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 20px 16px; }
  .stat-number { font-size: 36px; }

  .tab-bar { overflow-x: auto; width: 100%; }
  .tab-btn { white-space: nowrap; min-height: 44px; }

  .card { padding: 20px 16px; }
  .hero-panel { padding: 20px 16px; }
}
