/* Intelligence Dashboard - Modern Bento Grid Design */
:root {
  --primary: #1a1a1a;
  --secondary: #2a2a2a;
  --accent: #3498db;
  --text: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --success: #2ecc71;
  --warning: #f1c40f;
  --danger: #e74c3c;
  --card-bg: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius: 16px;
}

.intelligence-dashboard {
  background: var(--primary);
  min-height: 100vh;
  padding: 2rem;
  color: var(--text);
}

.dashboard-header {
  margin-bottom: 2rem;
  text-align: center;
}

.company-logo {
  max-width: 200px;
  height: auto;
  margin-bottom: 1rem;
}

.dashboard-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #3498db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.dashboard-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Bento Grid Layout */
.intelligence-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Intelligence Card Base Styles */
.intel-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.intel-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.intel-card.expanded {
  grid-column: span 3;
  min-height: 500px;
}

/* Card Header */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rescrape-btn {
  background: rgba(52, 152, 219, 0.2);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

.rescrape-btn:hover {
  background: var(--accent);
  color: var(--primary);
  transform: rotate(180deg);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-icon {
  font-size: 1.5rem;
}

.card-status {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-completed { 
  background: rgba(46, 204, 113, 0.2); 
  color: #2ecc71; 
}

.status-loading { 
  background: rgba(241, 196, 15, 0.2); 
  color: #f1c40f; 
  animation: pulse 2s infinite;
}

.status-error { 
  background: rgba(231, 76, 60, 0.2); 
  color: #e74c3c; 
}

.status-pending { 
  background: rgba(255, 255, 255, 0.1); 
  color: var(--text-secondary); 
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Card Footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-border);
  gap: 0.75rem;
}

.expand-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  flex: 1;
}

.expand-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--accent);
}

/* Updated Raw Data Toggle */
.raw-data-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  flex: 1;
}

.raw-data-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--accent);
}

/* Card Content Cursor */
.card-content {
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  padding: 0.5rem;
  margin: -0.5rem;
  flex: 1;
}

.card-content:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Data Visualization */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.data-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
}

.data-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.data-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Raw Data View */
.raw-data-view {
  display: none;
  background: var(--secondary);
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1rem;
  overflow: auto;
  max-height: 400px;
}

.raw-data-view.visible {
  display: block;
}

.raw-data-view pre {
  margin: 0;
  font-family: 'Fira Code', monospace;
  font-size: 0.875rem;
  color: var(--text);
}

/* Modal View - FIXED VERSION */
.intel-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
  padding: 20px;
  box-sizing: border-box;
}

.intel-modal.visible,
.intel-modal.active {
  display: flex !important;
}

.modal-content {
  background: var(--primary);
  border-radius: var(--radius);
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 800px;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--card-border);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--text);
  font-size: 24px;
  font-weight: bold;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: all 0.3s ease;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 0, 0, 0.3);
  transform: scale(1.1);
  color: #ff4444;
}

/* Modal Content Structure */
.modal-header {
  background: var(--secondary);
  padding: 1.5rem;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.modal-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .intelligence-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .intel-card.expanded {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .intelligence-grid {
    grid-template-columns: 1fr;
  }
  
  .intel-card.expanded {
    grid-column: span 1;
  }
  
  .dashboard-title {
    font-size: 2rem;
  }
  
  .dashboard-subtitle {
    font-size: 1rem;
  }
  
  .intel-card {
    padding: 1rem;
  }
}

/* Animations */
@keyframes cardExpand {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.intel-card {
  animation: cardExpand 0.3s ease forwards;
}

/* Loading States */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1) 25%,
    rgba(255, 255, 255, 0.15) 37%,
    rgba(255, 255, 255, 0.1) 63%
  );
  background-size: 400% 100%;
  animation: skeletonLoading 1.4s ease infinite;
}

@keyframes skeletonLoading {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* Expanded Card Styles */
.expanded-overview,
.expanded-market-position,
.expanded-competitor-analysis,
.expanded-local-presence,
.expanded-sentiment-analysis,
.expanded-brand-analysis {
    padding: 2rem;
    color: var(--text);
}

.classification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
}

.classification-header h2 {
    font-size: 2rem;
    margin: 0;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.confidence-badge,
.targets-badge,
.digital-score {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
    font-weight: 500;
}

.content-section {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 2rem;
}

.analysis-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.analysis-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.analysis-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.analysis-section li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.analysis-section li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Competitor Cards */
.competitors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.competitor-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--card-border);
}

