/**
 * Insights View Styles
 * Matches company-view.css design exactly
 */

/* Insights View Container */
#insights-view-container {
  width: 100%;
  background: transparent;
}

/* Insights Controls Wrapper */
.insights-controls-wrapper {
  margin-bottom: 20px;
  background: transparent;
}

/* Insights View Controls - matches company-view */
.insights-view-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  gap: 15px;
}

.insights-view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.insights-view-filters {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

/* Editable cells - hover effect */
.insights-table td.editable-cell {
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s;
}

.insights-table td.editable-cell:hover {
  background-color: #f0f9ff !important;
  border: 1px solid #e0f2fe;
}

.insights-table td.editable-cell:hover::after {
  content: '✎';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  color: #94a3b8;
  opacity: 0.7;
}

/* Manual override indicator */
.override-indicator {
  font-size: 10px;
  margin-left: 4px;
  color: #f59e0b;
  opacity: 0.8;
}

.manually-overridden {
  border-left: 3px solid #f59e0b !important;
  padding-left: 8px !important;
}

/* Cell editing styles - matches company-view.css */
.cell-edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid #4a90e2;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 5px rgba(74, 144, 226, 0.3);
}

.cell-edit-input:focus {
  border-color: #357abd;
}

textarea.cell-edit-input {
  resize: vertical;
  min-height: 60px;
}

.cell-edit-actions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  justify-content: flex-end;
}

.cell-edit-actions .btn-icon {
  opacity: 1;
  padding: 4px 8px;
}

.insights-view-controls .btn {
  text-decoration: none;
  background: white;
  box-shadow: 0px 3px 10px #0000001a;
  color: #4b5563;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #e4e7ee;
  transition: all 0.2s ease;
  margin-bottom: 0 !important;
  text-transform: none !important;
}

.insights-view-controls .btn-primary {
  background: #30a5bf;
  color: white;
  border-color: #30a5bf;
}

.insights-view-controls .btn-primary:hover {
  opacity: 0.9;
}

.insights-view-controls .btn-secondary {
  background: white;
  color: #4b5563;
}

.insights-view-controls .btn-secondary:hover {
  background: #f9fafb;
  border-color: #30a5bf;
  color: #30a5bf;
}

.insights-view-controls .btn i {
  font-size: 14px;
}

/* Table Outer Wrapper */
.insights-table-outer-wrapper {
  position: relative;
  width: 100%;
}

/* Table Wrapper - matches company-view */
.insights-table-wrapper {
  width: 100%;
  position: relative;
  overflow-x: auto;
  background-color: #fff;
  border-radius: 4px;
}

/* Table Styling - matches company-view exactly */
.insights-table {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background-color: #fff;
}

.insights-table thead {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #EDEEF4;
}

.insights-table thead tr {
  background-color: #EDEEF4;
}

.insights-table th {
  padding: 10px 6px;
  font-weight: bold;
  font-size: 13px;
  color: #555;
  text-align: left;
  line-height: 14px;
  background-color: #EDEEF4;
  border-bottom: 1px solid #F3F3F3;
  position: sticky;
  top: 0;
}

.insights-table th .th-content {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 10px;
}

.insights-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.insights-table th.sortable:hover {
  background-color: #e0e2e8;
}

/* Sort icons - Lucide move-up / move-down DOM elements */
.sort-icons {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
  gap: 0;
}
.sort-icons i,
.sort-icons svg {
  display: block !important;
  width: 10px !important;
  height: 10px !important;
  margin: 0 -2px;
  opacity: 0.7;
  color: #222;
  stroke-width: 3;
  flex-shrink: 0;
  transition: opacity 0.15s, color 0.15s;
  cursor: pointer;
}
.sort-up-icon:hover svg,
.sort-up-icon:hover {
  opacity: 1 !important;
  color: #30a5bf !important;
}
.sort-down-icon:hover svg,
.sort-down-icon:hover {
  opacity: 1 !important;
  color: #30a5bf !important;
}
.insights-table th.sort-asc .sort-up-icon,
.insights-table th.sort-asc .sort-up-icon svg {
  opacity: 1 !important;
  color: #30a5bf !important;
}
.insights-table th.sort-desc .sort-down-icon,
.insights-table th.sort-desc .sort-down-icon svg {
  opacity: 1 !important;
  color: #30a5bf !important;
}

