/* ============================================================
   MachoFX Journal — App Shared Styles
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-base:        #08080f;
  --bg-surface:     #10101a;
  --bg-raised:      #161625;
  --bg-card:        rgba(22, 22, 37, 0.8);
  --border:         rgba(255,255,255,0.07);
  --border-bright:  rgba(255,255,255,0.12);
  --accent:         #7c3aed;
  --accent-light:   #a855f7;
  --accent-mid:     #9333ea;
  --accent-glow:    rgba(124, 58, 237, 0.35);
  --pink:           #ec4899;
  --green:          #22c55e;
  --green-bg:       rgba(34, 197, 94, 0.1);
  --red:            #ef4444;
  --red-bg:         rgba(239, 68, 68, 0.1);
  --blue:           #3b82f6;
  --blue-bg:        rgba(59, 130, 246, 0.1);
  --orange:         #f97316;
  --orange-bg:      rgba(249, 115, 22, 0.1);
  --yellow:         #eab308;
  --yellow-bg:      rgba(234, 179, 8, 0.1);
  --text-primary:   #f1f0ff;
  --text-secondary: #9898b8;
  --text-muted:     #5a5a7a;
  --sidebar-width:  240px;
  --topbar-height:  64px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  --transition: 0.2s ease;
  --transition-slow: 0.4s ease;
}

[data-theme="light"] {
  --bg-base:        #f4f3ff;
  --bg-surface:     #ffffff;
  --bg-raised:      #ede9fe;
  --bg-card:        rgba(255, 255, 255, 0.95);
  --border:         rgba(0,0,0,0.07);
  --border-bright:  rgba(0,0,0,0.12);
  --text-primary:   #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted:     #888899;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Unbounded', sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.logo-icon { font-size: 22px; }
.logo-accent { color: var(--accent-light); }

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  padding: 8px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 12px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-light);
}
.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  padding: 2px 7px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-user:hover { background: var(--bg-raised); }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-plan { font-size: 11px; color: var(--text-muted); }
.user-chevron { margin-left: auto; color: var(--text-muted); font-size: 12px; }

/* ============================================================
   TOP BAR
============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.page-title-group {}
.page-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.page-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

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

.topbar-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--accent); color: var(--accent-light); }

.date-range-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.date-range-picker:hover { border-color: var(--accent); color: var(--text-primary); }

.theme-toggle {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-light); }

/* ============================================================
   MAIN CONTENT AREA
============================================================ */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================
   STAT CARDS
============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--transition);
  cursor: default;
}
.stat-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stat-value {
  font-family: 'Unbounded', sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}
.stat-change {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 4px;
}
.si-purple { background: rgba(124, 58, 237, 0.15); }
.si-green  { background: var(--green-bg); }
.si-red    { background: var(--red-bg); }
.si-blue   { background: var(--blue-bg); }
.si-orange { background: var(--orange-bg); }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--blue); }

/* ============================================================
   GLASS CARD
============================================================ */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ============================================================
   CHART CARD
============================================================ */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 15px;
  font-weight: 700;
}
.chart-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.chart-controls { display: flex; gap: 4px; align-items: center; }
.chart-control-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.chart-control-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.chart-control-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-body { padding: 0 20px 20px; }

/* ============================================================
   TABLE
============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-raised); color: var(--text-primary); }

.td-symbol {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}
.td-long  { color: var(--green); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.td-short { color: var(--red);   font-weight: 600; font-size: 11px; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-purple { background: rgba(124,58,237,0.15); color: var(--accent-light); }

/* ============================================================
   BUTTONS
============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-light); }

.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  font-size: 16px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent-light); }

/* ============================================================
   FORM ELEMENTS
============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

/* ============================================================
   MODAL
============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-slow);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Unbounded', sans-serif; font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--red); color: var(--red); }

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ============================================================
   GRADIENT TEXT
============================================================ */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 64px; }
  .sidebar { overflow: visible; }
  .nav-item span:not(.nav-icon):not(.nav-badge), .nav-section-label, .user-name, .user-plan, .user-chevron, .sidebar-logo span:not(.logo-icon) { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-user { justify-content: center; }
  .sidebar-header { padding: 16px 8px; justify-content: center; display: flex; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; --topbar-height: 56px; }
  .sidebar { transform: translateX(-100%); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
}
