/* Portfolio Manager Styles */

/* ==================== LAYOUT ==================== */
.portfolio-page {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.portfolio-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

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

#refresh-portfolio {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.2s;
}

#refresh-portfolio:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

#refresh-portfolio:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== TOTAL VALUE CARD ==================== */
.portfolio-value-card {
    background: var(--bg-card, #1E1E21);
    border: 1px solid var(--border-primary, #2D2D30);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
    transition: border-color 0.2s ease;
}

.portfolio-value-card:hover {
    border-color: rgba(16, 185, 129, 0.25);
}

.portfolio-value-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.portfolio-value-label {
    font-size: 14px;
    color: var(--text-secondary, #9CA3AF);
    margin-bottom: 8px;
}

#portfolio-total-value {
    font-size: 42px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

#portfolio-24h-change {
    font-size: 16px;
    margin-top: 8px;
}

#portfolio-24h-change .positive {
    color: var(--contrast-green, #10B981);
}

#portfolio-24h-change .negative {
    color: #ef4444;
}

.portfolio-meta {
    display: flex;
    gap: 24px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary, #9CA3AF);
}

#last-update-time {
    color: #64748b;
}

/* ==================== GRID LAYOUT ==================== */
.portfolio-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== CARDS ==================== */
.portfolio-card {
    background: var(--bg-card, #1E1E21);
    border: 1px solid var(--border-primary, #2D2D30);
    border-radius: 16px;
    padding: 24px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portfolio-card:hover {
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.06);
}

.portfolio-card h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.portfolio-card h2 i {
    color: var(--contrast-green, #10B981);
}

/* ==================== TOKEN LIST ==================== */
#token-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.token-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary, #111113);
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.token-row:hover {
    background: var(--bg-tertiary, #1A1A1D);
    border-color: rgba(16, 185, 129, 0.15);
}

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

.token-logo {
    position: relative;
    width: 40px;
    height: 40px;
}

.token-logo img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary, #111113);
}

.chain-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 4px;
    color: #fff;
    text-transform: uppercase;
}

.token-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.token-symbol {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.token-name {
    font-size: 12px;
    color: var(--text-muted, #6B7280);
}

.token-balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.balance-amount {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.balance-value {
    font-size: 13px;
    color: var(--text-secondary, #9CA3AF);
}

.token-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.price-current {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.price-change {
    font-size: 12px;
    font-weight: 500;
}

.price-change.positive {
    color: var(--contrast-green, #10B981);
}

.price-change.negative {
    color: #ef4444;
}

/* ==================== DEFI POSITIONS ==================== */
#defi-positions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.defi-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.defi-summary span {
    font-size: 13px;
    color: #a0aec0;
}

.defi-summary strong {
    font-size: 18px;
    color: #fff;
}

.defi-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.defi-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary, #111113);
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.defi-row:hover {
    border-color: rgba(16, 185, 129, 0.15);
    background: var(--bg-tertiary, #1A1A1D);
}

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

.defi-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.defi-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.defi-protocol {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.defi-type {
    font-size: 12px;
    color: var(--text-muted, #6B7280);
}

.defi-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.value-amount {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.value-apy {
    font-size: 12px;
    font-weight: 500;
}

/* ==================== ALLOCATION CHART ==================== */
#allocation-chart {
    margin-top: 12px;
}

.allocation-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.allocation-item {
    display: grid;
    grid-template-columns: 100px 1fr 80px;
    align-items: center;
    gap: 12px;
}

.allocation-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #fff;
}

.allocation-label .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.allocation-label .percent {
    margin-left: auto;
    color: #64748b;
    font-size: 12px;
}

.allocation-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.allocation-value {
    font-size: 13px;
    color: #a0aec0;
    text-align: right;
}

/* ==================== SKELETON LOADING ==================== */
.skeleton {
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.1), 
        transparent
    );
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skeleton-row {
    opacity: 0.5;
}

.skeleton-text {
    color: transparent;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.skeleton-text.small {
    font-size: 0.8em;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

/* ==================== EMPTY & ERROR STATES ==================== */
.empty-state,
.error-state,
.connect-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state i,
.error-state i {
    font-size: 48px;
    color: #64748b;
    margin-bottom: 16px;
}

.empty-state p,
.error-state p {
    font-size: 16px;
    color: #a0aec0;
    margin: 0 0 8px 0;
}

.empty-state small {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 16px;
}

.connect-prompt {
    min-height: 300px;
}

.connect-prompt .prompt-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.connect-prompt .prompt-icon i {
    font-size: 32px;
    color: var(--contrast-green, #10B981);
}

.connect-prompt h3 {
    font-size: 24px;
    color: #fff;
    margin: 0 0 8px 0;
}

.connect-prompt p {
    font-size: 14px;
    color: #a0aec0;
    margin: 0 0 24px 0;
    max-width: 300px;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--contrast-green, #10B981);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: var(--contrast-green-dark, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ==================== UPDATING INDICATOR ==================== */
#updating-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 8px;
    font-size: 13px;
    color: var(--contrast-green, #10B981);
}

#updating-indicator i {
    animation: spin 1s linear infinite;
}

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

/* ==================== PIE CHARTS ==================== */
.portfolio-charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .portfolio-charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--bg-card, #1E1E21);
    border: 1px solid var(--border-primary, #2D2D30);
    border-radius: 16px;
    padding: 24px;
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-card h3 i {
    color: var(--contrast-green, #10B981);
    font-size: 14px;
}

.pie-chart-container {
    display: flex;
    align-items: center;
    gap: 24px;
}

.pie-chart {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    font-size: 13px;
    color: #a0aec0;
    flex: 1;
}

.legend-value {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

/* ==================== DEFI V3 POSITIONS ==================== */
.defi-position-v3 {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.05) 0%, rgba(0, 168, 204, 0.05) 100%);
    border: 1px solid rgba(0, 212, 170, 0.15);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.position-tokens {
    display: flex;
    align-items: center;
    gap: 10px;
}

.token-pair-icons {
    display: flex;
    align-items: center;
}

.token-pair-icons .token-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #1a1f2e;
    background: #0f172a;
}

.token-pair-icons .token-icon.overlap {
    margin-left: -10px;
}

.position-fee-badge {
    font-size: 11px;
    font-weight: 600;
    color: #00d4aa;
    background: rgba(0, 212, 170, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
}

.position-status {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.position-status.active {
    color: #00d4aa;
    background: rgba(0, 212, 170, 0.15);
}

.position-status.inactive {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.position-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pair-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.position-id {
    font-size: 12px;
    color: #64748b;
    font-family: monospace;
}

.position-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.value-usd {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.position-apr {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.apr-label {
    font-size: 12px;
    color: #64748b;
}

.apr-value {
    font-size: 14px;
    font-weight: 600;
}

.apr-value.positive {
    color: #00d4aa;
}

/* ==================== LOADING STATE ==================== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

.loading-state i {
    font-size: 32px;
    color: #00d4aa;
    margin-bottom: 16px;
}

.loading-state p {
    font-size: 16px;
    color: #fff;
    margin: 0 0 8px 0;
}

.loading-state small {
    font-size: 13px;
    color: #64748b;
}

#portfolio-total-value.loading {
    color: transparent;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    min-width: 150px;
}

/* ==================== RESPONSIVE ==================== */
/* ==================== PORTFOLIO SIDEBAR ==================== */
.portfolio-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ==================== TOKEN ACTION BUTTONS ==================== */
.token-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    transition: background 0.2s;
}

.token-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.token-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.token-action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.token-action-btn.buy {
    background: rgba(0, 212, 170, 0.1);
    border-color: rgba(0, 212, 170, 0.3);
    color: #00d4aa;
}

.token-action-btn.buy:hover {
    background: #00d4aa;
    color: #fff;
    border-color: #00d4aa;
}

.token-action-btn.sell {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.token-action-btn.sell:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

@media (max-width: 768px) {
    .portfolio-page {
        padding: 16px;
    }
    
    .portfolio-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    #portfolio-total-value {
        font-size: 32px;
    }
    
    .token-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .token-balance,
    .token-price {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .token-actions {
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 8px;
    }
    
    .allocation-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .allocation-label {
        justify-content: space-between;
    }
    
    .allocation-value {
        display: none;
    }
}
