/* Enhanced Base Styles - Polished Version */

:root {
  /* Company Brand Colors */
  --primary: #086c84;
  --primary-light: #e6f2f5;
  --primary-lighter: #f0f9fb;
  --primary-dark: #065666;
  --primary-darker: #054451;
  
  /* Secondary Colors */
  --secondary: #0d9488;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  /* Grays - Refined */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  
  /* Shadows - Enhanced */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 4px 14px 0 rgba(8, 108, 132, 0.39);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Loading State */
body.page-loading {
  cursor: wait;
}

body.page-loading .page {
  opacity: 0.7;
}

/* Primary Button - Polished */
.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

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

.btn-primary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-primary:active::after {
  width: 200px;
  height: 200px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* Secondary Button - Polished */
.btn-secondary {
  padding: 10px 20px;
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-base);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* Icon Button */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: all var(--transition-fast);
  position: relative;
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: scale(1.05);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* Toolbar Button */
.toolbar-btn {
  padding: 8px 12px;
  border: none;
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-600);
  transition: all var(--transition-fast);
  font-size: 14px;
}

.toolbar-btn:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.toolbar-btn.ai-active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

/* Form Elements - Enhanced */
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 14px;
  transition: all var(--transition-fast);
  font-family: inherit;
  background: var(--white);
  color: var(--gray-900);
}

.form-input:hover {
  border-color: var(--gray-300);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  background: var(--white);
}

.form-input::placeholder {
  color: var(--gray-400);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* Cards - Polished */
.card {
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.card-action {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.card-action:hover {
  background: var(--primary-light);
}

.card-body {
  padding: 24px;
}

/* Modal - Enhanced */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--white);
  border-radius: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-400);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Page Structure - CRITICAL: Only active page should show */
.page {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  pointer-events: none !important;
}

.page.active {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  overflow: visible !important;
  position: relative !important;
  pointer-events: auto !important;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--gray-500);
  font-size: 16px;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.new { 
  background: #dbeafe; 
  color: #1e40af; 
}
.status-badge.contacted { 
  background: #fef3c7; 
  color: #92400e; 
}
.status-badge.qualified { 
  background: #d1fae5; 
  color: #065f46; 
}
.status-badge.negotiation { 
  background: #fce7f3; 
  color: #9d174d; 
}
.status-badge.closed { 
  background: #e0e7ff; 
  color: #3730a3; 
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Empty States - Beautiful */
.empty-state-compact {
  text-align: center;
  padding: 32px 20px;
  color: var(--gray-500);
}

.empty-state-compact .empty-icon {
  width: 56px;
  height: 56px;
  background: var(--gray-100);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 24px;
  color: var(--gray-400);
}

.empty-state-compact .empty-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.empty-state-compact h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.empty-state-compact p {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.empty-state-large {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}

.empty-illustration {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary-light), var(--white));
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 32px;
  color: var(--primary);
  box-shadow: var(--shadow);
}

.empty-state-large h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.empty-state-large p {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 20px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.empty-table-cell {
  padding: 48px 24px !important;
  background: var(--white) !important;
}

/* Pipeline Empty State */
.pipeline-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray-400);
}

.pipeline-empty i {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.pipeline-empty p {
  font-size: 13px;
}

/* Toast Notifications - Polished */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-base);
  font-weight: 500;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { 
  background: var(--success); 
}

.toast.error { 
  background: var(--danger); 
}

.toast.info { 
  background: var(--primary); 
}

.toast i {
  font-size: 18px;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--gray-200);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
}

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

/* Selection Color */
::selection {
  background: var(--primary-light);
  color: var(--primary-dark);
}

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

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Focus Visible for Accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .prospect-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .workflow-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .main-content {
    margin-left: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .search-box {
    width: 200px;
  }
  .prospect-grid {
    grid-template-columns: 1fr;
  }
  .workflow-board {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
