/* CSS Variables */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #263548;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --positive: #22c55e;
    --negative: #ef4444;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .moon-icon {
    display: block;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    min-width: 120px;
    height: 44px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.refresh-btn:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
}

.refresh-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

.refresh-btn svg {
    flex-shrink: 0;
}

.refresh-btn span {
    flex-shrink: 0;
}

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

/* Summary Card */
.summary-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
    box-shadow: var(--shadow);
}

.summary-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.summary-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.summary-value {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.total-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.change-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trend-icon {
    width: 16px;
    height: 16px;
}

.trend-icon.up {
    color: var(--positive);
    transform: rotate(180deg);
}

.trend-icon.down {
    color: var(--negative);
}

.change-amount {
    font-size: 14px;
    font-weight: 600;
}

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

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

.change-period {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.summary-right {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

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

.filter-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.currency-buttons {
    display: flex;
    background: var(--bg-primary);
    border-radius: 10px;
    padding: 4px;
}

.currency-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.currency-btn:hover {
    color: var(--text-primary);
}

.currency-btn.active {
    background: var(--accent-blue);
    color: white;
}

.sort-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sort-select {
    appearance: none;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 40px 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 160px;
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.sort-select-wrapper svg {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Crypto Grid */
.crypto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

.crypto-grid.hidden {
    display: none;
}

/* Crypto Card */
.crypto-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.crypto-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.card-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crypto-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-primary);
}

.crypto-logo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-secondary);
}

.crypto-details h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.crypto-details .symbol {
    font-size: 13px;
    color: var(--accent-blue);
    font-weight: 600;
}

.card-quantity {
    text-align: right;
}

.card-quantity .label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.card-quantity .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-price {
    margin-bottom: 16px;
}

.card-price .label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card-price .price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-price .price {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.card-price .change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
}

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

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

.card-price .change svg {
    width: 14px;
    height: 14px;
}

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-row .label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-row .value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-row .value.highlight {
    color: var(--accent-blue);
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .summary-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }

    .summary-right {
        flex-direction: column;
        width: 100%;
        gap: 16px;
    }

    .currency-buttons {
        width: 100%;
    }

    .currency-btn {
        flex: 1;
        text-align: center;
    }

    .sort-select {
        width: 100%;
    }

    .total-value {
        font-size: 32px;
    }

    .crypto-grid {
        grid-template-columns: 1fr;
    }

    .card-price .price {
        font-size: 24px;
    }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--positive);
}

.toast.error {
    border-left: 4px solid var(--negative);
}

.toast p {
    font-size: 14px;
    color: var(--text-primary);
}

