/* ============================================================
   platform.css — Real Capital Partners | Internal Platform
   Extends the dark theme from the main site
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg:          #111111;
  --bg-card:     #1a1a1a;
  --bg-input:    #222222;
  --bg-hover:    #252525;
  --border:      #2e2e2e;
  --border-light:#3a3a3a;
  --text:        #f2f2f2;
  --text-muted:  #888888;
  --text-dim:    #555555;
  --accent:      #8ab4f8;
  --accent-dark: #5a8adb;
  --buy:         #4caf7d;
  --buy-bg:      rgba(76,175,125,0.15);
  --neutral:     #e0b050;
  --neutral-bg:  rgba(224,176,80,0.15);
  --sell:        #e05252;
  --sell-bg:     rgba(224,82,82,0.15);
  --sidebar-w:   220px;
  --header-h:    56px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #0d0d0d;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar__logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar__logo img {
  height: 28px;
  width: auto;
}

.sidebar__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 20px 20px 6px;
}

.sidebar__nav {
  list-style: none;
  padding: 0 10px;
  flex: 1;
}

.sidebar__nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.sidebar__nav li a:hover,
.sidebar__nav li a.active {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar__nav li a.active {
  color: var(--accent);
}

/* Sidebar sub-items (nested menu) */
.sidebar__sub > a {
  padding-left: 36px !important;
  font-size: 12px !important;
}

