/**
 * Professional Markets Page CSS
 * Consistent styling for cryptocurrency markets display
 */

:root {
    /* Market specific colors */
    --market-gain: #22c55e;
    --market-loss: #ef4444;
    --market-neutral: #6b7280;
    --market-highlight: #5d4fe8;
    --market-card-bg: linear-gradient(135deg, rgba(30, 30, 50, 0.6) 0%, rgba(20, 20, 40, 0.4) 100%);
}

/* Market Stats Cards */
.market-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.market-stat-card {
    background: var(--market-card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.market-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--market-highlight), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.market-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(93, 79, 232, 0.2);
}

.market-stat-card:hover::before {
    opacity: 1;
}

.market-stat-card.gain {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
    border-color: rgba(34, 197, 94, 0.2);
}

.market-stat-card.gain:hover {
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.3);
}

.market-stat-card.loss {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border-color: rgba(239, 68, 68, 0.2);
}

.market-stat-card.loss:hover {
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.stat-label {
    color: var(--table-text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-value {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-symbol {
    font-size: 24px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--table-text-primary);
}

.stat-change {
    font-size: 18px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.stat-change.positive {
    color: var(--market-gain);
}

.stat-change.negative {
    color: var(--market-loss);
}

.stat-price {
    font-size: 14px;
    color: var(--table-text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

/* Market Category Cards */
.market-categories-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.market-category-card {
    background: var(--market-card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    height: 100%;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.category-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--table-text-primary);
}

.category-icon {
    width: 28px;
    height: 28px;
    background: rgba(93, 79, 232, 0.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--market-highlight);
}

.category-action {
    font-size: 12px;
    color: var(--market-highlight);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.category-action:hover {
    color: #7b6ff0;
}

/* Mini Table Styles */
.mini-table {
    width: 100%;
}

.mini-table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.2s;
    cursor: pointer;
}

.mini-table-row:last-child {
    border-bottom: none;
}

.mini-table-row:hover {
    background: rgba(93, 79, 232, 0.05);
    margin: 0 -10px;
    padding: 12px 10px;
    border-radius: 8px;
}

.mini-table-symbol {
    display: flex;
    align-items: center;
    gap: 4px;  /* Reduced from 8px for tighter alignment */
    flex: 1;
}

.coin-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* SVG icon styles */
.coin-icon .coin-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Fallback letter style when SVG fails to load */
.coin-icon .coin-letter {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.coin-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.coin-ticker {
    font-size: 14px;
    font-weight: 600;
    color: var(--table-text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.coin-fullname {
    font-size: 11px;
    color: var(--table-text-secondary);
}

.mini-table-price {
    font-size: 14px;
    font-weight: 500;
    color: var(--table-text-primary);
    font-family: 'JetBrains Mono', monospace;
    text-align: right;
    margin-right: 15px;
}

.mini-table-change {
    min-width: 80px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

.mini-table-change.positive {
    background: rgba(34, 197, 94, 0.15);
    color: var(--market-gain);
}

.mini-table-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--market-loss);
}

/* Main Markets Section */
.markets-main-section {
    background: var(--market-card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 0;
    overflow: hidden;
}

/* Markets Controls */
.markets-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.01);
    flex-wrap: wrap;
    gap: 15px;
}

.markets-tabs {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 10px;
}

.market-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--table-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    white-space: nowrap;  /* Prevent text wrapping */
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.market-tab:hover {
    color: var(--table-text-primary);
}

.market-tab.active {
    background: var(--market-highlight);
    color: white;
    position: relative;
    z-index: 1;
    font-weight: 600;
    padding: 10px 20px;
}

.markets-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.market-search {
    position: relative;
}

.market-search-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 12px 8px 36px;
    color: var(--table-text-primary);
    font-size: 14px;
    width: 250px;
    transition: all 0.3s;
}

.market-search-input:focus {
    outline: none;
    border-color: var(--market-highlight);
    background: rgba(255, 255, 255, 0.08);
}

.market-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--table-text-secondary);
    font-size: 14px;
}

.market-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-label {
    font-size: 13px;
    color: var(--table-text-secondary);
}

.sort-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--table-text-primary);
    font-size: 13px;
    cursor: pointer;
}

.sort-select:focus {
    outline: none;
    border-color: var(--market-highlight);
}

/* Markets Table */
.markets-table-container {
    width: 100%;
    overflow-x: auto;
    position: relative;
}

.markets-table {
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

/* Column width suggestions */
.markets-table th:nth-child(1),
.markets-table td:nth-child(1) { width: auto; min-width: 30px; max-width: 60px; text-align: center; } /* Rank */
.markets-table th:nth-child(2),
.markets-table td:nth-child(2) { width: 20%; min-width: 150px; } /* Name */
.markets-table th:nth-child(3),
.markets-table td:nth-child(3) { width: 12%; min-width: 100px; } /* Price */
.markets-table th:nth-child(4),
.markets-table td:nth-child(4) { width: 10%; min-width: 80px; } /* 24h % */
.markets-table th:nth-child(5),
.markets-table td:nth-child(5) { width: 15%; min-width: 120px; } /* Volume */
.markets-table th:nth-child(6),
.markets-table td:nth-child(6) { width: 15%; min-width: 120px; } /* Market Cap */
.markets-table th:nth-child(7),
.markets-table td:nth-child(7) { width: 13%; min-width: 100px; } /* Chart */
.markets-table th:nth-child(8),
.markets-table td:nth-child(8) { width: 10%; min-width: 80px; } /* Trade */

.markets-table thead {
    background: rgba(255, 255, 255, 0.02);
    position: sticky;
    top: 0;
    z-index: 10;
}

.markets-table thead th {
    padding: 16px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--table-text-secondary);
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.markets-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.markets-table thead th.sortable:hover {
    color: var(--table-text-primary);
}

.markets-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.2s;
    cursor: pointer;
}

.markets-table tbody tr:hover {
    background: rgba(93, 79, 232, 0.08);
    transform: translateX(2px);
}

.markets-table tbody td {
    padding: 14px 12px;
    font-size: 14px;
    color: var(--table-text-primary);
    white-space: nowrap;
}

/* Market rank */
.market-rank {
    color: var(--table-text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    padding: 0 8px !important;
    width: fit-content;
}

/* Market symbol cell */
.market-symbol-cell {
    display: flex;
    align-items: center;
    gap: 6px;  /* Reduced from 10px for tighter alignment */
}

.market-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* SVG icon styles for market icons */
.market-icon .coin-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Fallback letter style for market icons */
.market-icon .coin-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.market-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.market-ticker {
    font-size: 14px;
    font-weight: 600;
    color: var(--table-text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.market-name {
    font-size: 12px;
    color: var(--table-text-secondary);
}

/* Price column */
.market-price {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

/* Change column */
.market-change {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    display: inline-block;
}

.market-change.positive {
    background: rgba(34, 197, 94, 0.15);
    color: var(--market-gain);
}

.market-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--market-loss);
}

/* Volume and market cap */
.market-volume,
.market-cap {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--table-text-secondary);
}

/* Mini chart */
.market-chart {
    width: 120px;
    height: 40px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.chart-bar {
    flex: 1;
    background: rgba(93, 79, 232, 0.3);
    border-radius: 2px 2px 0 0;
    transition: all 0.3s;
}

.chart-bar:hover {
    background: rgba(93, 79, 232, 0.5);
}

/* Trade button */
.trade-btn {
    padding: 6px 16px;
    background: var(--market-highlight);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.trade-btn:hover {
    background: #7b6ff0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(93, 79, 232, 0.3);
}

/* Pagination */
.markets-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.pagination-info {
    font-size: 13px;
    color: var(--table-text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--table-text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(93, 79, 232, 0.1);
    border-color: rgba(93, 79, 232, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--market-highlight);
    border-color: var(--market-highlight);
    color: white;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--table-text-secondary);
    font-size: 13px;
    user-select: none;
    display: inline-block;
}

/* Loading states */
.markets-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--table-text-secondary);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(93, 79, 232, 0.2);
    border-top-color: var(--market-highlight);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
.markets-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--table-text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.3;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--table-text-primary);
}

.empty-message {
    font-size: 14px;
    opacity: 0.8;
}

/* Mobile responsive */
@media (max-width: 1200px) {
    .market-categories-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .market-stats-row {
        grid-template-columns: 1fr;
    }
    
    .markets-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .market-search-input {
        width: 100%;
    }
    
    .markets-table-container {
        display: none;
    }
    
    /* Mobile card layout */
    .markets-mobile-cards {
        display: block;
        padding: 15px;
    }
    
    .market-mobile-card {
        background: var(--market-card-bg);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
    }
    
    .market-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }
    
    .market-mobile-symbol {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .market-mobile-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .market-mobile-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .market-mobile-label {
        font-size: 11px;
        text-transform: uppercase;
        color: var(--table-text-secondary);
    }
    
    .market-mobile-value {
        font-size: 14px;
        font-weight: 500;
        color: var(--table-text-primary);
    }
}

/* Desktop only */
@media (min-width: 769px) {
    .markets-mobile-cards {
        display: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.market-stat-card,
.market-category-card,
.markets-main-section {
    animation: fadeIn 0.3s ease-out;
}

/* Price flash animation */
@keyframes priceFlash {
    0% {
        background: transparent;
    }
    50% {
        background: rgba(93, 79, 232, 0.2);
    }
    100% {
        background: transparent;
    }
}

.price-updated {
    animation: priceFlash 0.5s ease-out;
}