/* Lucide SVG size overrides */
.insights-search-icon { position: absolute; left: 12px; color: #999; pointer-events: none; z-index: 1; width: 14px !important; height: 14px !important; }
.override-indicator { width: 10px !important; height: 10px !important; display: inline !important; vertical-align: middle; margin-left: 2px; }
.insights-view-controls .btn svg { width: 14px !important; height: 14px !important; vertical-align: middle; }
.company-website-link svg { width: 12px !important; height: 12px !important; }
.activities-btn svg { width: 14px !important; height: 14px !important; }
.show-more-btn svg { width: 12px !important; height: 12px !important; }
.insights-row-error svg { width: 16px !important; height: 16px !important; }
.insights-table-error svg { width: 32px !important; height: 32px !important; display: block; margin: 0 auto 8px; }

.insights-table tbody tr {
  background-color: #fff;
  transition: background-color 0.2s;
  border-bottom: 1px solid #F3F3F3;
}

.insights-table tbody tr:hover {
  background-color: #f9fafb;
}

.insights-table tbody tr:hover .owners-cell {
  background-color: transparent;
}

.insights-table .owners-cell:hover {
  background: #f9fafb !important;
}

.insights-table th:first-child {
  padding-left: 10px;
}

.insights-table td:first-child {
  padding-left: 10px;
}

.insights-table td {
  padding: 8px 6px;
  font-size: 13px;
  color: #30a5bf;
  text-align: left;
  border-bottom: 1px solid #F3F3F3;
  vertical-align: middle;
}

/* Column widths */
.insights-table th:nth-child(1), 
.insights-table td:nth-child(1) {
  width: 14%;
  min-width: 150px;
}

.insights-table th:nth-child(2), 
.insights-table td:nth-child(2) {
  width: 9%;
  min-width: 100px;
}

.insights-table th:nth-child(3), 
.insights-table td:nth-child(3) {
  width: 7%;
  min-width: 85px;
}

.insights-table th:nth-child(4), 
.insights-table td:nth-child(4) {
  width: 11%;
  min-width: 120px;
}

.insights-table th:nth-child(5), 
.insights-table td:nth-child(5) {
  width: 7%;
  min-width: 70px;
}

.insights-table th:nth-child(6), 
.insights-table td:nth-child(6) {
  width: 8%;
  min-width: 80px;
}

.insights-table th:nth-child(7), 
.insights-table td:nth-child(7) {
  width: 25%;
  min-width: 250px;
}

.insights-table th:nth-child(8), 
.insights-table td:nth-child(8) {
  width: 8%;
  min-width: 100px;
}

.insights-table th:nth-child(9), 
.insights-table td:nth-child(9) {
  width: auto;
  min-width: 130px;
}

/* Company Name Cell */
.company-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-name-cell a {
  color: #30a5bf;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.company-name-cell a:hover {
  text-decoration: underline;
  color: #2891a8;
}

.company-name-cell .fa-external-link-alt {
  opacity: 0.5;
  font-size: 10px;
}

/* Owners Cell - matches company view exactly */
.insights-table .owners-cell {
  cursor: pointer;
}

.insights-table .owners-preview-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 10px;
}

.insights-table .owner-item-preview {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.insights-table .owner-name {
  font-weight: 500;
  color: #2c3e50;
  font-size: 12px;
}

/* Owners Count Badge */
.insights-table .owners-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #30a5bf;
  color: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
}

/* Add Owner Button */
.insights-table .cell-with-add-btn {
  text-align: left;
  vertical-align: middle;
}

