/* New Features Styles - Optimized UI */

/* Ensure pages are properly hidden */
.page {
  display: none !important;
}

.page.active {
  display: block !important;
  animation: fadeIn 0.3s ease;
}

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

/* Segments Grid */
.segments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  padding: 8px;
}

.segment-card {
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.segment-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.segment-card-header {
  padding: 24px;
  position: relative;
}

.segment-color-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.segment-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.segment-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.segment-card-title h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.segment-description {
  font-size: 14px;
  color: var(--gray-500);
  line-height: 1.5;
  margin: 0;
}

.segment-card-stats {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

.segment-stat {
  flex: 1;
  text-align: center;
}

.segment-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.segment-stat-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.segment-card-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  justify-content: flex-end;
}

/* Templates Grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
  padding: 8px;
}

.template-card {
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: all 0.3s ease;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.template-card-header {
  padding: 20px 24px;
  position: relative;
  border-bottom: 1px solid var(--gray-100);
}

.template-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.template-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.template-preview {
  padding: 20px 24px;
  background: var(--gray-50);
}

.template-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-body-preview {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}

.template-card-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  justify-content: flex-end;
}

/* Deals Board */
.deals-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.deal-column {
  background: var(--gray-50);
  border-radius: 12px;
  padding: 16px;
  min-height: 400px;
}

.deal-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--gray-200);
}

.deal-column-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.deal-column-count {
  background: var(--white);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.deal-card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.deal-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.deal-card.discovery { border-left-color: #6b7280; }
.deal-card.proposal { border-left-color: #3b82f6; }
.deal-card.negotiation { border-left-color: #f59e0b; }
.deal-card.closed-won { border-left-color: #10b981; }
.deal-card.closed-lost { border-left-color: #ef4444; }

.deal-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.deal-card-company {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.deal-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.deal-card-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 600;
}

.deal-card-date {
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 6px;
}

.deal-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* Coming Soon Pages */
.coming-soon-container {
  animation: fadeIn 0.5s ease;
}

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

.coming-soon-icon {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Empty States Enhancement */
.empty-state-large {
  text-align: center;
  padding: 60px 40px;
}

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

.empty-state-large h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.empty-state-large p {
  font-size: 15px;
  color: var(--gray-500);
  max-width: 400px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

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

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

.status-badge.partner { background: #ede9fe; color: #7c3aed; }
.status-badge.partner::before { background: #8b5cf6; }

.status-badge.supplier { background: #fef3c7; color: #d97706; }
.status-badge.supplier::before { background: #f59e0b; }

.status-badge.customer { background: #d1fae5; color: #059669; }
.status-badge.customer::before { background: #10b981; }

.status-badge.network { background: #dbeafe; color: #2563eb; }
.status-badge.network::before { background: #3b82f6; }

.status-badge.prospect { background: #dbeafe; color: #1e40af; }
.status-badge.prospect::before { background: #3b82f6; }

.status-badge.competitor { background: #fee2e2; color: #dc2626; }
.status-badge.competitor::before { background: #ef4444; }

/* Page Header Enhancement */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 16px;
  color: var(--gray-500);
  max-width: 600px;
  line-height: 1.5;
}

/* Card Enhancement */
.card {
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

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

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

.card-body {
  padding: 24px;
}

/* Button Enhancements */
.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  transform: translateY(-1px);
}

.btn-icon:hover[style*="danger"],
.btn-icon[style*="color: var(--danger)"]:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Table Enhancements */
.leads-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.leads-table th {
  background: var(--gray-50);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  padding: 16px;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
}

.leads-table td {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s ease;
  vertical-align: middle;
}

.leads-table tbody tr:hover td {
  background: var(--gray-50);
}

.leads-table tbody tr:last-child td {
  border-bottom: none;
}

/* Lead Info Component */
.lead-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lead-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.lead-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--gray-900);
  margin-bottom: 3px;
}

.lead-company {
  font-size: 13px;
  color: var(--gray-500);
}

/* Form Input Enhancement */
.form-input {
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: var(--white);
}

.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);
}

/* Modal Enhancement */
.modal-content {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--gray-50), var(--white));
  border-bottom: 1px solid var(--gray-200);
}

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

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
  .segments-grid,
  .templates-grid {
    grid-template-columns: 1fr;
  }
  
  .deals-board {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column;
    gap: 16px;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .card-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
}

/* Critical Fixes for Page Display */
.main-content {
  position: relative;
  overflow-x: hidden;
}

.content {
  position: relative;
  min-height: calc(100vh - 80px);
}

/* Ensure proper z-index stacking */
.page {
  position: relative;
  z-index: 1;
}

.page.active {
  z-index: 2;
}

/* Fix for nav-item disabled state */
.nav-item.disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.nav-item.disabled * {
  pointer-events: none !important;
}

/* Fix table overflow issues */
.card-body {
  overflow-x: auto;
}

.leads-table {
  min-width: 100%;
}

/* Ensure modals are on top */
.modal {
  z-index: 1000 !important;
}

.modal.active {
  display: flex !important;
}

/* Fix for segments and templates grid */
.segments-grid:empty::before,
.templates-grid:empty::before {
  content: '';
  display: block;
  height: 200px;
}

/* Ensure deals board doesn't overflow */
.deals-board {
  overflow-x: auto;
  padding-bottom: 8px;
}

/* Loading state improvements */
.page-loading {
  position: relative;
}

.page-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 9999;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Fix for empty states in tables */
.empty-table-cell {
  padding: 60px 20px;
  text-align: center;
}

/* Header actions responsive fix */
.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Card improvements */
.card {
  position: relative;
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.card + .card {
  margin-top: 24px;
}

/* Ensure proper padding in page content */
.page > .card:first-child,
.page > .page-header + .card {
  margin-top: 0;
}

/* ============================================
   PROFESSIONAL POLISH - Feature Pages
   ============================================ */

/* Content area breathing room */
.content {
  padding: 28px 32px 40px;
}

/* Page header — flex row with proper wrapping */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.page-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* Header action buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Professional table layouts */
.leads-table {
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.leads-table th {
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.leads-table td {
  font-size: 14px;
  color: var(--gray-700);
}

.leads-table td:last-child {
  white-space: nowrap;
}

/* Settings page layout */
.settings-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  min-height: 500px;
}

.settings-content {
  min-width: 0;
}

.settings-tab {
  animation: fadeIn 0.25s ease;
}

/* Form group spacing */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Workflow board columns — professional min heights */
.workflow-column {
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

.workflow-column > div:last-child {
  flex: 1;
}

/* Prospect grid consistent height */
.prospect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* Calendar page polish */
#calendar .card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  .content {
    padding: 20px 20px 32px;
  }
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .page-title {
    font-size: 24px;
  }
  
  .content {
    padding: 16px 16px 24px;
  }
}
