/* ─── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #07090F;
  --bg2:         #0C0F1A;
  --sidebar:     #0A0D17;
  --card:        rgba(255,255,255,0.03);
  --card-border: rgba(255,255,255,0.07);
  --card-hover:  rgba(255,255,255,0.06);
  --accent:      #00D9FF;
  --accent-dim:  rgba(0,217,255,0.12);
  --accent2:     #6366F1;
  --green:       #10B981;
  --green-dim:   rgba(16,185,129,0.12);
  --red:         #EF4444;
  --red-dim:     rgba(239,68,68,0.12);
  --yellow:      #F59E0B;
  --text:        #E2E8F0;
  --text-muted:  #64748B;
  --text-dim:    #94A3B8;
  --radius:      12px;
  --radius-sm:   8px;
  --sidebar-w:   220px;
  --transition:  0.2s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ─── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ─── LAYOUT ───────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  padding: 24px 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 20px;
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--card-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,217,255,0.15);
}

.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

.sidebar-clock {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-clock .clock-time {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.sidebar-clock .clock-date {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── MAIN CONTENT ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── PAGE HEADER ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ─── CARD ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}

.card:hover { border-color: rgba(255,255,255,0.12); }

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── TICKER TAPE ──────────────────────────────────────────────────────────── */
.ticker-wrap {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  height: 46px;
}

/* ─── INSTRUMENT GRID ──────────────────────────────────────────────────────── */
.instruments-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.instrument-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.instrument-card:hover {
  border-color: rgba(0,217,255,0.2);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.instrument-card-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.instrument-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.instrument-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.instrument-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.instrument-full-name {
  font-size: 11px;
  color: var(--text-muted);
}

.ai-card-body {
  min-height: 150px;
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
}

/* gauge container centers the SVG in the card */
.ai-card-body svg { display: block; margin: 0 auto; }
.ai-card-body ul  { padding-left: 14px !important; list-style: disc !important; }
.ai-card-body li  { color: var(--text-muted); font-size: 10.5px; line-height: 1.7; }

.instrument-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── BADGE / PILL ─────────────────────────────────────────────────────────── */
.badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-up   { background: var(--green-dim); color: var(--green); }
.badge-down { background: var(--red-dim);   color: var(--red); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ─── BTN ──────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: #33E0FF; }

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--card-hover); color: var(--text); }

.btn-danger {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--red);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-ai {
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(0,217,255,0.15));
  border: 1px solid rgba(99,102,241,0.3);
  color: var(--accent);
  font-size: 12px;
  padding: 7px 14px;
}
.btn-ai:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.35), rgba(0,217,255,0.25));
  border-color: var(--accent);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ─── STAT ROW ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

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

/* ─── TABLE ────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table td {
  padding: 13px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}

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

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

.long-pill  { background: var(--green-dim); color: var(--green); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.short-pill { background: var(--red-dim);   color: var(--red);   padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.open-pill  { background: rgba(245,158,11,0.12); color: var(--yellow); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }

/* ─── AI ANALYSIS PANEL ────────────────────────────────────────────────────── */
.ai-panel {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(0,217,255,0.04));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  padding: 20px;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(99,102,241,0.15);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.25);
  color: var(--accent2);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-content {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
}

.ai-content h2, .ai-content h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 6px;
}

.ai-content strong { color: var(--text); }
.ai-content ul { padding-left: 18px; }
.ai-content li { margin-bottom: 4px; }
.ai-content p { margin-bottom: 10px; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(99,102,241,0.3);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── MODAL ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--card-border);
}

/* ─── FORM ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: rgba(0,217,255,0.04);
}

.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── LOGIN ────────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,217,255,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(99,102,241,0.04) 0%, transparent 50%);
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 40px 36px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.login-logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── INSTRUMENT DETAIL ────────────────────────────────────────────────────── */
.instrument-detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

/* Full AI panel on instrument page */
.instrument-ai-full { min-height: 220px; }
.instrument-ai-full ul { padding-left: 16px !important; list-style: disc !important; }
.instrument-ai-full li { font-size: 12px !important; line-height: 1.8; color: var(--text-dim) !important; }

.chart-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ─── EMPTY STATE ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── SENTIMENT GAUGE ─────────────────────────────────────────────────────── */
.sentiment-wrap {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--card-border);
}

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

.sentiment-pct-bull { font-size: 11px; font-weight: 700; color: var(--green); }
.sentiment-pct-bear { font-size: 11px; font-weight: 700; color: var(--red); }

.sentiment-bias-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 2px 7px;
  border-radius: 4px;
}

.sentiment-bias-label.bull { background: var(--green-dim); color: var(--green); }
.sentiment-bias-label.bear { background: var(--red-dim);   color: var(--red); }
.sentiment-bias-label.neut { background: rgba(245,158,11,0.12); color: var(--yellow); }

.sentiment-bar-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
  display: flex;
  gap: 1px;
}

.sentiment-bar-bull {
  height: 100%;
  background: linear-gradient(90deg, #059669, var(--green));
  border-radius: 3px 0 0 3px;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}

.sentiment-bar-bear {
  height: 100%;
  background: linear-gradient(90deg, var(--red), #b91c1c);
  border-radius: 0 3px 3px 0;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}

.sentiment-reason {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sentiment-loading-bar {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(0,217,255,0.15), rgba(99,102,241,0.15));
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── NEWS BLOCK ───────────────────────────────────────────────────────────── */
.news-block {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--card-border);
}

.news-block-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.news-item {
  display: block;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  text-decoration: none;
  transition: opacity var(--transition);
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { opacity: 0.75; }

.news-headline {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.news-meta {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── CALENDAR PAGE ────────────────────────────────────────────────────────── */
.calendar-wrap {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 600px;
}

/* ─── ALERT ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
}
.alert-success { background: var(--green-dim); border: 1px solid rgba(16,185,129,0.2); color: var(--green); }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(239,68,68,0.2);   color: var(--red); }

/* ─── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .instruments-grid { grid-template-columns: repeat(2, 1fr); }
  .instrument-detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 20px 18px; }
}

@media (max-width: 680px) {
  .instruments-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); }
}
