/* ============================
   MARKETSCOPE — styles.css
   ============================ */

:root {
  --bg:        #f8fafc;
  --surface:   #ffffff;
  --card:      #f1f5f9;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #2563eb;
  --accent-lt: #60a5fa;
  --green:     #16a34a;
  --red:       #dc2626;
  --nav-h:     60px;
  --sidebar-w: 220px;
}

/* ----------------------------
   RESET / BASE
---------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding-top: var(--nav-h);
  font-family: "Google Sans", "Product Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ----------------------------
   NAVBAR
---------------------------- */
.navbar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  background: linear-gradient(90deg, var(--nav-from, #1e3a8a), var(--accent, #2563eb), var(--nav-to, #60a5fa));
  color: white !important;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.nav-brand {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-right: 0;
  white-space: nowrap;
  color: white !important;
  padding: 8px 14px;
  border-radius: 6px;
  user-select: none;
  transition: background 0.15s;
}
.nav-brand:hover { background: rgba(255,255,255,0.15); }

.nav-item {
  position: relative;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 6px;
  user-select: none;
  transition: background 0.15s;
  color: white !important;
}
.nav-item:hover { background: rgba(255,255,255,0.15); }

/* dropdown */
.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  color: var(--text) !important;
  min-width: 230px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  overflow: hidden;
  z-index: 10000;
  border: 1px solid var(--border);
}

.dropdown div {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s;
  color: var(--text) !important;
}
.dropdown div:hover { background: var(--card); }

/* ----------------------------
   LAYOUT (sidebar + main)
---------------------------- */
.layout {
  display: flex;
  min-height: calc(100vh - var(--nav-h));
}

/* LEFT SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: white;
  min-height: calc(100vh - var(--nav-h));
  position: fixed;
  left: 0;
  top: var(--nav-h);
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-item {
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  border-radius: 8px;
  background: #1e293b;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
  color: white;
}
.sidebar-item:hover  { background: #334155; }
.sidebar-item.active { background: var(--accent); }

/* MAIN CONTENT */
.main {
  margin-left: var(--sidebar-w);
  padding: 24px;
  width: 100%;
  min-width: 0;
}

/* ----------------------------
   HOMEPAGE GRID
---------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 4px 20px 20px 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* ----------------------------
   SECTION TITLE
---------------------------- */
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 20px 20px 16px;
}

/* ----------------------------
   BUTTON
---------------------------- */
.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 11px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
  text-decoration: none;
}
.button:hover { background: #1d4ed8; }

/* ----------------------------
   CHART AREA
---------------------------- */
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

/* TradingView container */
#tradingview_chart {
  width: 100%;
  min-height: 500px;
}

/* Historical canvas */
#historyChart {
  width: 100% !important;
  max-height: 480px;
  display: block;
}

/* ----------------------------
   EVENT / NEWS PANEL
---------------------------- */
.news-container {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
}

.news-box {
  flex: 1 1 200px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 18px 20px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  border: 2px solid transparent;
}
.news-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}
.news-box.active-event {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.35);
}

.news-date {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}

/* ----------------------------
   SECTOR PAGE
---------------------------- */
.sector-hero {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  border-radius: 14px;
  padding: 32px;
  margin-bottom: 24px;
}
.sector-hero h1 { margin: 0 0 8px; font-size: 28px; }
.sector-hero p  { margin: 0; opacity: 0.85; font-size: 15px; }

/* ----------------------------
   UTILITY
---------------------------- */
.tag {
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.up   { color: var(--green); font-weight: 600; }
.down { color: var(--red);   font-weight: 600; }

/* ----------------------------
   NAVBAR SEARCH
---------------------------- */
.nav-search {
  margin-left: auto;
  position: relative;
}

.nav-search-input {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 7px 16px;
  color: white;
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: background 0.2s, width 0.2s;
}
.nav-search-input::placeholder { color: rgba(255,255,255,0.6); }
.nav-search-input:focus {
  background: rgba(255,255,255,0.25);
  width: 280px;
}

.nav-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  min-width: 380px;
  z-index: 10000;
  overflow: hidden;
}

.search-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: var(--card); }

.search-result-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-result-ticker {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}

.search-result-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.search-result-sector {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 12px;
}

.search-result-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ----------------------------
   DARK MODE
---------------------------- */
[data-theme="dark"] {
  --bg:      #0f172a;
  --surface: #1e293b;
  --card:    #293548;
  --border:  #334155;
  --text:    #f1f5f9;
  --muted:   #94a3b8;
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .section-title {
  color: var(--text);
}

[data-theme="dark"] .chart-box {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .news-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .news-card-headline {
  color: var(--text);
}

[data-theme="dark"] .holdings-card,
[data-theme="dark"] .add-form,
[data-theme="dark"] .summary-card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] table thead th {
  background: var(--card);
  color: var(--muted);
}

[data-theme="dark"] tbody tr:hover {
  background: var(--card);
}

[data-theme="dark"] tbody td {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .add-form-group input,
[data-theme="dark"] .form-group input {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .dropdown {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .dropdown div {
  color: var(--text);
}

[data-theme="dark"] .dropdown div:hover {
  background: var(--card);
}

[data-theme="dark"] .hero-search-results,
[data-theme="dark"] .nav-search-results {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .hero-search-row,
[data-theme="dark"] .search-result-row {
  border-color: var(--border);
}

[data-theme="dark"] .hero-search-row:hover,
[data-theme="dark"] .search-result-row:hover {
  background: var(--card);
}

[data-theme="dark"] .hero-search-name,
[data-theme="dark"] .search-result-name {
  color: var(--text);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2 {
  color: var(--text);
}

[data-theme="dark"] .filter-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .filter-btn:hover {
  background: var(--card);
}
[data-theme="dark"] .filter-btn.active {
  background: var(--accent);
  color: white;
}

[data-theme="dark"] .sidebar {
  background: #0a0f1e;
}