/**
 * Market Data Table Styles
 * Styling for market data tables with animations for updates
 * Using brand colors defined in variables.css
 */

/* Table Container */
.market-table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

/* Market Table */
.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.market-table th {
    background-color: var(--primary-dark);
    color: #fff;
    /* padding: 12px 15px; */
    text-align: left;
    font-weight: 600;
    position: relative;
    border-bottom: 2px solid var(--accent);
}

.market-table th:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.market-table th .sort-icon {
    margin-left: 5px;
    font-size: 12px;
}

.market-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--gray-light);
    vertical-align: middle;
}

/* Row Styles */
.market-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.market-table tbody tr.row-hover {
    background-color: rgba(27, 20, 100, 0.05);
}

/* Product Name Cell */
.product-name-cell {
    display: flex;
    flex-direction: column;
}

.product-name {
    font-weight: 600;
    color: var(--primary-dark);
}

.base-currency {
    font-size: 12px;
    color: var(--gray-dark);
    margin-top: 2px;
}

/* Price Cell */
.price-cell {
    position: relative;
    font-weight: 500;
}

.currency-symbol {
    color: var(--gray-dark);
    margin-right: 2px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background-color: var(--success-light);
    color: var(--success);
}

.status-badge.limited {
    background-color: var(--warning-light);
    color: #856404;
}

.status-badge.inactive {
    background-color: var(--danger-light);
    color: #721c24;
}

/* Forecast Cell */
.state-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.forecast-trend {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

.forecast-trend.up {
    background-color: var(--success-light);
    color: var(--success);
}

.forecast-trend.down {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* Action Buttons */
.action-column {
    white-space: nowrap;
    text-align: center;
}

.action-btn {
    display: inline-block;
    padding: 5px 10px;
    margin: 2px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    transition: var(--transition-normal);
}

.sample-btn {
    background-color: var(--primary-dark);
    color: #fff;
}

.sample-btn:hover {
    background-color: var(--primary-light);
    color: #fff;
}



/* Price Change Indicators */
.price-change-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 14px;
    font-weight: bold;
    animation: fadeOut 3s forwards;
}

.price-change-indicator.increase {
    color: var(--success);
}

.price-change-indicator.decrease {
    color: var(--danger);
}

/* Row Update Animation */
.row-updated {
    animation: highlightRow 3s;
}

/* Currency Toggle */
.currency-toggle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 15px 15px;
    position: relative;
}

.currency-toggle-caption {
    font-size: 0.85rem;
    color: var(--gray-dark);
    margin-bottom: 8px;
    text-align: center;
    font-style: italic;
    max-width: 600px;
}

.currency-toggle {
    display: flex;
    align-items: center;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
    width: auto; /* Change from 100% to auto */
    flex-wrap: wrap; /* Allow items to wrap */
    overflow-x: visible; /* Remove horizontal scrolling */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(0, 0, 0, 0.1);
}

.currency-toggle::-webkit-scrollbar {
    height: 4px;
}

.currency-toggle::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.currency-toggle::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 2px;
}

.currency-toggle span {
    font-weight: 500;
    margin-right: 10px;
}

.currency-options {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: nowrap;
}

.currency-option {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-normal);
    gap: 5px;
    user-select: none;
    white-space: nowrap;
}

.currency-option:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.currency-option.active {
    background-color: var(--primary-dark);
    color: #fff;
}

.currency-flag {
    height: 20px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Currency flag fallback style */
.currency-flag-fallback {
    background-color: var(--primary-dark);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 10px;
    width: 20px;
    height: 20px;
    border-radius: 3px;
}

/* Refresh button */
.refresh-button {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--primary-dark);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-normal);
}

.refresh-btn:hover {
    background-color: var(--primary-light);
}

.refresh-btn.loading .fa-sync {
    animation: rotate 1s linear infinite;
}

/* Section header */
.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin: 0;
    font-weight: 600;
    position: relative;
    display: inline-block;
}

.update-time {
    font-size: 0.85rem;
    color: var(--gray-dark);
    display: flex;
    align-items: center;
    gap: 5px;
}

.time-updated {
    animation: highlight-time 2s ease;
}

/* Visibility helpers */
.loading-indicator-hidden {
    display: none;
}

.results-section-hidden {
    display: none;
}

/* Define animations */
@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 0.7; }
    100% { opacity: 0; }
}

@keyframes highlightRow {
    0% { background-color: rgba(120, 109, 60, 0.2); }
    100% { background-color: transparent; }
}

@keyframes highlight-time {
    0% { color: var(--accent); }
    100% { color: var(--gray-dark); }
}

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

/* Media queries */
@media (max-width: 1200px) {
    .market-table {
        font-size: 13px;
    }
    
    .market-table th,
    .market-table td {
        /* padding: 10px 12px; */
    }
    
    .action-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

@media (max-width: 992px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .update-time {
        margin-top: 5px;
    }
    
    .refresh-button {
        margin-top: 10px;
        margin-left: 0;
    }
    
    .currency-toggle-container {
        margin-top: 15px;
    }
}

@media (max-width: 768px) {
    .market-table th,
    .market-table td {
        /* padding: 8px 10px; */
    }
    
    .market-table {
        min-width: 650px;
    }
    
    .action-column {
        position: sticky;
        right: 0;
        background-color: rgba(255, 255, 255, 0.9);
    }
    
    .action-btn {
        padding: 3px 6px;
    }
    
    .state-cell {
        flex-direction: row;
    }
    
    .currency-toggle-container {
        flex-direction: column;
    }
    
    .currency-toggle-caption {
        text-align: left;
        margin-bottom: 10px;
    }
    
    .currency-toggle {
        width: 100%;
    }
    
    .currency-option {
        padding: 4px 8px;
    }
    
    .currency-flag {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 576px) {
    .currency-toggle-caption {
        font-size: 0.8rem;
    }
    
    .currency-toggle {
        padding: 6px;
    }
    
    .currency-option {
        padding: 3px 6px;
        font-size: 0.8rem;
    }
    
    .currency-flag {
        width: 14px;
        height: 14px;
    }
}

/* Dark Mode */
.dark-mode .market-table {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.dark-mode .market-table th {
    background-color: #2d2d2d;
    color: #f0f0f0;
    border-bottom: 2px solid var(--accent);
}

.dark-mode .market-table td {
    border-bottom: 1px solid #333;
    color: #e0e0e0;
}

.dark-mode .market-table tbody tr:nth-child(even) {
    background-color: #1a1a1a;
}

.dark-mode .market-table tbody tr.row-hover {
    background-color: rgba(120, 109, 60, 0.15);
}

.dark-mode .product-name {
    color: #f0f0f0;
}

.dark-mode .base-currency {
    color: #a0a0a0;
}

.dark-mode .currency-toggle {
    background-color: #1e1e1e;
    border: 1px solid #333;
}

.dark-mode .currency-toggle span {
    color: #f0f0f0;
}

.dark-mode .currency-option:hover {
    background-color: #2d2d2d;
}

.dark-mode .section-header {
    border-bottom-color: #333;
}

.dark-mode .section-header h2 {
    color: #e0e0e0;
}

.dark-mode .update-time {
    color: #a0a0a0;
}

.dark-mode .market-data-title {
    color: #e0e0e0;
}
