/*
Theme Name: Apex Charts
Theme URI: https://example.com/apex-charts
Author: Apex Charts
Author URI: https://example.com
Description: Premium, ad-free financial charting terminal theme inspired by professional trading platforms. Dark modern UI with interactive candlestick charts, watchlist, timeframes and market overview. No ads. No subscription required.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: apex-charts
Tags: custom-background, custom-colors, custom-logo, custom-menu, featured-images, full-width-template, theme-options, translation-ready, dark, finance, charts
*/

/* =========================================================
   Apex Charts — Premium Terminal Theme
   ========================================================= */

:root {
  --bg-deep: #0b0e11;
  --bg-panel: #12161c;
  --bg-elevated: #1a1f27;
  --bg-hover: #222831;
  --border: #2a313c;
  --border-subtle: #1e242d;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #6b7280;
  --accent: #2962ff;
  --accent-hover: #1e4bd8;
  --green: #26a69a;
  --red: #ef5350;
  --yellow: #f0b90b;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html {
  height: 100%;
}

body.apex-charts-theme,
body.page-template-template-apex-charts {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  margin: 0 !important;
}

/* Hide default WP admin bar spacing when full-screen terminal is active */
body.apex-charts-theme.admin-bar,
body.page-template-template-apex-charts.admin-bar {
  padding-top: 0 !important;
}

body.apex-charts-theme #wpadminbar,
body.page-template-template-apex-charts #wpadminbar {
  display: none !important;
}

/* ========== APP SHELL ========== */
.apex-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* ========== TOP BAR ========== */
.apex-topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.apex-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
  text-decoration: none;
  color: inherit;
}

.apex-logo-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #2962ff, #7c4dff);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: white;
}

.apex-logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.apex-logo-text span {
  color: var(--text-secondary);
  font-weight: 500;
}

.apex-search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.apex-search-box input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.apex-search-box input:focus {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.apex-search-box input::placeholder {
  color: var(--text-muted);
}

.apex-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.apex-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}

.apex-search-results.visible {
  display: block;
}

.apex-search-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: background 0.1s;
}

.apex-search-item:hover {
  background: var(--bg-hover);
}

.apex-search-item .sym {
  font-weight: 600;
  font-family: var(--mono);
}

.apex-search-item .name {
  color: var(--text-secondary);
  font-size: 12px;
}

.apex-top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.apex-btn-ghost {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.apex-btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.apex-btn-ghost svg {
  width: 16px;
  height: 16px;
}

.apex-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(41, 98, 255, 0.15), rgba(124, 77, 255, 0.15));
  border: 1px solid rgba(41, 98, 255, 0.3);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #8ab4ff;
}

.apex-status-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
}

/* ========== MAIN LAYOUT ========== */
.apex-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Toolbar */
.apex-toolbar {
  width: 48px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  flex-shrink: 0;
}

.apex-tool {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.apex-tool svg {
  width: 18px;
  height: 18px;
}

.apex-tool:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.apex-tool.active {
  background: rgba(41, 98, 255, 0.15);
  color: var(--accent);
}

.apex-tool-divider {
  width: 24px;
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Chart Area */
.apex-chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-deep);
}

.apex-chart-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.apex-symbol-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.apex-symbol-info h1 {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-primary);
}

.apex-exchange {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.apex-price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: 8px;
}

.apex-price {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--mono);
}

.apex-change {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--mono);
}

.apex-change.up { color: var(--green); }
.apex-change.down { color: var(--red); }

.apex-timeframes {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.apex-timeframes button {
  padding: 5px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
}

.apex-timeframes button:hover {
  color: var(--text-primary);
}

.apex-timeframes button.active {
  background: var(--accent);
  color: white;
}

.apex-chart-controls {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.apex-btn-sm {
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.apex-btn-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.apex-btn-sm.active {
  background: rgba(41, 98, 255, 0.15);
  border-color: rgba(41, 98, 255, 0.4);
  color: #8ab4ff;
}

.apex-chart-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

.apex-chart-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.apex-status-bar {
  display: flex;
  gap: 8px;
  font-family: var(--mono);
}

.apex-sep {
  opacity: 0.4;
}

.apex-attribution {
  font-size: 11px;
  opacity: 0.7;
}

/* Sidebar */
.apex-sidebar {
  width: 280px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.apex-sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.apex-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.apex-section-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0;
}

.apex-icon-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.apex-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.apex-watchlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.apex-watch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.apex-watch-item:hover,
.apex-watch-item.active {
  background: var(--bg-hover);
}

.apex-watch-item .left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.apex-watch-item .sym {
  font-weight: 600;
  font-size: 13px;
  font-family: var(--mono);
}

.apex-watch-item .name {
  font-size: 11px;
  color: var(--text-muted);
}

.apex-watch-item .right {
  text-align: right;
}

.apex-watch-item .px {
  font-size: 13px;
  font-family: var(--mono);
  font-weight: 500;
}

.apex-watch-item .chg {
  font-size: 11px;
  font-family: var(--mono);
}

.apex-watch-item .chg.up { color: var(--green); }
.apex-watch-item .chg.down { color: var(--red); }

.apex-market-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apex-market-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.apex-market-card .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.apex-market-card .val {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
}

.apex-market-card .val.up { color: var(--green); }
.apex-market-card .val.down { color: var(--red); }

.apex-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.apex-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.apex-stat .value {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--mono);
}

/* Scrollbar */
.apex-sidebar::-webkit-scrollbar {
  width: 6px;
}
.apex-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.apex-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.apex-sidebar::-webkit-scrollbar-thumb:hover {
  background: #3a4250;
}

/* Responsive */
@media (max-width: 1100px) {
  .apex-sidebar {
    width: 240px;
  }
}

@media (max-width: 900px) {
  .apex-sidebar {
    display: none;
  }
  .apex-toolbar {
    width: 42px;
  }
}

@media (max-width: 600px) {
  .apex-chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .apex-chart-controls {
    margin-left: 0;
  }
  .apex-search-box {
    max-width: none;
  }
}

/* Light theme support (optional) */
body.apex-light-theme {
  --bg-deep: #f5f7fa;
  --bg-panel: #ffffff;
  --bg-elevated: #f0f2f5;
  --bg-hover: #e8eaed;
  --border: #d1d5db;
  --border-subtle: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
}

/* Loading spinner for live data */
.apex-loading .apex-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #2a313c;
  border-top-color: #2962ff;
  border-radius: 50%;
  animation: apex-spin 0.7s linear infinite;
}
@keyframes apex-spin {
  to { transform: rotate(360deg); }
}
.apex-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #26a69a;
  margin-left: 8px;
}