.sidebar__nav .nav-icon {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar__user {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.btn-signout:hover {
  color: var(--sell);
  border-color: var(--sell);
}

/* ── Main content area ───────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-w));
}

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

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

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

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-grid {
  display: grid;
  gap: 16px;
}

.card-grid--2 { grid-template-columns: repeat(2, 1fr); }
.card-grid--3 { grid-template-columns: repeat(3, 1fr); }
.card-grid--4 { grid-template-columns: repeat(4, 1fr); }

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

.stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card__value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

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

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  font-family: inherit;
  line-height: 1;
}

.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn--secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
}

.btn--danger {
  background: var(--sell-bg);
  color: var(--sell);
  border: 1px solid rgba(224,82,82,0.3);
}

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

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

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 9px 12px;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-input::placeholder { color: var(--text-dim); }
.form-select { appearance: none; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }

.form-error {
  font-size: 12px;
  color: var(--sell);
  margin-top: 4px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

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

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
}

.td-muted { color: var(--text-muted); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge--buy     { background: var(--buy-bg);     color: var(--buy);     }
.badge--neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge--sell    { background: var(--sell-bg);    color: var(--sell);    }

.change-pos { color: var(--buy); }
.change-neg { color: var(--sell); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}

.modal__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal__close {
  position: absolute;
  top: 18px; right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal__close:hover { color: var(--text); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 500;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast--info    { background: #1e3a5f; color: var(--accent); border: 1px solid #2a5080; }
.toast--success { background: #1a3828; color: var(--buy);    border: 1px solid #2a5a3a; }
.toast--error   { background: #3a1a1a; color: var(--sell);   border: 1px solid #5a2a2a; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Section divider ─────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
  margin-bottom: 20px;
}

.tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

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

/* ── Chart container ─────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 240px;
}

/* ── Upload area ─────────────────────────────────────────── */
.upload-zone {
  position: relative;
  overflow: hidden;
  border: 2px dashed var(--border-light);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(138,180,248,0.04);
}

.upload-zone__icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone__text { color: var(--text-muted); font-size: 13px; }
.upload-zone__sub  { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

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

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

.empty-state__icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-state__text { font-size: 14px; }
.empty-state__sub  { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

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

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

.login-card__logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-card__logo img { height: 32px; }

.login-card__title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

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

/* ── MWIR table ──────────────────────────────────────────── */
.mwir-table th { text-align: right; }
.mwir-table th:first-child { text-align: left; }
.mwir-table td { text-align: right; }
.mwir-table td:first-child { text-align: left; font-weight: 600; }

/* ── Market ticker header ────────────────────────────────── */
.market-ticker-bar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: #0a0a0a;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 16px;
  height: 38px;
  flex-shrink: 0;
}

.market-ticker-bar::-webkit-scrollbar { display: none; }

#market-ticker {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  height: 38px;
}

.ticker-item:first-child { padding-left: 0; }
.ticker-item:last-child  { border-right: none; }

.ticker-label {
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.ticker-value {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ticker-change {
  font-size: 11px;
  font-weight: 600;
}

.ticker-pos { color: var(--buy); }
.ticker-neg { color: var(--sell); }

/* Adjust layout when ticker bar exists */
.with-ticker .platform-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.with-ticker .platform-body {
  display: flex;
  flex: 1;
}

.with-ticker .sidebar {
  position: sticky;
  top: 38px;
  height: calc(100vh - 38px);
}

.with-ticker .main-content {
  margin-left: 0;
  padding-top: 28px;
}

/* ── File upload for analyses ────────────────────────────── */
.file-input-wrap {
  position: relative;
}

.file-input-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-input-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px dashed var(--border-light);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  width: 100%;
  justify-content: center;
}

.file-input-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-input-btn.has-file {
  border-color: var(--buy);
  color: var(--buy);
  border-style: solid;
}

.analysis-file-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--accent);
  padding: 3px 8px;
  border: 1px solid rgba(138,180,248,0.25);
  border-radius: 5px;
  text-decoration: none;
  transition: background 0.15s;
}

.analysis-file-link:hover {
  background: rgba(138,180,248,0.08);
  text-decoration: none;
}

/* ── Hamburger (hidden by default, shown on mobile) ─────── */
.hamburger { display: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 56px; overflow: hidden; }
  .sidebar__label,
  .sidebar__nav li a span:not(.nav-icon),
  .sidebar__user,
  .sidebar__footer .btn-signout span { display: none; }
  .main-content { margin-left: 56px; padding: 20px; }
  .card-grid--3, .card-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  html { font-size: 16px; }
  .main-content { padding: 14px; }
  .card-grid--2,
  .card-grid--3,
  .card-grid--4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .market-ticker-bar { height: auto; min-height: 38px; padding: 0 8px; }
  .ticker-item { border-right: none; padding: 2px 8px; }
  /* Inputs: prevent iOS auto-zoom */
  input, select, textarea { font-size: 16px !important; }
  /* Tables: ensure horizontal scroll on small screens */
  [class*="-table-wrap"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Scale large values down slightly */
  .page-title { font-size: 18px; }
  .sum-card__value { font-size: 18px; }
  /* Stack summary cards */
  .summary-cards { flex-direction: column; }
  .sum-card { min-width: 0 !important; flex: 0 0 auto; width: 100%; }
}

@media (max-width: 480px) {
  /* Hamburger button */
  .hamburger {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text);
    font-size: 20px; cursor: pointer; line-height: 1;
    padding: 0 12px; height: 38px; flex-shrink: 0;
  }
  /* Sidebar: hidden off-screen by default, slides in as overlay */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    position: fixed !important;
    width: 220px !important;
    z-index: 200;
    overflow: visible !important;
  }
  /* Restore full sidebar labels inside the drawer */
  .sidebar .sidebar__label,
  .sidebar .sidebar__nav li a span:not(.nav-icon),
  .sidebar .sidebar__user,
  .sidebar .sidebar__footer .btn-signout span { display: initial !important; }
  /* Open state */
  body.sidebar-open .sidebar { transform: translateX(0); }
  /* Backdrop */
  body.sidebar-open::before {
    content: '';
    position: fixed; inset: 0; z-index: 199;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
  }
  /* Full-width main content (no sidebar indent) */
  .main-content { margin-left: 0 !important; max-width: 100vw !important; padding: 12px; }
  .with-ticker .main-content { margin-left: 0 !important; }
}
