/* ===========================================
   CRM Shared Design System
   RTL | Hebrew | Modern Dashboard
   =========================================== */

/* ---- CSS Variables ---- */
:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f3f4f6;
  --bg-sidebar-active: #eff6ff;

  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;
  --text-sidebar: #6b7280;
  --text-sidebar-active: #3b82f6;

  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --accent-hover: #2563eb;

  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #6366f1;
  --info-light: #e0e7ff;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;

  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;
  --mobile-nav-height: 60px;

  --font: 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ---- Auth View ---- */
.auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1d23 0%, #2d3748 100%);
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 90%;
}

.auth-logo { font-size: 56px; margin-bottom: 16px; }
.auth-title { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.auth-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 16px; }

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 32px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--bg); box-shadow: var(--shadow); }
.google-icon { flex-shrink: 0; }

/* ---- App Shell Layout ---- */
.app-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 28px; flex-shrink: 0; }
.sidebar-logo-icon { color: var(--accent); }
.sidebar-title { font-size: 18px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  text-decoration: none;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 400;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); font-weight: 500; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }
.nav-label { white-space: nowrap; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 14px; }
.nav-external { opacity: 0.75; }
.nav-external:hover { opacity: 1; }

/* Sidebar toggle */
.sidebar-toggle {
  position: fixed;
  top: 50%;
  right: var(--sidebar-width);
  transform: translate(50%, -50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 101;
  transition: all 0.3s;
  padding: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); box-shadow: var(--shadow-sm); }
.sidebar-toggle svg { transition: transform 0.3s; }

/* Sidebar collapsed state */
.sidebar.collapsed + .sidebar-toggle { right: var(--sidebar-collapsed); }
.sidebar.collapsed + .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role-label { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 8px; }
.sidebar.collapsed .sidebar-footer { flex-direction: column; align-items: center; padding: 8px; }
.sidebar.collapsed .nav-divider { display: none; }
.sidebar.collapsed ~ .main-content { margin-right: var(--sidebar-collapsed); }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.user-name { color: var(--text-sidebar); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sign-out { color: var(--text-sidebar); padding: 6px; border-radius: var(--radius-sm); transition: all 0.15s; flex-shrink: 0; }
.btn-sign-out:hover { background: var(--border); color: var(--danger); }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ---- Mobile Navigation ---- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: flex-start;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  gap: 4px;
  padding: 0 8px;
  scrollbar-width: none;
}
.mobile-nav::-webkit-scrollbar { display: none; }

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  padding: 6px 12px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item:hover { text-decoration: none; }
.mobile-nav-item svg { width: 20px; height: 20px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .main-content { margin-right: 0; padding-bottom: var(--mobile-nav-height); }
  .mobile-nav { display: flex; }
}
