/* Pipeline Kanban Board Styles */
/* Professional CRM-style design like HubSpot/Salesforce */

:root {
  --pipeline-bg: #f5f7fa;
  --pipeline-column-bg: #ffffff;
  --pipeline-card-bg: #ffffff;
  --pipeline-border: #e2e8f0;
  --pipeline-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --pipeline-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);

  /* Stage colors */
  --stage-new-lead: #3b82f6;
  --stage-qualifying: #06b6d4;
  --stage-proposal: #f59e0b;
  --stage-negotiation: #f97316;
  --stage-due-diligence: #8b5cf6;
  --stage-closing: #10b981;
  --stage-won: #059669;
  --stage-lost: #ef4444;
}

/* Container */
.pipeline-container {
  min-height: 100vh;
  background: var(--pipeline-bg);
  padding: 0;
}

/* Header */
.pipeline-header {
  background: #ffffff;
  border-bottom: 1px solid var(--pipeline-border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.pipeline-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pipeline-header h1::before {
  content: '';
  width: 8px;
  height: 24px;
  background: linear-gradient(180deg, var(--stage-new-lead), var(--stage-won));
  border-radius: 4px;
}

/* Stats Bar */
.pipeline-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.pipeline-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  background: var(--pipeline-bg);
  border-radius: 8px;
  min-width: 100px;
}

.pipeline-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}

.pipeline-stat-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Header Actions */
.pipeline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-add-deal {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--stage-new-lead);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-deal:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: white;
  color: #475569;
  border: 1px solid var(--pipeline-border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-filter:hover {
  background: var(--pipeline-bg);
  border-color: #94a3b8;
}

/* Kanban Board */
.pipeline-board {
  display: flex;
  gap: 16px;
  padding: 24px;
  overflow-x: auto;
  min-height: calc(100vh - 100px);
}

/* Column */
.pipeline-column {
  flex: 0 0 280px;
  background: var(--pipeline-column-bg);
  border-radius: 12px;
  box-shadow: var(--pipeline-shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
  transition: all 0.2s;
}

.pipeline-column.collapsed {
  flex: 0 0 60px;
}

.pipeline-column.drop-target {
  box-shadow: 0 0 0 2px var(--stage-new-lead);
}

.pipeline-column.drag-over {
  background: #f0f9ff;
}

/* Column Header */
.column-header {
  padding: 16px;
  border-bottom: 1px solid var(--pipeline-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.column-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.column-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.column-name {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.column-count {
  background: var(--pipeline-bg);
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.column-value {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* Stage Colors */
.pipeline-column[data-stage="new_lead"] .column-indicator { background: var(--stage-new-lead); }
.pipeline-column[data-stage="qualifying"] .column-indicator { background: var(--stage-qualifying); }
.pipeline-column[data-stage="proposal"] .column-indicator { background: var(--stage-proposal); }
.pipeline-column[data-stage="negotiation"] .column-indicator { background: var(--stage-negotiation); }
.pipeline-column[data-stage="due_diligence"] .column-indicator { background: var(--stage-due-diligence); }
.pipeline-column[data-stage="closing"] .column-indicator { background: var(--stage-closing); }
.pipeline-column[data-stage="won"] .column-indicator { background: var(--stage-won); }
.pipeline-column[data-stage="lost"] .column-indicator { background: var(--stage-lost); }

/* Column Cards Container */
.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.column-cards::-webkit-scrollbar {
  width: 6px;
}

.column-cards::-webkit-scrollbar-track {
  background: transparent;
}

.column-cards::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Deal Card */
.deal-card {
  background: var(--pipeline-card-bg);
  border: 1px solid var(--pipeline-border);
  border-radius: 10px;
  padding: 14px;
  cursor: grab;
  transition: all 0.2s;
  position: relative;
}

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

.deal-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(3deg);
}

.deal-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.deal-company-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--pipeline-bg);
  flex-shrink: 0;
}

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

.deal-company-name {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 4px;
}

.deal-type-badge.buy {
  background: #dbeafe;
  color: #1d4ed8;
}

.deal-type-badge.sell {
  background: #fce7f3;
  color: #be185d;
}

/* Deal Details */
.deal-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  padding: 10px 0;
  border-top: 1px solid var(--pipeline-border);
  border-bottom: 1px solid var(--pipeline-border);
  margin: 10px 0;
}

.deal-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deal-detail-label {
  color: #94a3b8;
}

.deal-detail-value {
  font-weight: 500;
  color: #475569;
}

.deal-volume {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

/* Deal Footer */
.deal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
}

.deal-partner {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
}

.deal-partner-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 600;
}

.deal-activity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deal-emails {
  display: flex;
  align-items: center;
  gap: 4px;
}

.deal-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Probability Bar */
.deal-probability {
  margin-top: 10px;
}

.probability-bar {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.probability-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.probability-fill.low { background: #ef4444; }
.probability-fill.medium { background: #f59e0b; }
.probability-fill.high { background: #10b981; }

.probability-label {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  text-align: right;
}

/* Empty State */
.column-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #94a3b8;
  text-align: center;
}

.column-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.column-empty-text {
  font-size: 13px;
}

/* Add Deal Modal */
.pipeline-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 0.3s;
}

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

.pipeline-modal {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s;
  display: flex;
  flex-direction: column;
}

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

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--pipeline-bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--pipeline-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--pipeline-border);
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  transition: all 0.2s;
  background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--stage-new-lead);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Deal Type Selector */
.deal-type-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.deal-type-option {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--pipeline-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.deal-type-option:hover {
  border-color: #94a3b8;
}

.deal-type-option.selected {
  border-color: var(--stage-new-lead);
  background: #eff6ff;
}

.deal-type-option input {
  display: none;
}

.deal-type-option-label {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

/* Buttons */
.btn-primary {
  padding: 10px 20px;
  background: var(--stage-new-lead);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  padding: 10px 20px;
  background: white;
  color: #475569;
  border: 1px solid var(--pipeline-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Deal Detail Slide Panel */
.deal-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.deal-panel.active {
  right: 0;
}

.deal-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

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

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

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* History Timeline */
.history-timeline {
  margin-top: 20px;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--pipeline-border);
}

.history-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pipeline-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-content {
  flex: 1;
}

.history-text {
  font-size: 13px;
  color: #1e293b;
}

.history-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.history-stage-change {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.history-stage {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Loading State */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--pipeline-border);
  border-top-color: var(--stage-new-lead);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: #1e293b;
  color: white;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateX(120%);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

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

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

/* Responsive */
@media (max-width: 1200px) {
  .pipeline-column {
    flex: 0 0 260px;
  }
}

@media (max-width: 768px) {
  .pipeline-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .pipeline-stats {
    justify-content: space-between;
  }

  .pipeline-board {
    padding: 16px;
  }

  .pipeline-column {
    flex: 0 0 85vw;
  }

  .deal-panel {
    width: 100%;
    right: -100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}
