/* Market Redesign - CryptoRank Style */

/* Reset and Base */
.market-container * {
  box-sizing: border-box;
}

.market-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fafbfc;
  min-height: calc(100vh - 80px);
}

/* Compact Header Section */
.market-header {
  background: white;
  border-radius: 12px;
  padding: 20px 30px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.header-content {
  display: flex;
  align-items: flex-start;
  gap: 40px;
}

.header-left {
  flex: 1;
  max-width: 50%;
}

.header-right {
  flex: 1;
  max-width: 50%;
}

.market-title {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 12px 0;
}

.market-disclaimer {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

.market-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 12px !important;
  text-align: center;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: auto;
  gap: 3px;
}

.stat-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.stat-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  padding: 0;
  display: block;
  font-weight: 500;
  line-height: 1;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  display: block;
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* Main Content Layout */
.market-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Table Container (70-80%) */
.market-table-container {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

/* Table Controls */
.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  font-size: 14px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: #425DCF;
  box-shadow: 0 0 0 3px rgba(66, 93, 207, 0.1);
}

.filter-buttons {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 6px 16px;
  border: 1px solid #e5e7eb;
  background: white;
  border-radius: 6px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.filter-btn:hover {
  border-color: #425DCF;
  color: #425DCF;
}

.filter-btn.active {
  background: #425DCF;
  color: white;
  border-color: #425DCF;
}

.btn-download {
  padding: 8px 16px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.btn-download:hover {
  background: #e5e7eb;
}

/* Table Styles - CryptoRank Inspired */
.services-table-redesign {
  width: 100%;
  border-collapse: collapse;
}

.services-table-redesign thead {
  border-bottom: 1px solid #e5e7eb;
}

.services-table-redesign th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: transparent;
  user-select: none;
}

.services-table-redesign th.sortable {
  cursor: pointer;
  position: relative;
}

.services-table-redesign th.sortable i {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.services-table-redesign th.sortable:hover i {
  opacity: 1;
}

/* Table Rows */
.table-row {
  border-bottom: 1px solid #f3f4f6;
  transition: all 0.2s;
}

.table-row:hover {
  background: #f9fafb;
}

/* Featured Row (Netts) */
.featured-row {
  background: linear-gradient(90deg, rgba(66, 93, 207, 0.03) 0%, rgba(66, 93, 207, 0.01) 100%);
  border-left: 3px solid #425DCF;
}

.featured-row:hover {
  background: linear-gradient(90deg, rgba(66, 93, 207, 0.05) 0%, rgba(66, 93, 207, 0.02) 100%);
}

.services-table-redesign td {
  padding: 16px;
  vertical-align: middle;
}

/* Tier Column */
.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.tier-1 {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.tier-2 {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

.tier-3 {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

/* Provider Info */
.provider-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.provider-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: #f9fafb;
  padding: 4px;
}

.provider-details {
  display: flex;
  flex-direction: column;
}

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

.provider-tag {
  font-size: 12px;
  color: #6b7280;
}

.realtime-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  color: #10b981;
  font-size: 12px;
  cursor: help;
}

.realtime-indicator i {
  font-size: 14px;
  animation: pulse 2s infinite;
}

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

.reseller-badge {
  font-size: 10px;
  color: #6b7280;
  margin-left: 4px;
  vertical-align: super;
  font-style: italic;
}

/* Price Column */
.td-price {
  font-weight: 600;
}

.price-value {
  font-size: 16px;
  color: #425DCF;
}

.price-unit {
  font-size: 12px;
  color: #6b7280;
  margin-left: 4px;
}

.price-extra {
  font-size: 11px;
  color: #9ca3af;
  margin-left: 4px;
}

.price-na {
  font-size: 14px;
  color: #9ca3af;
  font-style: italic;
}

/* Energy Values */
.energy-value {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

/* Type Badges */
.type-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.type-badge {
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 11px;
  color: #4b5563;
  font-weight: 500;
}

.api-badge {
  padding: 4px 8px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Action Links */
.action-links {
  display: flex;
  gap: 8px;
}

.action-link {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #6b7280;
  transition: all 0.2s;
}

.action-link:hover {
  background: #f3f4f6;
  color: #425DCF;
}

/* Sidebar (20-30%) */
.market-sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
}

/* Sidebar Cards */
.sidebar-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 16px;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.action-btn.primary {
  background: #425DCF;
  color: white;
}

.action-btn.primary:hover {
  background: #3649b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(66, 93, 207, 0.25);
}

.action-btn.secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.action-btn.secondary:hover {
  background: #e5e7eb;
}

/* Activity Chart */
.activity-chart {
  margin-bottom: 16px;
  height: 120px;
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
}

.activity-stats {
  display: flex;
  justify-content: space-between;
}

.activity-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.activity-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.activity-value {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

/* Top Services */
.top-services {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-service {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.top-service:hover {
  background: #f9fafb;
}

.service-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.service-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

.service-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.service-name {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
}

.service-price {
  font-size: 14px;
  font-weight: 600;
  color: #425DCF;
}

/* Add Project Card */
.add-project {
  background: linear-gradient(135deg, #425DCF 0%, #0050FE 100%);
  color: white;
}

.add-project .card-title {
  color: white;
}

.card-description {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Center content in chat card */
.sidebar-card:has(#openChatBtn) {
  text-align: center;
}

.sidebar-card:has(#openChatBtn) .card-description {
  color: #6b7280;
}

.btn-add-project {
  width: 100%;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-add-project:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  color: white;
}

/* Table wrapper for mobile scroll */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .market-content {
    flex-direction: column;
  }
  
  .market-table-container {
    width: 100%;
  }
  
  .market-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .sidebar-card {
    flex: 1;
    min-width: 280px;
  }
}

/* Mobile two-row layout for table */
@media (max-width: 768px) {
  .market-container {
    padding: 10px;
  }
  
  .market-header {
    padding: 16px;
    margin-bottom: 15px;
  }
  
  /* Fix table container margins on mobile */
  .market-table-container {
    margin: 0;
    width: 100%;
  }
  
  /* Remove horizontal scroll wrapper on mobile */
  .table-responsive-wrapper {
    overflow-x: visible;
    margin: 0;
    padding: 0;
  }
  
  /* Make table full width */
  .services-table-redesign {
    min-width: 100%;
    width: 100%;
  }
  
  /* Hide table header on mobile */
  .services-table-redesign thead {
    display: none;
  }
  
  /* Convert each row to a mobile card with grid */
  .services-table-redesign tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 12px;
    background: white;
  }
  
  .services-table-redesign tbody tr.featured-row {
    border-left: 3px solid #425DCF;
  }
  
  /* Reset all cells */
  .services-table-redesign td {
    display: block;
    border: none;
    padding: 0;
  }
  
  /* Grid positioning */
  .services-table-redesign .td-tier {
    grid-column: 1;
    grid-row: 1;
  }
  
  .services-table-redesign .td-name {
    grid-column: 2;
    grid-row: 1;
  }
  
  .services-table-redesign .td-price {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    background: #f0f4ff;
    padding: 4px 8px;
    border-radius: 6px;
    align-self: center;
  }
  
  .services-table-redesign .td-available {
    grid-column: 1;
    grid-row: 2;
    font-size: 12px;
  }
  
  .services-table-redesign .td-total {
    grid-column: 2;
    grid-row: 2;
    font-size: 12px;
  }
  
  .services-table-redesign .td-type {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
  
  .services-table-redesign .td-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    gap: 8px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
  }
  
  /* Add labels for mobile */
  .services-table-redesign .td-available::before {
    content: 'Avail: ';
    font-size: 10px;
    color: #6b7280;
  }
  
  .services-table-redesign .td-total::before {
    content: 'Total: ';
    font-size: 10px;
    color: #6b7280;
  }
  
  /* Mobile specific adjustments */
  .tier-badge {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .provider-info {
    gap: 8px;
  }
  
  .provider-logo {
    width: 28px;
    height: 28px;
  }
  
  .provider-name {
    font-size: 13px;
  }
  
  .provider-tag {
    font-size: 11px;
  }
  
  .price-value {
    font-size: 18px;
    font-weight: 700;
    color: #425DCF;
  }
  
  .price-unit {
    font-size: 14px;
    font-weight: 600;
  }
  
  .price-extra {
    display: none;
  }
  
  .price-na {
    font-size: 16px;
    font-weight: 600;
    color: #9ca3af;
  }
  
  .type-badge,
  .api-badge {
    font-size: 9px;
    padding: 2px 5px;
  }
  
  .action-link {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  
  .header-content {
    flex-direction: column;
    gap: 20px;
  }
  
  .header-left,
  .header-right {
    max-width: 100%;
    width: 100%;
  }
  
  .market-title {
    font-size: 20px;
    margin-bottom: 8px;
  }
  
  .market-disclaimer {
    font-size: 13px;
  }
  
  .market-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin: 0 auto;
  }
  
  .stat-item {
    padding: 5px 10px !important;
  }
  
  .stat-label {
    font-size: 10px;
    margin-bottom: 2px;
  }
  
  .stat-value {
    font-size: 14px;
  }
  
  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    max-width: 100%;
  }
  
  .filter-buttons {
    width: 100%;
    overflow-x: auto;
  }
  
  /* Table container mobile styles */
  .market-table-container {
    padding: 12px;
    overflow: hidden;
  }
  
  .market-sidebar {
    flex-direction: column;
  }
  
  .sidebar-card {
    min-width: auto;
  }
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #425DCF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Update Animation */
.value-update {
  animation: valueFlash 0.5s ease;
}

@keyframes valueFlash {
  0% { background-color: transparent; }
  50% { background-color: rgba(66, 93, 207, 0.1); }
  100% { background-color: transparent; }
}

/* Chat Overlay Styles */
.chat-overlay {
  position: fixed;
  bottom: -600px;
  right: 20px;
  width: 380px;
  height: 580px;
  background: white;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transition: bottom 0.3s ease;
  z-index: 1050;
}

.chat-overlay.active {
  bottom: 0;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 16px 20px;
  background: #425DCF;
  color: white;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.chat-header-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-header h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.chat-subtitle {
  font-size: 13px;
  opacity: 0.9;
  color: white;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
}

.chat-message {
  margin-bottom: 16px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: #6b7280;
}

.chat-wallet {
  font-weight: 600;
  color: #425DCF;
}

.chat-time {
  font-size: 11px;
}

.chat-message-text {
  font-size: 14px;
  color: #1a1a1a;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-loading {
  text-align: center;
  color: #6b7280;
  padding: 40px;
}

.chat-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.chat-not-connected {
  text-align: center;
  padding: 20px;
}

.chat-not-connected i {
  font-size: 32px;
  color: #f59e0b;
  margin-bottom: 12px;
}

.chat-not-connected p {
  color: #6b7280;
  margin-bottom: 16px;
}

.chat-connected {
  display: flex;
  gap: 8px;
}

#chatInput {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#chatInput:focus {
  border-color: #425DCF;
}

.chat-send-btn {
  padding: 10px 16px;
  background: #425DCF;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover {
  background: #3649b3;
  transform: translateY(-1px);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-status {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.chat-status i {
  font-size: 14px;
}

.chat-status.connected {
  color: #10b981;
  font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-overlay {
    width: 100%;
    right: 0;
    left: 0;
    border-radius: 12px 12px 0 0;
  }
}