/* =============================================
   APP DASHBOARD STYLES
   ============================================= */

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

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200; transition: transform 0.3s ease;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo-text { font-family: var(--font-brand); font-size: 0.85rem; font-weight: 900; }
.sidebar-logo img { height: 28px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
  padding: 12px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: var(--text-secondary);
  font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  border-left: 3px solid transparent; text-decoration: none;
  position: relative;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active { color: var(--gold); background: var(--gold-dim); border-left-color: var(--gold); }
.nav-item-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--gold); color: #000; font-size: 0.65rem; font-weight: 800; padding: 2px 7px; border-radius: 10px; }

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; color: #000; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pkg { font-size: 0.7rem; color: var(--gold); font-weight: 600; }
.sidebar-logout { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 4px; flex-shrink: 0; transition: var(--transition); }
.sidebar-logout:hover { color: var(--red); }

/* MAIN */
#main-area {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}

/* HEADER */
#app-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-page-title { font-family: var(--font-brand); font-size: 0.9rem; font-weight: 700; color: var(--gold); }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.3rem; cursor: pointer; }
.header-search-wrap { position: relative; }
.header-search {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 24px; padding: 8px 16px 8px 36px;
  color: var(--text-primary); font-size: 0.85rem; width: 240px;
  transition: var(--transition); font-family: var(--font-main);
}
.header-search:focus { border-color: var(--gold); width: 300px; outline: none; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; pointer-events: none; }
.search-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; width: 320px;
  background: var(--bg-modal); border: 1px solid var(--gold-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-modal);
  z-index: 500; display: none; max-height: 320px; overflow-y: auto;
}
.search-dropdown.open { display: block; }
.search-result-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:hover { background: var(--gold-dim); }
.search-result-item:last-child { border-bottom: none; }
.search-sym { font-weight: 700; font-size: 0.88rem; }
.search-name { font-size: 0.75rem; color: var(--text-muted); }
.search-exch { font-size: 0.7rem; background: var(--gold-dim); color: var(--gold); padding: 2px 8px; border-radius: 10px; }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-notif { position: relative; background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1.1rem; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: var(--transition); }
.header-notif:hover { background: var(--bg-card); color: var(--text-primary); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; }
.header-pkg-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--gold-dim); border: 1px solid var(--gold-border);
  color: var(--gold); border-radius: 20px; padding: 5px 12px; font-size: 0.75rem; font-weight: 700;
}

/* PAGE CONTENT */
#page-content { flex: 1; padding: 24px; }

/* ---- DASHBOARD ---- */
.dash-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; transition: var(--transition);
  display: flex; flex-direction: column; gap: 8px;
}
.kpi-card:hover { border-color: var(--gold-border); }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-family: var(--font-brand); font-size: 1.5rem; font-weight: 700; }
.kpi-change { font-size: 0.8rem; display: flex; align-items: center; gap: 4px; }

