/* ============================================================
   Axel Trader — Custom CSS
   Dark trading terminal theme
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --bg:           #0d0d0d;
  --surface:      #141414;
  --surface-2:    #1a1a1a;
  --border:       #1e1e1e;
  --border-2:     #2a2a2a;
  --accent:       #00e5ff;
  --accent-dim:   rgba(0, 229, 255, 0.12);
  --accent-hover: rgba(0, 229, 255, 0.08);
  --green:        #00e676;
  --green-dim:    rgba(0, 230, 118, 0.12);
  --red:          #ff1744;
  --red-dim:      rgba(255, 23, 68, 0.12);
  --text:         #e0e0e0;
  --text-dim:     #808080;
  --text-muted:   #4a4a4a;
  --sidebar-w:    200px;
}

/* ── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  height: 100%;
  overflow-x: hidden;
}

/* ── Custom Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: #2a2a2a var(--surface); }

/* ── Layout Shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  box-shadow: 0 0 8px rgba(0,229,255,0.3);
}

.sidebar-logo span {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0,229,255,0.5);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-link:hover {
  color: var(--text);
  background: var(--accent-hover);
  border-left-color: var(--accent);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

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

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
  opacity: 1;
}

/* ── Main Area ──────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.topbar {
  height: 52px;
  min-height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 40;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

.topbar-title span {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Content Area ───────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

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

.card-body {
  padding: 16px;
}

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
}

.stat-card.green::before { background: var(--green); }
.stat-card.red::before   { background: var(--red); }
.stat-card.cyan::before  { background: var(--accent); }

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

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 4px;
}

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

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

table.data-table thead tr {
  border-bottom: 1px solid var(--border-2);
}

table.data-table thead th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

table.data-table thead th.text-right { text-align: right; }

table.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

table.data-table tbody tr:hover {
  background: var(--accent-hover);
}

table.data-table tbody td {
  padding: 9px 12px;
  color: var(--text);
  white-space: nowrap;
}

table.data-table tbody td.text-right { text-align: right; }
table.data-table tbody td.text-center { text-align: center; }

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

/* Positive / Negative cell values */
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted    { color: var(--text-dim) !important; }
.accent   { color: var(--accent) !important; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.badge-buy {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.badge-sell {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 23, 68, 0.3);
}

.badge-hold {
  background: rgba(128, 128, 128, 0.12);
  color: #808080;
  border: 1px solid rgba(128, 128, 128, 0.25);
}

.badge-us {
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 255, 0.25);
}

.badge-asx {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.25);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(255, 23, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 23, 68, 0.2);
  border-color: var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-2);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-logout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-2);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
}

.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-dim);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

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

.form-input,
.form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease;
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23808080' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* ── Alerts / Messages ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 14px;
}

.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(255, 23, 68, 0.3);
  color: var(--red);
}

.alert-success {
  background: var(--green-dim);
  border: 1px solid rgba(0, 230, 118, 0.3);
  color: var(--green);
}

.alert-info {
  background: var(--accent-dim);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--accent);
}

/* ── Chart Container ────────────────────────────────────────── */
.chart-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px - 80px);
  min-height: 500px;
}

#candlestick-chart {
  flex: 7;
  min-height: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-2);
}

#rsi-chart {
  flex: 3;
  min-height: 0;
  background: var(--surface);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.chart-symbol-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.chart-price-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ── Page Sections ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

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

/* ── Summary Grid ───────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.15s ease;
}

.page-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.page-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.pagination-info {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.05);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 20px rgba(0,229,255,0.3);
  margin-bottom: 10px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 15px rgba(0,229,255,0.5);
  margin: 0 0 4px;
}

.login-logo p {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin: 0;
}

/* ── Inline Indicators ──────────────────────────────────────── */
.change-positive {
  color: var(--green);
  font-weight: 600;
}

.change-negative {
  color: var(--red);
  font-weight: 600;
}

.symbol-chip {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* ── No Data State ──────────────────────────────────────────── */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 13px;
  margin: 0;
}

/* ── Dividers ───────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── RSI Colour Helpers ─────────────────────────────────────── */
.rsi-overbought { color: var(--red); }
.rsi-oversold   { color: var(--green); }
.rsi-neutral    { color: var(--text-dim); }

/* ── Target Price Badge ─────────────────────────────────────── */
.target-hit {
  color: var(--green);
  font-weight: 700;
}

.target-miss {
  color: var(--text-dim);
}

/* ── Refresh btn animation ──────────────────────────────────── */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tooltip ────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
  cursor: default;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── Misc ───────────────────────────────────────────────────── */
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.text-xs    { font-size: 10px; }
.text-sm    { font-size: 11px; }
.text-mono  { font-family: 'Courier New', monospace; }
.font-bold  { font-weight: 700; }
.font-semi  { font-weight: 600; }
.uppercase  { text-transform: uppercase; letter-spacing: 0.5px; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
