/* ===================================================
   Investment Dashboard - Shared Styles
   RTL Hebrew, Professional Finance Design
   =================================================== */

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

:root {
  /* Brand Colors */
  --primary: #1a56db;
  --primary-light: #3b7ef5;
  --primary-dark: #1040b0;
  --accent: #0ea5e9;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Dark Theme (default) */
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card2: #263044;
  --bg-hover: #334155;
  --border: #334155;
  --border-light: #475569;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);

  /* Fonts */
  --font: 'Heebo', 'Arial', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card2: #f8fafc;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { direction: rtl; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

/* ── Typography ── */
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ── KPI Cards ── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 4px; height: 100%; border-radius: 0 var(--radius) var(--radius) 0;
}
.kpi-card.positive::before { background: var(--success); }
.kpi-card.negative::before { background: var(--danger); }
.kpi-card.neutral::before { background: var(--primary); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.kpi-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; margin-top: 6px; }
.kpi-badge.up { background: rgba(16,185,129,0.15); color: var(--success); }
.kpi-badge.down { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--bg-card2); border-radius: var(--radius); padding: 4px; flex-wrap: wrap; }
.tab-btn {
  flex: 1; padding: 10px 16px; border: none; border-radius: calc(var(--radius) - 4px);
  background: transparent; color: var(--text-muted); font-family: var(--font);
  font-size: 0.88rem; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { background: var(--bg-card2); padding: 12px 16px; text-align: right; font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: left; font-feature-settings: 'tnum'; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-primary { background: rgba(26,86,219,0.15); color: var(--primary-light); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-neutral { background: var(--bg-card2); color: var(--text-muted); }

/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card2);
  color: var(--text); font-family: var(--font); font-size: 0.9rem;
  transition: border-color 0.2s; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.15); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
.form-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

/* ── Grid ── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Layout ── */
.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.section { margin-bottom: 32px; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.font-bold { font-weight: 700; }
.font-mono { font-feature-settings: 'tnum'; }

/* ── Navbar ── */
.navbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.navbar-logo { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 800; color: #fff; }
.navbar-name { font-weight: 700; font-size: 1.1rem; }
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.navbar-client-name { font-size: 0.88rem; color: var(--text-muted); font-weight: 500; padding: 6px 12px; background: var(--bg-card2); border-radius: 20px; }

/* ── Theme Toggle ── */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card2); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all 0.2s; color: var(--text);
}
.theme-toggle:hover { background: var(--bg-hover); }

/* ── Sparkline ── */
.sparkline-wrap { position: relative; height: 40px; }

/* ── Tooltip ── */
.tooltip-trigger { position: relative; cursor: help; }
.tooltip-box {
  position: absolute; bottom: 100%; right: 0; z-index: 200;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 0.82rem; color: var(--text); white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transform: translateY(4px); transition: all 0.15s;
  min-width: 200px;
}
.tooltip-trigger:hover .tooltip-box { opacity: 1; transform: translateY(0); }

/* ── Progress Bar ── */
.progress { height: 6px; background: var(--bg-card2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.6s; }
.progress-bar.up { background: var(--success); }
.progress-bar.down { background: var(--danger); }
.progress-bar.primary { background: var(--primary); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto;
  transform: scale(0.95); transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-close { font-size: 1.2rem; cursor: pointer; color: var(--text-muted); background: none; border: none; padding: 4px; }

/* ── Heatmap ── */
.heatmap-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.heatmap-table th { padding: 8px 10px; text-align: center; font-weight: 600; color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.heatmap-table td { padding: 6px 8px; text-align: center; border-radius: 4px; font-weight: 600; font-size: 0.78rem; cursor: default; transition: transform 0.15s; white-space: nowrap; }
.heatmap-table td:hover { transform: scale(1.05); z-index: 1; position: relative; }
.hm-label { text-align: right !important; font-weight: 600; color: var(--text); background: transparent !important; font-size: 0.75rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Timeline ── */
.timeline { position: relative; padding-right: 24px; }
.timeline::before { content: ''; position: absolute; right: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; padding-right: 20px; }
.timeline-dot { position: absolute; right: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg-card); }
.timeline-date { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.timeline-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.timeline-desc { font-size: 0.82rem; color: var(--text-muted); }

/* ── Loading ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; flex-direction: column; gap: 12px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert ── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 500; display: flex; align-items: flex-start; gap: 10px; }
.alert-info { background: rgba(26,86,219,0.1); border: 1px solid rgba(26,86,219,0.3); color: var(--primary-light); }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  html { font-size: 15px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .navbar { padding: 0 16px; }
  .container { padding: 0 12px; }
  .card { padding: 16px; }
  .kpi-value { font-size: 1.5rem; }
  .tabs { gap: 2px; }
  .tab-btn { padding: 8px 10px; font-size: 0.82rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}
@media (max-width: 480px) {
  .navbar-client-name { display: none; }
}
