/* ── App-wide styles (portfolio input, dashboard, advisor) ── */

/* Shared nav */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-brand .gold { color: var(--gold); }

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

.nav-link {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-link:hover { color: var(--fg); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--gold); background: var(--gold-glow); }

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 10px 20px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-gold {
  background: var(--gold);
  color: #0a0f1a;
}

.btn-gold:hover {
  background: #e0b75e;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 168, 83, 0.3);
}

.btn-outline {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-outline:hover {
  color: var(--fg);
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.04);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  padding: 8px 12px;
}

.btn-ghost:hover { color: var(--fg); background: rgba(255,255,255,0.05); }

.btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.25);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.5); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* App page wrapper */
.app-page {
  min-height: calc(100vh - 60px);
  padding: 40px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.app-page-wide {
  min-height: calc(100vh - 60px);
  max-width: 1400px;
  margin: 0 auto;
}

/* Page header */
.page-header {
  margin-bottom: 36px;
}

.page-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 8px;
}

.page-header p {
  color: var(--fg-muted);
  font-size: 1rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 28px;
}

.card-sm { padding: 20px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

/* Form elements */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-input, .form-select {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  appearance: none;
}

.form-input::placeholder { color: rgba(255,255,255,0.25); }

.form-input:focus, .form-select:focus {
  border-color: var(--gold);
  background: rgba(212, 168, 83, 0.05);
}

/* Ticker input special styling */
.ticker-input {
  text-transform: uppercase;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 1px;
}

/* Holdings table */
.holdings-table {
  width: 100%;
  border-collapse: collapse;
}

.holdings-table th {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.holdings-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.93rem;
  vertical-align: middle;
}

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

.holdings-table tr:hover td { background: rgba(255,255,255,0.02); }

.ticker-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.company-name {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 2px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--fg);
}

.empty-state p {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Health score ring */
.health-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.health-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.health-ring svg {
  transform: rotate(-90deg);
}

.health-ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 8;
}

.health-ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.health-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.health-ring-num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.health-ring-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Priority tags */
.priority-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

.priority-high { background: rgba(239,68,68,0.15); color: #f87171; }
.priority-medium { background: rgba(212,168,83,0.15); color: var(--gold); }
.priority-low { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* Recommendation card */
.rec-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.rec-card + .rec-card { margin-top: 10px; }

.rec-content { flex: 1; }

.rec-title {
  font-family: var(--font-display);
  font-size: 0.93rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.rec-desc {
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

.dashboard-grid-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Advisor chat */
.advisor-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.advisor-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid rgba(255,255,255,0.07);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.advisor-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 75%;
  animation: fadeUp 0.25s ease;
}

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

.chat-msg-user { align-self: flex-end; }
.chat-msg-assistant { align-self: flex-start; }

.chat-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.93rem;
  line-height: 1.65;
}

.chat-msg-user .chat-bubble {
  background: var(--gold);
  color: #0a0f1a;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.chat-msg-assistant .chat-bubble {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--fg);
  border-bottom-left-radius: 4px;
  white-space: pre-wrap;
}

.chat-meta {
  font-size: 0.72rem;
  color: var(--fg-muted);
  margin-top: 5px;
  padding: 0 4px;
}

.chat-msg-user .chat-meta { text-align: right; }

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-muted);
  animation: typingBounce 1.2s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
  padding: 16px 24px;
  background: var(--bg-surface);
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.93rem;
  padding: 11px 14px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.chat-textarea:focus { border-color: var(--gold); }
.chat-textarea::placeholder { color: rgba(255,255,255,0.25); }

/* Section labels */
.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

/* Stat row in dashboard sidebar */
.sidebar-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.88rem;
}

.sidebar-stat:last-child { border-bottom: none; }

.sidebar-stat-label { color: var(--fg-muted); }

.sidebar-stat-val {
  font-family: var(--font-display);
  font-weight: 600;
}

.sidebar-stat-val.positive { color: #4ade80; }
.sidebar-stat-val.negative { color: #f87171; }

/* Analysis section tabs */
.analysis-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 4px;
}

.analysis-tab {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--fg-muted);
  border: none;
  background: transparent;
  transition: all 0.2s;
}

.analysis-tab.active {
  background: var(--bg-card);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.analysis-panel { display: none; }
.analysis-panel.active { display: block; }

.analysis-text {
  color: var(--fg-muted);
  font-size: 0.93rem;
  line-height: 1.75;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px 18px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--fg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { border-left: 3px solid #4ade80; }
.toast-error { border-left: 3px solid #f87171; }
.toast-info { border-left: 3px solid var(--gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Add holding form inline row */
.add-row {
  display: grid;
  grid-template-columns: 100px 1fr 110px 130px auto;
  gap: 10px;
  align-items: end;
}

/* Responsive */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .advisor-layout { grid-template-columns: 1fr; }
  .advisor-sidebar { display: none; }
  .add-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .app-page { padding: 20px 16px; }
  .add-row { grid-template-columns: 1fr; }
  .nav-links .nav-link span { display: none; }
}
