/* ============================================
   OP_FLASH Portfolio Tracker
   ============================================ */

/* --- Nav Active State --- */
.nav-active {
    color: var(--accent-light) !important;
}

.nav-active::after {
    width: 100% !important;
}

/* --- Portfolio Hero --- */
.portfolio-hero {
    position: relative;
    padding: 140px 0 80px;
    background: var(--bg-primary);
    overflow: hidden;
}

.portfolio-hero-glow {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 500px;
    background: radial-gradient(ellipse, rgba(255, 140, 0, 0.06) 0%, transparent 70%);
    pointer-events: none;
    animation: pulse-glow 4s ease-in-out infinite;
}

.portfolio-hero-content {
    text-align: center;
    max-width: 720px;
    margin: 0 auto;
}

.portfolio-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(255, 140, 0, 0.2);
    margin-bottom: 24px;
}

.portfolio-badge svg {
    color: var(--accent);
}

.portfolio-hero-content h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.portfolio-hero-sub {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 40px;
}

/* --- Address Input --- */
.address-input-container {
    max-width: 640px;
    margin: 0 auto 20px;
}

.address-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 8px;
    padding: 6px 6px 6px 16px;
    transition: all 0.3s ease;
    gap: 12px;
}

.address-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 24px rgba(255, 140, 0, 0.12), 0 0 0 1px rgba(255, 140, 0, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.address-input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.3s;
}

.address-input-wrapper:focus-within .address-input-icon {
    color: var(--accent);
}

.address-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 10px 0;
    min-width: 0;
}

.address-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.btn-lookup {
    padding: 10px 24px;
    font-size: 0.875rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.btn-lookup-text {
    display: inline;
}

.address-input-hint {
    margin-top: 10px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.address-input-hint .hint-error {
    color: #ff4444;
}

.address-input-hint .hint-success {
    color: #44bb44;
}

/* --- Network Toggle --- */
.network-toggle {
    display: inline-flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 4px;
}

.network-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.network-btn:hover {
    color: var(--text-secondary);
}

.network-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.network-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.network-btn.active .network-dot {
    opacity: 1;
    box-shadow: 0 0 6px currentColor;
}

/* --- Portfolio Results --- */
.portfolio-results {
    background: var(--bg-secondary);
    padding: 48px 0 80px;
    min-height: 400px;
}

/* --- Summary Cards --- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: border-color 0.3s, transform 0.3s;
}

.summary-card:hover {
    border-color: rgba(255, 140, 0, 0.2);
    transform: translateY(-2px);
}

.summary-card-primary {
    border-color: rgba(255, 140, 0, 0.2);
    background: rgba(255, 140, 0, 0.03);
}

.summary-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-dim);
    border: 1px solid rgba(255, 140, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.summary-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.summary-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.summary-sub {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Address Bar --- */
.address-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 32px;
}

.address-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.address-bar-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    flex-shrink: 0;
}

.address-bar-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'Inter', monospace;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.address-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.address-bar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.2s;
    white-space: nowrap;
}

.address-bar-link:hover {
    color: var(--accent-light);
}

/* --- Token Section --- */
.token-section {
    margin-bottom: 48px;
}

.token-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.token-section-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.token-section-header h2 svg {
    color: var(--accent);
}

.token-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Loading State --- */
.token-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 64px 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

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

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

/* --- Empty State --- */
.token-empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

.token-empty svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.token-empty p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.token-empty span {
    font-size: 0.875rem;
}

/* --- Token Table --- */
.token-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.token-table {
    width: 100%;
    border-collapse: collapse;
}

.token-table thead {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.token-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.th-balance,
.th-value {
    text-align: right;
}

.th-action {
    text-align: center;
    width: 120px;
}

.token-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s;
}

.token-table tbody tr:hover {
    background: rgba(255, 140, 0, 0.03);
}

.token-table tbody tr:last-child {
    border-bottom: none;
}

.token-table td {
    padding: 16px;
    vertical-align: middle;
}

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

.token-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid rgba(255, 140, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--accent);
    flex-shrink: 0;
}

.token-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.token-symbol {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

/* Balance cell */
.td-balance {
    text-align: right;
}

.token-balance {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Value cell */
.td-value {
    text-align: right;
}

.token-value-mobile {
    display: none;
}

.token-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.token-value-na {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Action cell */
.td-action {
    text-align: center;
}

.btn-trade-token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-trade-token:hover {
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(255, 140, 0, 0.15);
}

/* --- Portfolio CTA --- */
.portfolio-cta {
    margin-top: 16px;
}

.portfolio-cta-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: linear-gradient(135deg, rgba(255, 140, 0, 0.06), rgba(255, 179, 71, 0.03));
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 12px;
    padding: 32px 40px;
}

.portfolio-cta-text h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.portfolio-cta-text p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* --- Error State --- */
.portfolio-error {
    background: var(--bg-secondary);
    padding: 80px 0;
}

.error-card {
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
    padding: 48px 32px;
    background: rgba(255, 68, 68, 0.03);
    border: 1px solid rgba(255, 68, 68, 0.15);
    border-radius: 12px;
}

.error-card svg {
    color: #ff4444;
    margin-bottom: 20px;
    opacity: 0.6;
}

.error-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.error-card p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .portfolio-hero {
        padding: 120px 0 60px;
    }

    .portfolio-hero-content h1 {
        font-size: 1.75rem;
    }

    .address-input-wrapper {
        flex-direction: column;
        padding: 12px;
        gap: 10px;
    }

    .address-input-icon {
        display: none;
    }

    .address-input {
        width: 100%;
        text-align: center;
        font-size: 0.875rem;
    }

    .btn-lookup {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .address-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 12px 16px;
    }

    .address-bar-left {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .address-bar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .address-bar-value {
        font-size: 0.75rem;
        max-width: calc(100vw - 120px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .token-table th,
    .token-table td {
        padding: 12px 10px;
    }

    .th-value {
        display: none;
    }

    .td-value {
        display: none;
    }

    /* Show value inline under the balance on mobile */
    .td-balance {
        position: relative;
    }

    .td-balance .token-value-mobile {
        display: block;
        font-size: 0.7rem;
        color: var(--accent, #f7931a);
        margin-top: 2px;
    }

    .th-action,
    .td-action {
        width: auto;
    }

    .portfolio-cta-content {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }

    .token-info {
        gap: 8px;
    }

    .token-icon {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .portfolio-hero-content h1 {
        font-size: 1.5rem;
    }

    .summary-value {
        font-size: 1.25rem;
    }

    .btn-trade-token span {
        display: none;
    }
}

/* ── Custom Token Section ───────────────── */

.custom-token-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.custom-token-header {
    margin-bottom: 12px;
}

.custom-token-title {
    font-weight: 600;
    color: var(--text-primary, #fff);
    font-size: 0.95rem;
}

.custom-token-subtitle {
    color: var(--text-secondary, #888);
    font-size: 0.8rem;
    margin-left: 8px;
}

.custom-token-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-token-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.custom-token-input:focus {
    border-color: var(--accent, #f7931a);
}

.custom-token-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.btn-sm {
    padding: 10px 18px;
    font-size: 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-accent {
    background: var(--accent, #f7931a);
    color: #000;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-accent:hover {
    opacity: 0.85;
}

.custom-token-feedback {
    margin-top: 8px;
    font-size: 0.8rem;
    min-height: 20px;
}

.custom-badge {
    font-size: 0.6rem;
    background: rgba(247, 147, 26, 0.2);
    color: var(--accent, #f7931a);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.btn-remove-token {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.btn-remove-token:hover {
    color: #ff4444;
}