.insights-table .cell-with-add-btn .btn-add-horizontal {
  opacity: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background-color: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.insights-table .cell-with-add-btn .btn-add-horizontal:hover {
  background-color: #e0e0e0;
  color: #333;
  border-color: #ccc;
}

.insights-table .cell-with-add-btn .btn-add-horizontal i {
  font-size: 10px;
}

/* Lead Temperature Badge - matches company view priority styling */
.lead-temp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.lead-temp-badge.temp-hot {
  background: #ffe4e6;
  color: #e11d48;
  border: none;
}

.lead-temp-badge.temp-warm {
  background: #fef3c7;
  color: #d97706;
  border: none;
}

.lead-temp-badge.temp-cold {
  background: #dbeafe;
  color: #2563eb;
  border: none;
}

.lead-temp-badge.temp-new {
  background: #dbeafe;
  color: #0891b2;
  border: none;
}

.lead-temp-badge .temp-icon {
  font-size: 11px;
}

/* Deal Stage Text - colored text without background */
.deal-stage-text {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.deal-stage-text.stage-negotiation {
  color: #7c3aed;
}

.deal-stage-text.stage-interest {
  color: #8b5cf6;
}

.deal-stage-text.stage-discovery {
  color: #6366f1;
}

/* Engagement Score */
.engagement-score {
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Probability Badge */
.probability-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  min-width: 45px;
}

/* Priority Badge for insights (HIGH, LOW indicators) */
.priority-indicator {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.priority-indicator.priority-high {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.priority-indicator.priority-low {
  background: linear-gradient(135deg, #cff4fc 0%, #9ee7f5 100%);
  color: #30a5bf;
  border: 1px solid #6dd4e7;
}

/* Next Action Cell */
/* Next Action Cell */
.next-action-cell {
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.next-action-cell .priority-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: white;
}

.next-action-cell .priority-badge.high {
  background: #ef4444;
}

.next-action-cell .priority-badge.medium {
  background: #f59e0b;
}

.next-action-cell .priority-badge.low {
  background: #6b7280;
}

.next-action-text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}

.next-action-expandable {
  position: relative;
  padding-right:30px;
}

.next-action-expandable .show-more-btn {
  background: none;
  border: none;
  color: #30a5bf;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.next-action-expandable .show-more-btn:hover {
  color: #2891a8;
  text-decoration: underline;
}

.next-action-expandable .show-more-btn i {
  font-size: 10px;
}

/* Draft Email Button - matches company view assistant buttons */
.draft-email-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: #30a5bf;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(48, 165, 191, 0.2);
}

.draft-email-btn:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(48, 165, 191, 0.3);
}

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

.draft-email-btn .sparkles-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  fill: currentColor;
}

/* Loading States */
.insights-table-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.insights-row-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
}

.insights-row-loading .tab-loader-spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
  margin: 0;
}

.insights-row-loading span {
  font-size: 13px;
  color: #6b7280;
}

/* Error States */
.insights-table-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.insights-table-error i {
  font-size: 48px;
  color: #ef4444;
  margin-bottom: 16px;
}

.insights-table-error p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 20px 0;
}

.insights-row-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: #ef4444;
}

.insights-row-error i {
  font-size: 16px;
}

.insights-row-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #9ca3af;
  font-size: 13px;
}

/* Search Input Wrapper and Icon */
.insights-search-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.insights-search-icon {
  position: absolute;
  left: 12px;
  color: #999;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

/* Search Input Styling - Insights Specific */
.insights-search-input {
  padding: 6px 15px 6px 35px;
  font-size: 14px;
  border: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 -1px 0px rgba(0,0,0,0.02);
  background-color: #fff;
  border-radius: 6px;
  outline: none;
  transition: all 0.2s ease;
  min-width: 200px;
}

.insights-search-input:focus {
  box-shadow: 0px 3px 3px -2px rgba(0, 0, 0, 0.2),
    0px 3px 4px 0px rgba(0, 0, 0, 0.14),
    0px 1px 8px 0px rgba(0, 0, 0, 0.12);
}

.insights-search-input::placeholder {
  color: #999;
}

/* Filter Tags - Insights Specific */
#insights-filter-tags-wrapper {
  margin-bottom: 5px;
}

