/* markets.css - Premium UI Enhancement with Optimized Icons */
.price-loading {
    position: relative;
    color: transparent;
}

.price-loader {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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


/* Base Styles */
.markets-overview {
    padding: 28px;
    max-width: 1600px;
    margin: 0 auto;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Header Styles */
.markets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 20px;
}

.markets-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    position: relative;
    padding-left: 16px;
}

.markets-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background: var(--primary);
    border-radius: 2px;
}

/* Tabs and Search Container */
.markets-tabs-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    position: relative;
    flex-wrap: wrap;
    gap: 16px;
}

/* Tabs Styling */
.markets-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 2px;
    position: relative;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.markets-tab {
    padding: 14px 24px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    margin-bottom: -1px;
    background: transparent;
    border: none;
    outline: none;
}

.markets-tab:hover {
    color: var(--text-primary);
    background: rgba(var(--primary-rgb), 0.05);
}

.markets-tab.active {
    color: var(--primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-bottom-color: transparent;
    box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.03);
}

/* Search Styling */
.markets-search {
    position: relative;
    width: 260px;
    min-width: 200px;
    margin-left: auto;
    margin-bottom: -1px;
}

.markets-search input {
    width: 100%;
    padding: 12px 20px 12px 40px;
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    background-color: rgba(var(--primary-rgb), 0.03);
}

.markets-search input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.markets-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15), 
                0 4px 16px rgba(var(--primary-rgb), 0.1);
    background: var(--input-focus-bg);
}

.markets-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1.1rem;
    transition: all 0.3s ease;
    z-index: 2;
}

.markets-search:focus-within i {
    color: var(--primary);
}

.markets-search .clear-search {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 1rem;
    padding: 6px;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--text-tertiary-rgb), 0.1);
}

.markets-search input:not(:placeholder-shown) + i + .clear-search {
    opacity: 1;
}

.markets-search .clear-search:hover {
    color: var(--negative);
    background: rgba(var(--negative-rgb), 0.1);
    transform: translateY(-50%) rotate(90deg) scale(1.1);
}

/* Stats Cards */
.markets-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.stat-card:hover::before {
    width: 6px;
}

.stat-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stat-change {
    font-size: 0.95rem;
    margin-top: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive {
    color: var(--positive);
}

.stat-change.negative {
    color: var(--negative);
}

/* Top Performers */
.performer-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.performer-item:last-child {
    border-bottom: none;
}

.performer-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
}

