/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px; /* 基础字体大小，用于rem计算 */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #141414;
    color: #fff;
    padding: 1rem;
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #1f1f1f;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    gap: 0.5rem;
}

/* Form controls */
select, .date-input {
    background: #141414;
    color: #fff;
    border: 1px solid #333;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 80px;
}

.date-input {
    width: 140px;
}

/* Metrics grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.metric-card {
    background: #1f1f1f;
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid #333;
}

.metric-title {
    color: #888;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.metric-change {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* Charts and cards */
.chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.card {
    background: #1f1f1f;
    border-radius: 8px;
    border: 1px solid #333;
    padding: 1.25rem;
    height: 100%;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.25rem 0;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.timeframe-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.timeframe-btn {
    padding: 0.35rem 0.75rem;
    background: #141414;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.timeframe-btn:hover {
    background: #1a1a1a;
    color: #fff;
    border-color: #444;
}

.timeframe-btn.active {
    background: #2962FF;
    color: white;
    border-color: #2962FF;
}

.chart-container {
    height: 400px;
    width: 100%;
    min-height: 300px;
}

/* Table styles */
.table-container {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 #1f1f1f;
}

.table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: #1f1f1f;
}

.table-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: right;
}

.data-table th {
    color: #888;
    font-weight: 500;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    background: #1f1f1f;
    z-index: 1;
}

.data-table td {
    border-bottom: 1px solid #262626;
}

/* Status colors */
.up {
    color: #52c41a;
    background: rgba(82, 196, 26, 0.1);
}

.down {
    color: #ff4d4f;
    background: rgba(255, 77, 79, 0.1);
}

.price-up {
    color: #52c41a;
}

.price-down {
    color: #ff4d4f;
}

/* Symbol button styles */
.symbol-btn {
    position: relative;
    padding: 0.5rem 0.75rem;
    background: #141414;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.875rem;
    min-width: 60px;
    text-align: center;
}

.symbol-btn-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.symbol-delete-btn {
    opacity: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 77, 79, 0.2);
    color: #ff4d4f;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.symbol-btn:hover .symbol-delete-btn {
    opacity: 1;
}

.symbol-delete-btn:hover {
    background: rgba(255, 77, 79, 0.4);
}

.symbol-btn.active {
    background: #2962FF;
    color: white;
    border-color: #2962FF;
}

.symbol-btn.active .symbol-delete-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.symbol-btn.active .symbol-delete-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Messages */
.error-message {
    color: #ff4d4f;
    background: rgba(255, 77, 79, 0.1);
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1.25rem 0;
    display: none;
}

/* Fullscreen styles */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.chart-wrapper:fullscreen {
    background: #141414;
    padding: 20px;
}

.chart-wrapper:fullscreen .chart-container {
    height: 90vh !important;
}

.fullscreen-button {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(31, 31, 31, 0.7);
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-button:hover {
    background: rgba(51, 51, 51, 0.9);
    transform: scale(1.05);
}

.fullscreen-button svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Custom symbol input styles */
.custom-symbol-input {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.custom-symbol-input input {
    background: #141414;
    color: #fff;
    border: 1px solid #333;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    width: 100px;
    text-transform: uppercase;
}

.custom-symbol-input input:focus {
    outline: none;
    border-color: #2962FF;
}

#addSymbolBtn {
    padding: 0.5rem 0.75rem;
    background: #2962FF;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
}

#addSymbolBtn:hover {
    background: #1a54ff;
}

#addSymbolBtn:disabled {
    background: #333;
    cursor: not-allowed;
}

/* Footer styles */
.footer {
    margin-top: 2rem;
    padding: 1rem;
    background: #1f1f1f;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #333;
}

.footer-left {
    color: #888;
    font-size: 0.875rem;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 响应式布局断点 */
@media (min-width: 1200px) {
    .container {
        padding: 0 2rem;
    }
}

@media (max-width: 1199px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 350px;
    }
}

@media (max-width: 991px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-controls {
        flex-direction: column;
    }
    
    .control-group {
        justify-content: center;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .timeframe-controls {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    html {
        font-size: 14px;
    }

    .container {
        padding: 0 0.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .date-range {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .date-input {
        width: 100%;
    }

    .footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .footer-right {
        width: 100%;
        justify-content: center;
    }
    
    .refresh-controls {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 575px) {
    .header h1 {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .symbol-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }

    .timeframe-btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #1f1f1f;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* 自动刷新相关样式 */
.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #141414;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #1a1a1a;
    color: #fff;
}

.control-btn.active {
    background: #2962FF;
    color: white;
    border-color: #2962FF;
}

.control-btn svg {
    transition: transform 0.3s ease;
}

.control-btn.active svg {
    animation: spin 2s linear infinite;
}

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

.interval-select {
    background: #141414;
    color: #888;
    border: 1px solid #333;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 100px;
}

/* 自动刷新按钮组样式 */
#autoRefreshBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#refreshInterval {
    background: #141414;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.875rem;
}

.refresh-btn {
    padding: 0.5rem 0.75rem;
    background: #141414;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: #1a1a1a;
    color: #fff;
}

.refresh-btn.active {
    background: #2962FF;
    color: white;
    border-color: #2962FF;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn.active svg {
    animation: spin 2s linear infinite;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .refresh-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .refresh-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    
    #refreshInterval {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
}