#insights-filter-tags-header {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#insights-filter-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .insights-table {
    font-size: 12px;
  }
  
  .insights-table thead th,
  .insights-table tbody td {
    padding: 12px 8px;
  }
  
  .next-action-cell {
    max-width: 200px;
  }
}

@media (max-width: 768px) {
  .insights-table-wrapper {
    overflow-x: scroll;
  }
  
  .insights-table {
    min-width: 1000px;
  }
}

/* Deal Stages Management Modal */
.stages-list-section {
  margin-bottom: 30px;
}

.stages-list-section h4 {
  margin-top: 0;
}

.stages-list {
  max-height: none;
  overflow-y: visible;
  border: 1px solid #e4e7ee;
  border-radius: 6px;
  padding: 10px;
  background: #f9fafb;
}

.stages-list::-webkit-scrollbar {
  width: 8px;
}

.stages-list::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 4px;
}

.stages-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.stages-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.no-stages {
  text-align: center;
  color: #999;
  padding: 30px 20px;
  font-style: italic;
}

.stage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e4e7ee;
  border-radius: 6px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.stage-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: #30a5bf;
}

.stage-item.inactive {
  opacity: 0.6;
  background: #f9fafb;
}

.stage-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid #e4e7ee;
  flex-shrink: 0;
}

.stage-name {
  font-weight: 600;
  font-size: 14px;
  color: #2c3e50;
}

.stage-order-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 10px;
  font-weight: 600;
}

.stage-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.stage-badge.inactive-badge {
  background: #fee2e2;
  color: #991b1b;
}

.stage-description {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  margin-left: 30px;
}

.stage-actions {
  display: flex;
  gap: 6px;
}

.stage-actions .btn-edit,
.stage-actions .btn-delete,
.stage-actions .btn-toggle {
  padding: 6px 10px;
  border: 1px solid #e4e7ee;
  background: white;
  color: #6b7280;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
}

.stage-actions .btn-edit:hover {
  background: #dbeafe;
  color: #2563eb;
  border-color: #2563eb;
}

.stage-actions .btn-delete:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #dc2626;
}

.stage-actions .btn-toggle:hover {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #16a34a;
}

.add-stage-section {
  background: #f9fafb;
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #e4e7ee;
}

.add-stage-section h4 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #2c3e50;
}

.add-stage-section .form-group {
  margin-bottom: 15px;
}

.add-stage-section .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #2c3e50;
}

.add-stage-section .form-group input[type="text"],
.add-stage-section .form-group input[type="number"],
.add-stage-section .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}

.add-stage-section .form-group input:focus,
.add-stage-section .form-group textarea:focus {
  outline: none;
  border-color: #30a5bf;
  box-shadow: 0 0 0 3px rgba(48, 165, 191, 0.1);
}

.add-stage-section .help-text {
  margin-top: 4px;
  font-size: 0.85rem;
  color: #6c757d;
}

.stage-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.stage-form-actions .btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.stage-form-actions .btn-primary {
  background: #30a5bf;
  color: white;
}

.stage-form-actions .btn-primary:hover {
  background: #2890a8;
}

.stage-form-actions .btn-secondary {
  background: #6b7280;
  color: white;
}

.stage-form-actions .btn-secondary:hover {
  background: #4b5563;
}

/* Global Insights Status Indicator */
.insights-global-status {
  background: white;
  border-radius: 8px;
  padding: 8px 16px;
  box-shadow: 0px 3px 10px #0000001a;
  border: 1px solid #e5e7eb;
  display: none;
  align-items: center;
  font-size: 12px;
  gap: 8px;
  margin-left: auto;
  animation: slideInRight 0.3s ease;
}

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

.insights-global-status .status-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.insights-global-status .status-spinner {
  display: none;
  width: 20px !important;
  height: 20px !important;
  border-width: 2px !important;
  flex-shrink: 0;
}

.insights-global-status .status-success {
  display: none;
  width: 16px !important;
  height: 16px !important;
  color: #10b981;
}

.insights-global-status .status-text {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.insights-global-status.loading .status-text {
  color: #30a5bf;
}

.insights-global-status.success .status-text {
  color: #10b981;
}