.performer-icon img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.performer-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.performer-pair {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.performer-price {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.performer-change {
    font-size: 0.9rem;
    font-weight: 600;
    margin-left: 12px;
    min-width: 60px;
    text-align: right;
}

.performer-change.positive {
    color: var(--positive);
}

.performer-change.negative {
    color: var(--negative);
}

/* Table Styling */
.markets-table-container {
    background: var(--card-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
}

.markets-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
}

.markets-table th {
    text-align: left;
    padding: 18px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--table-header-bg);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: sticky;
    top: 0;
    z-index: 10;
}

.markets-table th:hover {
    background: var(--table-header-hover);
    color: var(--text-primary);
}

.markets-table th.sort-asc::after,
.markets-table th.sort-desc::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 8px;
    vertical-align: middle;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

.markets-table th.sort-asc::after {
    border-bottom: 5px solid var(--primary);
}

.markets-table th.sort-desc::after {
    border-top: 5px solid var(--primary);
}

.markets-table td {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
    transition: background 0.2s ease;
}

.markets-table tr:first-child td {
    border-top: none;
}

.markets-table tr:hover td {
    background: var(--table-row-hover);
}

/* Pair Cell Styles */
.pair-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pair-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pair-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.pair-icon:not(:has(img)) {
    background: linear-gradient(135deg, var(--icon-gradient-start), var(--icon-gradient-end));
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
}

.pair-name {
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.pair-quote {
    color: var(--text-secondary);
    font-weight: 400;
    transition: color 0.2s ease;
}

.markets-table tr:hover .pair-name,
.markets-table tr:hover .pair-quote {
    color: var(--primary);
}

.markets-table tr:hover .pair-icon {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.15);
}

.markets-table tr:hover .pair-icon img {
    transform: scale(1.1);
}

/* Price Animation Styles */
@keyframes priceFlashUp {
    0% { color: var(--text-primary); }
    10% { color: #059669; }
    90% { color: #059669; }
    100% { color: var(--text-primary); }
}

@keyframes priceFlashDown {
    0% { color: var(--text-primary); }
    10% { color: #dc2626; }
    90% { color: #dc2626; }
    100% { color: var(--text-primary); }
}

.price-update-up {
    animation: priceFlashUp 5s ease-out;
}

.price-update-down {
    animation: priceFlashDown 5s ease-out;
}

.price-normal {
    color: var(--text-primary);
    font-weight: 500;
}

.price-positive {
    color: #059669;
    font-weight: 600;
}

.price-negative {
    color: #dc2626;
    font-weight: 600;
}

/* Volume Cell */
.volume-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.volume-value {
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.volume-percent {
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.volume-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(var(--primary-rgb), 0.08);
    border-radius: 2px;
    z-index: 0;
    transition: width 0.6s ease;
}

/* Buttons */
.trade-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.trade-btn:hover {
    background: rgba(var(--primary-rgb), 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.15);
}

.favorite-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
    margin-right: 8px;
}

.favorite-btn .fa-star-o {
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
    border-radius: 50%;
    padding: 2px;
    transition: all 0.3s ease;
}

.favorite-btn .fas.fa-star {
    color: var(--warning);
    text-shadow: 0 2px 4px rgba(var(--warning-rgb), 0.2);
}

.favorite-btn:hover .fa-star-o {
    color: var(--warning);
    border-color: var(--warning);
    transform: scale(1.1);
}

.favorite-btn:hover .fas.fa-star {
    transform: scale(1.1);
}

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

.favorite-btn::before {
    content: attr(aria-label);
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tooltip-bg);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.favorite-btn:hover::before {
    opacity: 1;
}

/* Loading States */
.loading-markets,
.no-markets,
.error-message {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.loading-markets i {
    margin-right: 12px;
    color: var(--primary);
    animation: spin 1.5s linear infinite;
}

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

.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.error-message i {
    color: var(--negative);
    font-size: 2rem;
}

.btn-retry {
    margin-top: 16px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
/* Add this to the existing markets-tabs styles */
.markets-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px; /* Space for scrollbar */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    margin-right: -16px; /* Compensate for negative margin */
    margin-left: -16px; /* Compensate for negative margin */
    padding-left: 16px; /* Restore padding */
}

/* Hide scrollbar for Chrome/Safari */
.markets-tabs::-webkit-scrollbar {
    display: none;
}

/* Add shadow to indicate scrollable area */
.markets-tabs-container {
    position: relative;
}

.markets-tabs-container::after {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, var(--card-bg) 100%);
    pointer-events: none;
    z-index: 1;
}

.dark-mode .markets-tabs-container::after {
    background: linear-gradient(90deg, rgba(30,41,59,0) 0%, var(--card-bg) 100%);
}

/* Adjust tab styles for mobile */
@media (max-width: 768px) {
    .markets-tab {
        padding: 12px 16px;
        font-size: 0.85rem;
        border-radius: 6px;
        margin-bottom: 0;
        border: 1px solid var(--border-color);
    }
    
    .markets-tab.active {
        border-bottom: 1px solid var(--border-color);
        border-radius: 6px;
    }
    
    .markets-tabs {
        gap: 6px;
    }
}
/* Responsive table styles */
@media (max-width: 768px) {
    .markets-table {
        display: block;
    }
    
    .markets-table thead {
        display: none;
    }
    
    .markets-table tbody {
        display: block;
    }
    
    .markets-table tr {
        display: block;
        padding: 16px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .markets-table tr:last-child {
        border-bottom: none;
    }
    
    .markets-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-top: none;
        position: relative;
    }
    
    .markets-table td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-weight: 500;
        font-size: 0.85rem;
        margin-right: 12px;
    }
    
    /* Hide some columns on mobile */
    .markets-table td:nth-child(4),
    .markets-table td:nth-child(5) {
        display: none;
    }
    
    /* Special styling for pair cell */
    .markets-table td:first-child {
        padding-top: 0;
        padding-bottom: 12px;
    }
    
    /* Special styling for action cell */
    .markets-table td:last-child {
        padding-top: 12px;
        padding-bottom: 0;
        justify-content: flex-end;
        gap: 12px;
    }
    
    .markets-table td:last-child::before {
        display: none;
    }
    
    /* Adjust pair cell */
    .pair-cell {
        gap: 10px;
    }
    
    .pair-icon {
        width: 28px;
        height: 28px;
    }
    
    .pair-icon img {
        width: 20px;
        height: 20px;
    }
    
    /* Adjust buttons */
    .trade-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .favorite-btn {
        margin-right: 0;
    }
    
    /* Adjust volume display */
    .volume-cell {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .volume-percent {
        font-size: 0.8rem;
    }
}

.btn-retry:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

/* Dark Mode Styles */
.dark-mode {
    --card-bg: #1e293b;
    --border-color: #334155;
    --border-light: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --input-bg: #1e293b;
    --input-focus-bg: #1e293b;
    --table-header-bg: #1e293b;
    --table-header-hover: #334155;
    --table-row-hover: #334155;
    --icon-bg: #334155;
    --positive: #10b981;
    --negative: #ef4444;
    --warning: #f59e0b;
}

.dark-mode .markets-table-container {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dark-mode .stat-card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dark-mode .markets-search input {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .markets-search input:focus {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Color Variables */
:root {
    --positive: #10b981;
    --positive-rgb: 16, 185, 129;
    --negative: #ef4444;
    --negative-rgb: 239, 68, 68;
    --text-primary: #000000;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --primary: #6366f1;
    --primary-rgb: 99, 102, 241;
    --primary-dark: #4f46e5;
    --warning: #f59e0b;
    --warning-rgb: 245, 158, 11;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --input-bg: #ffffff;
    --input-focus-bg: #ffffff;
    --table-header-bg: #f8fafc;
    --table-header-hover: #f1f5f9;
    --table-row-hover: #f8fafc;
    --icon-bg: #f1f5f9;
    --icon-gradient-start: #6366f1;
    --icon-gradient-end: #8b5cf6;
    --tooltip-bg: rgba(0, 0, 0, 0.8);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .markets-overview {
        padding: 24px;
    }
    
    .markets-table th,
    .markets-table td {
        padding: 14px 16px;
    }
}

@media (max-width: 768px) {
    .markets-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .markets-tabs-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .markets-search {
        width: 100%;
        margin-left: 0;
    }
    
    .markets-search input {
        border-radius: 8px;
    }
    
    .markets-tab {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    .pair-icon {
        width: 28px;
        height: 28px;
    }
    
    .pair-icon img {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .markets-overview {
        padding: 16px;
    }
    
    .markets-table-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .markets-table th,
    .markets-table td {
        padding: 12px 10px;
        font-size: 0.9rem;
    }
    
    .pair-icon {
        width: 24px;
        height: 24px;
    }
    
    .pair-icon img {
        width: 16px;
        height: 16px;
    }
    
    .trade-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}