/* public/styles/stock-market-table.css */
/* CoinMarketCap-inspired Stock Market Table for Listings */

.stock-market-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px 15px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 11px;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* ========================================
   HEADER
   ======================================== */

.stock-market-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #333333;
  box-shadow: 0 8px 32px #000000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.market-title {
  font-size: 24px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
  color: #f0f0f0;
  text-shadow: 0 2px 8px #000000;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #10B981;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    background: white;
  }
  50% {
    background: #cccccc;
  }
}

.live-text {
  letter-spacing: 0.5px;
}

.last-update {
  font-size: 11px;
  color: #6B7280;
  font-weight: 500;
}

.header-right {
  display: flex;
  gap: 10px;
}

.refresh-btn {
  background: #3B82F6;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-transform: uppercase;
}

.refresh-btn:hover {
  background: #2563EB;
}

.refresh-btn:active {
  transform: scale(0.95);
}

/* ========================================
   FILTERS
   ======================================== */

.stock-market-filters {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #333333;
  flex-wrap: wrap;
  box-shadow: 0 8px 32px #000000;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #b3b3b3;
  letter-spacing: 0.5px;
}

.filter-select,
.search-input {
  padding: 8px 12px;
  border: 1px solid #333333;
  border-radius: 8px;
  font-size: 11px;
  background: #2a2a2a;
  color: #f0f0f0;
  min-width: 150px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-select:focus,
.search-input:focus {
  outline: none;
  border-color: #555555;
  background: #333333;
  box-shadow: 0 0 20px #1a1a1a;
}

.filter-select option {
  background: #1a1a1a;
  color: white;
}

.search-input {
  min-width: 250px;
}

/* ========================================
   TABLE
   ======================================== */

.table-wrapper {
  overflow-x: auto;
  background: #1a1a1a;
  border: 1px solid #333333;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px #000000;
}

.stock-market-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.stock-market-table thead {
  background: #0d0d0d;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #333333;
}

.stock-market-table th {
  padding: 4px 4px;
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #b3b3b3;
  font-size: 10px;
  white-space: nowrap;
}

/* Center align for position, change, category, views, fav, kom, and data headers */
.stock-market-table th:nth-child(1),
.stock-market-table th:nth-child(2),
.stock-market-table th:nth-child(3),
.stock-market-table th:nth-child(5),
.stock-market-table th:nth-child(6),
.stock-market-table th:nth-child(7),
.stock-market-table th:nth-child(8) {
  text-align: center;
}

/* Center align content for same columns */
.stock-market-table td:nth-child(1),
.stock-market-table td:nth-child(2),
.stock-market-table td:nth-child(3),
.stock-market-table td:nth-child(5),
.stock-market-table td:nth-child(6),
.stock-market-table td:nth-child(7),
.stock-market-table td:nth-child(8) {
  text-align: center;
}

.stock-market-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px;
}

.stock-market-table th.sortable:hover {
  background: #2a2a2a;
  color: #f0f0f0;
}

.stock-market-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 6px;
  color: #666666;
  font-size: 10px;
}

.stock-market-table th.sort-asc::after {
  content: '▲';
  color: #3B82F6;
}

.stock-market-table th.sort-desc::after {
  content: '▼';
  color: #3B82F6;
}

.stock-market-table tbody tr {
  border-bottom: 1px solid #1a1a1a;
  transition: all 0.2s ease;
}

.stock-market-table tbody tr:hover {
  background: #2a2a2a;
  box-shadow: inset 0 0 20px #1a1a1a;
}

.stock-market-table td {
  padding: 4px 4px;
  color: #e6e6e6;
  font-weight: 500;
}

/* ========================================
   TABLE CELLS
   ======================================== */

.position-cell {
  font-weight: 700;
  color: #6B7280;
  text-align: center;
  position: relative;
}

.premium-badge {
  position: absolute;
  top: 8px;
  right: 4px;
  font-size: 12px;
}

.change-cell {
  text-align: center;
  font-weight: 600;
  font-size: 10px;
}

.position-change {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
}

.position-change.up {
  color: #10B981;
  background: #1a3a2e;
}

.position-change.down {
  color: #EF4444;
  background: #3a1a1a;
}

.position-change.neutral {
  color: #999999;
  background: #2a2a2a;
}

.position-change.new {
  color: #FFC700;
  background: #3a3020;
  animation: flash 2s ease-in-out;
}

@keyframes flash {
  0%, 100% {
    background: #3a3020;
  }
  50% {
    background: #4a4030;
  }
}

.category-cell {
  text-align: center;
}

