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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #252525;
  --bg4: #2e2e2e;
  --text: #f0f0f0;
  --text-muted: #999;
  --border: #333;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --male: #4a90d9;
  --female: #e07ab0;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', 'Arial', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { line-height: 1.6; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg4); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #27ae60; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 6px 10px; }

/* ===== INPUTS ===== */
.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
  direction: rtl;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.select option { background: var(--bg3); }
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-male { background: rgba(74,144,217,0.2); color: var(--male); }
.badge-female { background: rgba(224,122,176,0.2); color: var(--female); }
.badge-primary { background: rgba(37,99,235,0.2); color: var(--primary); }
.badge-success { background: rgba(46,204,113,0.2); color: var(--success); }
.badge-danger { background: rgba(231,76,60,0.2); color: var(--danger); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
}
.tab.active {
  background: var(--primary);
  color: white;
}
.tab:hover:not(.active) { background: var(--bg4); color: var(--text); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== SIDEBAR NAV ===== */
.layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo h2 { font-size: 1.1rem; color: var(--primary); }
.sidebar-logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.9rem;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
  font-family: inherit;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(37,99,235,0.15);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}
.nav-icon { font-size: 1.1rem; }
.main-content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
  max-height: 100vh;
}
.page { display: none; }
.page.active { display: block; }

/* ===== SEARCH ===== */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}
.search-bar .input { padding-right: 38px; }
.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

/* ===== AVATAR ===== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.avatar-male { background: rgba(74,144,217,0.2); color: var(--male); }
.avatar-female { background: rgba(224,122,176,0.2); color: var(--female); }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== GIF PREVIEW ===== */
.gif-preview {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.gif-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.5rem;
}

/* ===== EXERCISE CARD ===== */
.exercise-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg3);
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.exercise-card:hover { border-color: var(--primary); }
.exercise-info { flex: 1; }
.exercise-name { font-weight: 600; margin-bottom: 4px; }
.exercise-meta { font-size: 0.82rem; color: var(--text-muted); }
.weight-display {
  text-align: center;
  min-width: 80px;
}
.weight-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.weight-unit { font-size: 0.78rem; color: var(--text-muted); }
.reps-display {
  text-align: center;
  min-width: 80px;
}
.reps-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}
.reps-label { font-size: 0.78rem; color: var(--text-muted); }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideInLeft 0.3s;
  min-width: 200px;
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--primary); color: white; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== LOADING ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
}

/* ===== EXERCISE PICKER (prog-ex modal) ===== */
.pe-muscle-btn.active-muscle {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}
#pe-exercise-list .pe-ex-item:last-child { border-bottom: none; }