.dash-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.market-overview-table { width: 100%; border-collapse: collapse; }
.market-overview-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.market-overview-table td { padding: 12px 12px; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.market-overview-table tr:last-child td { border-bottom: none; }
.market-overview-table tr { transition: var(--transition); cursor: pointer; }
.market-overview-table tr:hover td { background: var(--gold-dim); }
.tbl-sym { font-weight: 700; }
.tbl-name { color: var(--text-secondary); font-size: 0.78rem; }

/* ---- STOCK VIEW ---- */
.stock-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.stock-title h2 { font-family: var(--font-brand); font-size: 1.4rem; }
.stock-title p { color: var(--text-secondary); font-size: 0.85rem; }
.stock-price-big { font-family: var(--font-brand); font-size: 2.2rem; font-weight: 900; }
.stock-change-big { font-size: 1rem; font-weight: 600; }

.chart-controls { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.period-btn {
  padding: 5px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.period-btn.active, .period-btn:hover { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }

.main-chart-canvas { width: 100%; height: 300px; display: block; border-radius: var(--radius-sm); }

/* ---- AI PANEL ---- */
.ai-panel { background: var(--bg-card); border: 1px solid var(--gold-border); border-radius: var(--radius-lg); padding: 20px; }
.ai-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.ai-panel-icon { font-size: 1.5rem; }
.ai-panel-title { font-family: var(--font-brand); font-size: 0.85rem; color: var(--gold); }
.ai-score-circle {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  position: relative;
}
.ai-score-num { font-family: var(--font-brand); font-size: 1.4rem; font-weight: 900; }
.ai-score-label { font-size: 0.65rem; color: var(--text-muted); }
.ai-recommendation { text-align: center; font-family: var(--font-brand); font-size: 1rem; font-weight: 900; padding: 10px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.ai-signals { display: flex; flex-direction: column; gap: 8px; }
.ai-signal { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8rem; padding: 8px 10px; border-radius: var(--radius-sm); }
.ai-signal.bullish { background: rgba(0,230,118,0.08); border: 1px solid rgba(0,230,118,0.2); }
.ai-signal.bearish { background: rgba(255,61,87,0.08); border: 1px solid rgba(255,61,87,0.2); }
.ai-signal.neutral { background: rgba(255,215,0,0.06); border: 1px solid rgba(255,215,0,0.15); }
.signal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.signal-dot.bullish { background: var(--green); }
.signal-dot.bearish { background: var(--red); }
.signal-dot.neutral { background: var(--gold); }
.signal-label { font-weight: 600; display: block; }
.signal-desc { color: var(--text-muted); font-size: 0.74rem; margin-top: 2px; }

/* ---- WATCHLIST ---- */
.watchlist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: var(--transition);
}
.watchlist-item:last-child { border-bottom: none; }
.watchlist-item:hover { padding-left: 6px; }
.wl-sym { font-weight: 700; font-size: 0.9rem; min-width: 60px; }
.wl-name { font-size: 0.75rem; color: var(--text-muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-price { font-weight: 600; font-size: 0.88rem; text-align: right; }
.wl-change { font-size: 0.78rem; text-align: right; min-width: 60px; }
.wl-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; padding: 4px; opacity: 0; transition: var(--transition); }
.watchlist-item:hover .wl-remove { opacity: 1; }
.wl-remove:hover { color: var(--red); }
.wl-spark { width: 60px; height: 28px; }

/* ---- INDICATORS TABLE ---- */
.indicators-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.ind-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.ind-name { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.ind-value { font-family: var(--font-brand); font-size: 1.1rem; font-weight: 700; }
.ind-signal { font-size: 0.72rem; margin-top: 4px; font-weight: 600; }

/* ---- PACKAGES PAGE ---- */
.pkg-page-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.pkg-page-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: var(--transition); position: relative; }
.pkg-page-card:hover { transform: translateY(-3px); }
.pkg-page-card.current { border-color: var(--gold); box-shadow: var(--shadow-gold); }
.pkg-current-tag { position: absolute; top: -10px; right: 20px; background: var(--gold); color: #000; font-size: 0.65rem; font-weight: 800; padding: 3px 12px; border-radius: 10px; }

/* ---- PROFILE PAGE ---- */
.profile-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; text-align: center; }
.profile-avatar-big { width: 80px; height: 80px; border-radius: 50%; background: linear-gradient(135deg, var(--gold-light), var(--gold-dark)); display: flex; align-items: center; justify-content: center; font-size: 2rem; margin: 0 auto 16px; border: 3px solid var(--gold-border); }
.profile-uid { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); background: var(--bg-input); padding: 6px 12px; border-radius: var(--radius-sm); margin-top: 8px; display: inline-block; }

/* Mobile */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-area { margin-left: 0; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .header-search { width: 160px; }
  .header-search:focus { width: 200px; }
  #page-content { padding: 16px; }
  .dash-overview { grid-template-columns: repeat(2, 1fr); }
  .header-pkg-badge { display: none; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199; }
.sidebar-overlay.show { display: block; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* Loading overlay */
.page-loader { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 18px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; transition: var(--transition); font-family: var(--font-main); }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s ease; }