.category-emoji {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.title-cell {
  font-weight: 700;
  text-transform: uppercase;
}

.listing-link {
  color: #f0f0f0;
  text-decoration: none;
  transition: all 0.2s ease;
}

.listing-link:hover {
  color: #60A5FA;
  text-shadow: 0 0 10px #3B82F6;
  text-decoration: none;
}

.description-cell {
  font-size: 10px;
  color: #999999;
  line-height: 1.4;
}

.city-cell {
  color: #bfbfbf;
  text-transform: capitalize;
}

.rating-cell {
  font-weight: 700;
  color: #F59E0B;
  text-align: center;
}

.views-cell,
.favorites-cell,
.comments-cell {
  text-align: center;
  font-weight: 600;
  color: #cccccc;
}

/* Favorites display (non-clickable) */
.favorites-display {
  color: #cccccc;
  font-weight: 600;
  font-size: 11px;
}

/* Comments link */
.comments-link {
  color: #cccccc;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
  cursor: pointer;
}

.comments-link:hover {
  color: #60A5FA;
  text-decoration: underline;
}

/* Author cell */
.author-cell {
  text-align: left;
  font-weight: 600;
  color: #bfbfbf;
}

.author-link {
  color: #bfbfbf;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.author-link:hover {
  color: #60A5FA;
  text-shadow: 0 0 10px #3B82F6;
  text-decoration: none;
}

/* Old favorite button styles (kept for backward compatibility) */
.favorite-btn {
  background: #2a2a2a;
  border: 1px solid #333333;
  color: #e6e6e6;
  cursor: pointer;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 11px;
}

.favorite-btn:hover {
  background: #4d1f1f;
  border-color: #7f2222;
  transform: scale(1.05);
  box-shadow: 0 4px 15px #4d1f1f;
}

.favorite-btn.favorited {
  animation: heartbeat 0.5s;
}

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1.1);
  }
}

.date-cell {
  color: #808080;
  text-align: right;
  font-size: 10px;
}

/* ========================================
   ROW STATES
   ======================================== */

.listing-row.new-listing {
  background: #2a2a2a;
  border-left: 3px solid #FFC700;
}

.listing-row.position-changed {
  animation: slide-fade 1s ease-out;
}

@keyframes slide-fade {
  0% {
    background: #DBEAFE;
    transform: translateX(-5px);
  }
  100% {
    background: transparent;
    transform: translateX(0);
  }
}

.listing-row.flash-new {
  animation: flash-yellow 3s ease-in-out;
}

@keyframes flash-yellow {
  0%, 100% {
    background: transparent;
  }
  10%, 30%, 50% {
    background: #FEF3C7;
  }
}

/* ========================================
   LOADING & EMPTY STATES
   ======================================== */

.loading-row,
.empty-row,
.error-row {
  text-align: center;
  padding: 40px 20px;
  color: #6B7280;
  font-size: 12px;
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #E5E7EB;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

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

.error-row {
  color: #EF4444;
  background: #FEE2E2;
}

/* ========================================
   FOOTER
   ======================================== */

.stock-market-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px 20px;
  margin-bottom: 80px;
  font-size: 11px;
  color: #b3b3b3;
  position: relative;
}

.stats {
  font-weight: 600;
  text-align: center;
}

.stock-market-footer .load-more-btn {
  position: absolute;
  left: 20px;
  background: #2a2a2a;
  color: #f0f0f0;
  border: 1px solid #333333;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.stock-market-footer .load-more-btn:hover {
  background: #3a3a3a;
  border-color: #555555;
  box-shadow: 0 4px 15px #1a1a1a;
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */

@media (max-width: 768px) {
  .stock-market-wrapper {
    padding: 10px;
    font-size: 10px;
  }

  .market-title {
    font-size: 18px;
  }

  .stock-market-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .stock-market-filters {
    flex-direction: column;
    gap: 10px;
  }

  .filter-select,
  .search-input {
    width: 100%;
    min-width: unset;
  }

  .table-wrapper {
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
  }

  .stock-market-table {
    min-width: 1200px;
  }

  .stock-market-table th,
  .stock-market-table td {
    padding: 4px 3px;
  }

  .description-cell {
    display: none;
  }

  .stock-market-footer {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}

/* ========================================
   DESKTOP WIDE (1920px)
   ======================================== */

@media (min-width: 1920px) {
  .stock-market-wrapper {
    max-width: 1920px;
  }

  .stock-market-table th,
  .stock-market-table td {
    padding: 4px 4px;
  }

  .market-title {
    font-size: 28px;
  }
}

/* ========================================
   USER PROFILE VIEW
   ======================================== */

.user-profile-view {
  padding: 20px;
  color: #e6e6e6;
}

.profile-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #333333;
}

.profile-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #f0f0f0;
}

.profile-header h2 i {
  margin-right: 8px;
  color: #60A5FA;
}

.profile-stats {
  font-size: 12px;
  color: #999999;
  margin: 0;
}

.user-profile-listings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-listing-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-listing-card:hover {
  background: #2a2a2a;
  border-color: #3a3a3a;
  transform: translateX(4px);
}

.listing-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.listing-card-emoji {
  font-size: 20px;
  flex-shrink: 0;
}

.listing-card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: #f0f0f0;
}

.listing-card-type {
  font-size: 11px;
  color: #60A5FA;
  margin: 4px 0;
  font-weight: 600;
}

.listing-card-city {
  font-size: 11px;
  color: #999999;
  margin: 2px 0;
}

.listing-card-date {
  font-size: 10px;
  color: #808080;
  margin: 4px 0 8px 0;
}

.listing-card-stats {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: #b3b3b3;
}

.listing-card-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .stock-market-header,
  .stock-market-filters,
  .stock-market-footer,
  .refresh-btn,
  .favorite-btn {
    display: none;
  }

  .stock-market-table {
    border: 1px solid #000;
  }

  .stock-market-table th,
  .stock-market-table td {
    border: 1px solid #000;
    padding: 8px;
  }
}

/* Gold separator lines after rows 3 and 10 */
.listing-row.separator-row {
  border-bottom: 1px solid #FFD700 !important;
}
