/* ========================================
   CorePlay Management System
   Main Stylesheet
   ======================================== */

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

/* CSS Variables */
:root {
  /* Brand Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0891b2;
  --accent: #f59e0b;
  
  /* Status Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  
  /* Light Theme (Default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  --border-color: #e2e8f0;
  --border-focus: var(--primary);
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Sidebar */
  --sidebar-width: 280px;
  --sidebar-collapsed: 80px;
  
  /* Header */
  --header-height: 64px;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-hover: #475569;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --border-color: #334155;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Heebo', 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ========================================
   Layout Components
   ======================================== */

/* App Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal), width var(--transition-normal);
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-family: 'Rubik', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--spacing-lg);
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

[data-theme="dark"] .nav-item.active {
  background: rgba(37, 99, 235, 0.2);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-right: auto;
  margin-left: 0;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-menu:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-xl);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

/* Search Bar */
.search-bar {
  position: relative;
  width: 300px;
}

.search-bar input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  padding-right: 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-bar-icon {
  position: absolute;
  right: var(--spacing-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-btn .badge {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle-btn.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Page Content */
.page-content {
  flex: 1;
  padding: var(--spacing-xl);
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: var(--spacing-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.primary {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.stat-icon.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.stat-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}

[data-theme="dark"] .stat-icon.primary { background: rgba(37, 99, 235, 0.2); }
[data-theme="dark"] .stat-icon.success { background: rgba(16, 185, 129, 0.2); }
[data-theme="dark"] .stat-icon.warning { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .stat-icon.danger { background: rgba(239, 68, 68, 0.2); }

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-change {
  font-size: 0.75rem;
  margin-top: var(--spacing-xs);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 0.8rem;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-icon.sm {
  width: 28px;
  height: 28px;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input.error {
  border-color: var(--danger);
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: var(--spacing-xs);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Input Group */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-input {
  border-radius: 0;
}

.input-group .form-input:first-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-input:last-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ========================================
   Tables
   ======================================== */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: var(--spacing-md);
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-tertiary);
}

.table td {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* ========================================
   Badges & Status
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

[data-theme="dark"] .badge-primary { background: rgba(37, 99, 235, 0.2); }
[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, 0.2); }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .badge-danger { background: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] .badge-info { background: rgba(59, 130, 246, 0.2); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.busy { background: var(--danger); }
.status-dot.away { background: var(--warning); }

/* ========================================
   Progress Bar
   ======================================== */
.progress {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar.primary { background: var(--primary); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-start;
  gap: var(--spacing-sm);
}

/* ========================================
   Tabs
   ======================================== */
.tabs {
  display: flex;
  gap: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--spacing-lg);
}

.tab {
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* ========================================
   Dropdown
   ======================================== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--transition-fast);
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--spacing-xs) 0;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
  position: fixed;
  top: var(--spacing-lg);
  left: var(--spacing-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--spacing-xs);
}

/* ========================================
   Empty States
   ======================================== */
.empty-state {
  text-align: center;
  padding: var(--spacing-2xl);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--spacing-lg);
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.empty-state-text {
  color: var(--text-muted);
  margin-bottom: var(--spacing-lg);
}

/* ========================================
   Avatar Group
   ======================================== */
.avatar-group {
  display: flex;
  flex-direction: row-reverse;
}

.avatar-group .user-avatar {
  margin-right: -10px;
  border: 2px solid var(--bg-secondary);
}

.avatar-group .user-avatar:last-child {
  margin-right: 0;
}

/* ========================================
   Loading Spinner
   ======================================== */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner.lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.8);
}

/* ========================================
   Mobile Menu
   ======================================== */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
}

.mobile-menu-btn:hover {
  background: var(--bg-hover);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ========================================
   Responsive - Tablet (1024px)
   ======================================== */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  .sidebar {
    transform: translateX(100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay.active {
    display: block;
  }
  
  .main-content {
    margin-right: 0;
    width: 100%;
    max-width: 100vw;
  }
  
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .search-bar {
    display: none;
  }
}

/* ========================================
   Responsive - Mobile (768px)
   ======================================== */
@media (max-width: 768px) {
  /* Typography */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.1rem; }
  
  .page-title { font-size: 1.1rem; }
  .page-subtitle { font-size: 0.75rem; }

  /* Header */
  .header {
    padding: 0 var(--spacing-sm);
    height: 56px;
    gap: var(--spacing-xs);
  }
  
  .header-right,
  .header-left {
    gap: var(--spacing-xs);
  }
  
  .header-left .btn span,
  .header .btn-ghost span {
    display: none;
  }
  
  /* Page content */
  .page-content {
    padding: var(--spacing-sm);
  }
  
  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
  }
  
  .stat-card {
    padding: var(--spacing-sm);
  }
  
  .stat-value {
    font-size: 1.25rem;
  }
  
  /* Cards */
  .card {
    border-radius: var(--radius-md);
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .card-body {
    padding: var(--spacing-sm);
  }
  
  /* Tables - horizontal scroll */
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  
  .table th,
  .table td {
    padding: var(--spacing-sm);
    font-size: 0.8rem;
  }
  
  /* Modal */
  .modal {
    width: 96%;
    max-width: none;
    max-height: 92vh;
    margin: 4vh 2%;
    border-radius: var(--radius-lg);
  }
  
  .modal-header {
    padding: var(--spacing-md);
  }
  
  .modal-body {
    padding: var(--spacing-md);
    max-height: 65vh;
  }
  
  .modal-footer {
    padding: var(--spacing-sm) var(--spacing-md);
    flex-wrap: wrap;
  }
  
  .modal-footer .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    justify-content: center;
  }
  
  /* Forms */
  .form-group {
    margin-bottom: var(--spacing-sm);
  }
  
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 10px 12px;
  }
  
  /* Buttons */
  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
  
  /* Badges */
  .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }
  
  /* Tabs */
  .tabs,
  .project-tabs,
  .budget-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .tabs::-webkit-scrollbar,
  .project-tabs::-webkit-scrollbar,
  .budget-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .project-tab,
  .budget-tab,
  .tab {
    padding: 10px 14px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  
  /* Inline grids in forms - stack on mobile */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Budget summary 4-col → 2-col */
  .budget-summary,
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--spacing-sm) !important;
  }
  
  /* 2-col layouts → 1 col */
  [style*="display:grid"][style*="gap:24px"] {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-md) !important;
  }
  
  /* Filter bars - wrap */
  [style*="display:flex"][style*="flex-wrap:wrap"] {
    gap: var(--spacing-xs) !important;
  }
  
  /* Action buttons */
  .action-btns {
    gap: 2px;
  }
  
  .action-btns button {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  /* Login page */
  .login-card {
    width: 95%;
    margin: var(--spacing-md);
  }
}

/* ========================================
   Responsive - Small Mobile (480px)
   ======================================== */
@media (max-width: 480px) {
  /* Header - minimal */
  .header {
    height: 50px;
    padding: 0 var(--spacing-xs);
  }
  
  .page-title { font-size: 1rem; }
  
  /* Hide non-essential header buttons */
  .header-left .btn:not(:first-child):not(:last-child) {
    display: none;
  }
  
  /* Stats → single column */
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  /* Budget cards → 2 col stays but smaller */
  .budget-summary,
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
  }
  
  /* Cycle header stats */
  .cycle-stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  
  .cycle-stat {
    padding: 10px !important;
  }
  
  .cycle-stat-value {
    font-size: 1.1rem !important;
  }
  
  .cycle-stat-label {
    font-size: 11px !important;
  }
  
  /* Project header */
  .project-header {
    padding: 16px !important;
  }
  
  .project-header h1 {
    font-size: 1.25rem !important;
  }
  
  /* Budget card values */
  .budget-card {
    padding: 12px !important;
  }
  
  .budget-card-value {
    font-size: 1.25rem !important;
  }
  
  .budget-card-label {
    font-size: 0.7rem !important;
  }
  
  /* Milestone items */
  .milestone-item {
    padding: 12px !important;
  }
  
  .milestone-item > div {
    flex-wrap: wrap !important;
  }
  
  /* Filters - full width */
  .form-input[style*="max-width"],
  .form-select[style*="width:auto"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Modal - full screen on very small devices */
  .modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  
  .modal-body {
    max-height: calc(100vh - 130px);
  }
  
  /* Table cells even smaller */
  .table th,
  .table td {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
  
  /* Group headers */
  .group-header {
    padding: 8px 12px !important;
    font-size: 0.85rem;
  }
  
  /* Back link in milestone detail */
  .back-link {
    font-size: 0.85rem;
  }
  
  .milestone-detail-header {
    padding: 12px !important;
  }
  
  /* Calc box */
  .calc-box {
    padding: 10px !important;
    font-size: 0.85rem;
  }
  
  /* Cycle header */
  .cycle-header {
    padding: 16px !important;
    border-radius: 8px !important;
  }
  
  .cycle-header h2 {
    font-size: 1.2rem !important;
  }
  
  .progress-bar {
    height: 20px !important;
  }
  
  /* MS rows in cycle view */
  .ms-row {
    padding: 10px 12px !important;
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* ========================================
   Critical Mobile Fixes (all mobile)
   ======================================== */
@media (max-width: 768px) {
  /* Force everything to stay within viewport */
  .app-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .page-content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  /* Project page header - stack vertically */
  .project-header {
    padding: 12px !important;
  }
  
  .project-header [style*="display:flex"] {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* Project tabs - scrollable, no wrap */
  .project-tabs {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    gap: 0 !important;
    padding: 0 !important;
  }
  
  .project-tabs::-webkit-scrollbar { display: none; }
  
  .project-tab {
    flex-shrink: 0;
    padding: 10px 12px !important;
    font-size: 0.8rem !important;
  }

  /* Budget summary cards in project - 2 columns */
  .budget-summary,
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* All inline flex containers - allow wrapping */
  [style*="display:flex"][style*="gap:"] {
    flex-wrap: wrap !important;
  }

  /* Header buttons - compact */
  .header-left {
    gap: 4px !important;
  }
  
  .header-left .btn {
    padding: 6px 8px !important;
    font-size: 0.75rem !important;
  }

  /* Inline grids - force 1 col on mobile */
  [style*="grid-template-columns: 1fr 1fr;"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  /* Even tighter on small phones */
  .page-content {
    padding: 8px !important;
  }

  .header {
    padding: 0 8px !important;
  }

  /* Full width stats */
  .stat-card,
  .budget-card {
    min-width: 0 !important;
  }

  /* Project tabs even smaller */
  .project-tab {
    padding: 8px 10px !important;
    font-size: 0.75rem !important;
  }
}
@media (pointer: coarse) {
  /* Larger touch targets */
  .nav-item {
    padding: 12px var(--spacing-md);
    min-height: 44px;
  }
  
  .btn {
    min-height: 40px;
  }
  
  .btn-sm {
    min-height: 34px;
    padding: 6px 10px;
  }
  
  .form-select,
  .form-input {
    min-height: 44px;
  }
  
  .table td,
  .table th {
    min-height: 44px;
  }
  
  /* Make select dropdown arrow larger */
  .form-select {
    background-size: 16px;
  }
  
  .milestone-checkbox {
    width: 32px !important;
    height: 32px !important;
  }
  
  .action-btns button {
    min-width: 34px;
    min-height: 34px;
  }
}

/* ========================================
   Safe area for notched phones
   ======================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .modal-footer {
    padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
  }
}

/* ========================================
   Sidebar mobile behavior
   ======================================== */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    z-index: 200;
    box-shadow: var(--shadow-xl);
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  .sidebar,
  .header,
  .btn,
  .mobile-menu-btn {
    display: none !important;
  }
  
  .main-content {
    margin: 0;
  }
  
  .page-content {
    padding: 0;
  }
}

/* ========================================
   Utilities
   ======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

.hidden { display: none; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ========================================
   Login Page Specific
   ======================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #0891b2 100%);
  padding: var(--spacing-lg);
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.login-header {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-xl) var(--spacing-lg);
  background: var(--bg-tertiary);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--spacing-lg);
}

.login-logo img {
  height: 70px;
  object-fit: contain;
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-xs);
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-form {
  padding: var(--spacing-xl);
}

.login-footer {
  text-align: center;
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}