.competitor-card.priority-high { border-color: var(--danger); }
.competitor-card.priority-medium { border-color: var(--warning); }
.competitor-card.priority-low { border-color: var(--success); }

.competitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.target-id {
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.priority-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.priority-high .priority-badge { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.priority-medium .priority-badge { background: rgba(241, 196, 15, 0.2); color: #f1c40f; }
.priority-low .priority-badge { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }

/* Local Presence */
.presence-metrics {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.location-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.location-details {
    margin-top: 1rem;
}

.rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.contact p {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Reviews & Sentiment */
.sentiment-metrics {
    display: flex;
    justify-content: space-around;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.review-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.review-card.positive { border: 1px solid var(--success); }
.review-card.negative { border: 1px solid var(--danger); }
.review-card.neutral { border: 1px solid var(--text-secondary); }

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sentiment-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.sentiment-badge.positive { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.sentiment-badge.negative { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.sentiment-badge.neutral { background: rgba(255, 255, 255, 0.1); color: var(--text); }

.review-content blockquote {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-style: italic;
}

/* Brand Analysis */
.brand-summary {
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
}

/* Responsive Adjustments for Expanded Views */
@media (max-width: 1200px) {
    .analysis-grid {
        grid-template-columns: 1fr;
    }
    
    .presence-metrics {
        flex-direction: column;
        gap: 1rem;
    }
    
    .sentiment-metrics {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .classification-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .competitors-grid,
    .locations-grid,
    .reviews-grid {
        grid-template-columns: 1fr;
    }
}

/* Error state styling */
.intel-card.error {
  border-color: var(--danger);
}

.intel-card.loading {
  border-color: var(--warning);
}

.intel-card.completed {
  border-color: var(--success);
}

/* Data Status Indicator */
.data-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.2);
}

/* Reviews Modal Fixes */
.expanded-sentiment-analysis {
  padding: 1.5rem;
  color: var(--text);
  max-height: 80vh;
  overflow-y: auto;
}

.sentiment-header {
  margin-bottom: 2rem;
  text-align: center;
}

.sentiment-header h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sentiment-metrics {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.sentiment-metrics .metric {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  min-width: 120px;
}

.sentiment-metrics .metric.positive {
  background: rgba(40, 167, 69, 0.2);
  border: 1px solid rgba(40, 167, 69, 0.4);
}

.sentiment-metrics .metric.negative {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid rgba(220, 53, 69, 0.4);
}

.sentiment-metrics .metric.neutral {
  background: rgba(108, 117, 125, 0.2);
  border: 1px solid rgba(108, 117, 125, 0.4);
}

.reviews-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.review-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.review-item.positive {
  border-left: 4px solid #28a745;
  background: rgba(40, 167, 69, 0.05);
}

.review-item.negative {
  border-left: 4px solid #dc3545;
  background: rgba(220, 53, 69, 0.05);
}

.review-item.neutral {
  border-left: 4px solid #6c757d;
  background: rgba(108, 117, 125, 0.05);
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.review-id {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sentiment-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sentiment-badge.positive {
  background: rgba(40, 167, 69, 0.2);
  color: #28a745;
}

.sentiment-badge.negative {
  background: rgba(220, 53, 69, 0.2);
  color: #dc3545;
}

.sentiment-badge.neutral {
  background: rgba(108, 117, 125, 0.2);
  color: #6c757d;
}

.review-content {
  margin-top: 1rem;
}

.review-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.review-text {
  margin: 0;
  padding: 1rem;
  border-radius: 8px;
  font-style: italic;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid;
}

.review-text.positive {
  border-left-color: #28a745;
  background: rgba(40, 167, 69, 0.1);
}

.review-text.negative {
  border-left-color: #dc3545;
  background: rgba(220, 53, 69, 0.1);
}

.review-text.neutral {
  border-left-color: #6c757d;
  background: rgba(108, 117, 125, 0.1);
}

.review-rating {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rating-value {
  font-weight: 500;
  color: var(--text-secondary);
}

/* Modal Enhancements */


/* Scrollbar Styling */
.reviews-container::-webkit-scrollbar {
  width: 6px;
}

.reviews-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.reviews-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.reviews-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
} 