/* ============================================
   Sianos Papageorgiou CRM - Custom Styles
   ============================================ */

:root {
  --primary: #4a7c8e;
  --primary-light: #5b8fa0;
  --primary-pale: #e8f2f5;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gold: #f59e0b;
}

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

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f1f5f9; }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 50;
  background: linear-gradient(180deg, #4a7c8e 0%, #3a6170 100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}
#sidebar.collapsed { transform: translateX(-240px); }
#main-content { margin-left: 240px; transition: margin-left 0.3s ease; }
#main-content.expanded { margin-left: 0; }

/* Mobile sidebar overlay */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  #sidebar { transform: translateX(-240px); z-index: 50; }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0 !important; }
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: rgba(255,255,255,0.75);
  cursor: pointer; transition: all 0.2s; border-radius: 8px; margin: 2px 8px;
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-item.active { background: rgba(255,255,255,0.18); color: white; }
.nav-item .icon { width: 20px; text-align: center; }

/* ── TOPBAR ── */
#topbar {
  position: sticky; top: 0; z-index: 30;
  background: white; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 64px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── CARDS ── */
.card {
  background: white; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 20px; border: 1px solid #f0f4f8;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.stat-card {
  background: white; border-radius: 12px;
  padding: 20px; border: 1px solid #f0f4f8;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── LEADERBOARD ── */
.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr 80px 72px 90px 130px;
  align-items: center; padding: 12px 14px;
  border-radius: 10px; margin-bottom: 6px;
  background: #f8fafc; border: 1px solid #e8edf2;
  transition: all 0.25s;
  cursor: pointer;
  gap: 6px;
  min-width: 0;
}
.leaderboard-row > * { min-width: 0; overflow: hidden; }
.leaderboard-row:hover { background: #eef3f8; transform: translateX(2px); }
.leaderboard-row.rank-1 { background: linear-gradient(90deg, #fffbeb, #fef9e7); border-color: #fbbf24; }
.leaderboard-row.rank-2 { background: linear-gradient(90deg, #f8fafc, #f1f5f9); border-color: #94a3b8; }
.leaderboard-row.rank-3 { background: linear-gradient(90deg, #fef6ee, #fdf1e7); border-color: #fb923c; }

/* Mobile leaderboard: stack to simpler layout */
@media (max-width: 640px) {
  .leaderboard-row {
    grid-template-columns: 32px 1fr auto auto;
    grid-template-rows: auto auto;
    padding: 10px 12px;
    row-gap: 6px;
  }
  .leaderboard-row .lb-score-col { grid-column: 3; grid-row: 1; }
  .leaderboard-row .lb-conv-col  { grid-column: 4; grid-row: 1; }
  .leaderboard-row .lb-gci-col   { grid-column: 2; grid-row: 2; font-size: 11px; }
  .leaderboard-row .lb-badge-col { grid-column: 3 / span 2; grid-row: 2; justify-content: flex-end; }
}

.rank-badge {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.rank-1 .rank-badge { background: #fbbf24; color: white; }
.rank-2 .rank-badge { background: #94a3b8; color: white; }
.rank-3 .rank-badge { background: #fb923c; color: white; }
.rank-other .rank-badge { background: #e2e8f0; color: #64748b; }

/* ── SCORE BARS ── */
.score-bar { height: 6px; border-radius: 4px; background: #e2e8f0; overflow: hidden; width: 100%; max-width: 64px; }
.score-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.score-bar-green .score-bar-fill { background: linear-gradient(90deg, #22c55e, #16a34a); }
.score-bar-yellow .score-bar-fill { background: linear-gradient(90deg, #fbbf24, #d97706); }
.score-bar-red .score-bar-fill { background: linear-gradient(90deg, #f87171, #dc2626); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #d97706; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ── FORMS ── */
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; color: #374151;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}
.form-input:focus { outline: none; border-color: #2d6a9f; box-shadow: 0 0 0 3px rgba(45,106,159,0.12); }
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; display: block; }

/* ── BUTTONS ── */
.btn { padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: linear-gradient(135deg, #1e3a5f, #2d6a9f); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(45,106,159,0.35); }
.btn-success { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; }
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(34,197,94,0.35); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.btn-danger:hover { transform: translateY(-1px); }
.btn-outline { background: white; border: 1.5px solid #e2e8f0; color: #374151; }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── TABLES ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8fafc; padding: 10px 14px; text-align: left; font-weight: 700; color: #374151; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid #f0f4f8; color: #374151; }
.data-table tr:hover td { background: #f8fafc; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: white; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #f0f4f8; display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f4f8; display: flex; justify-content: flex-end; gap: 10px; }

/* ── NOTIFICATIONS ── */
.notif-badge { position: absolute; top: -4px; right: -4px; background: #ef4444; color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid #f0f4f8; cursor: pointer; transition: background 0.15s; }
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; border-left: 3px solid #3b82f6; }

/* ── TABS ── */
.tab-bar { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.tab-btn { padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; color: #64748b; border: none; background: transparent; }
.tab-btn.active { background: white; color: #1e3a5f; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ── TOAST ── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease; max-width: 360px; }
.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-info { background: #2563eb; color: white; }
.toast-warning { background: #d97706; color: white; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── LOADING ── */
.skeleton { background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── CHARTS ── */
.chart-container { position: relative; }

/* ── PAGE HEADER ── */
.page-header { padding: 24px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.page-title { font-size: 22px; font-weight: 700; color: #1e3a5f; }
.page-subtitle { font-size: 13px; color: #94a3b8; margin-top: 2px; }

/* ── WEEK GRID ── */
.week-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.week-btn { width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: 1.5px solid #e2e8f0; background: white; color: #64748b; }
.week-btn:hover { border-color: #2d6a9f; color: #1e3a5f; }
.week-btn.has-data { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.week-btn.active { background: #1e3a5f; border-color: #1e3a5f; color: white; }

/* ── MONTHLY GRID ── */
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ── PARTNER AVATAR ── */
.partner-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: white; flex-shrink: 0; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .p-6 { padding: 12px !important; }
  .page-header { padding: 12px 12px 0; }
  .tab-bar { flex-wrap: wrap; }
  .tab-btn { padding: 6px 10px; font-size: 11px; }
  .stat-card { padding: 14px; }
  .stat-card .text-2xl { font-size: 1.25rem; }
  /* KPI grid on mobile: 2 columns */
  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-6 { grid-template-columns: repeat(2, 1fr) !important; }
  /* Hide leaderboard columns not essential on mobile */
  .leaderboard-row { gap: 4px; }
  /* Dashboard controls wrap nicely */
  .flex.flex-wrap.items-center.justify-between { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* Chart section stacks */
  .grid.grid-cols-1.xl\\:grid-cols-3 { grid-template-columns: 1fr !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── TREND ARROWS ── */
.trend-up { color: #16a34a; font-size: 11px; }
.trend-down { color: #dc2626; font-size: 11px; }
.trend-flat { color: #94a3b8; font-size: 11px; }

/* ── PROGRESS BARS (target) ── */
.target-progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.target-progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.target-progress-fill.on-track { background: linear-gradient(90deg, #3b82f6, #2d6a9f); }
.target-progress-fill.achieved { background: linear-gradient(90deg, #16a34a, #15803d); }
.target-progress-fill.behind { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* ── HEATMAP ── */
.heatmap-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.heatmap-cell { width: 18px; height: 18px; border-radius: 3px; cursor: default; transition: transform 0.1s; }
.heatmap-cell:hover { transform: scale(1.3); z-index: 1; }

/* ── PERSONAL DASHBOARD ── */
.rank-badge-large { font-size: 3rem; font-weight: 900; line-height: 1; }

/* ── MISSING ENTRY BANNER ── */
.missing-banner { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 12px; padding: 14px 18px; }

/* ── WEEK BTN current-week ── */
.week-btn.current-week { background: #fef3c7; border-color: #fbbf24; color: #92400e; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
