/* --- Modal Layout Improvements --- */
.modal-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    gap: 20px;
}

.modal-left-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.modal-stat-card {
    background: white;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.modal-stat-label {
    font-size: 0.7rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
}

.modal-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin-top: 2px;
}

.modal-chart-box {
    background: white;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.modal-right-col {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 0;
}

/* --- Star Ratings --- */
.star-rating {
    color: #f59e0b;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

body.dark .modal-stat-card,
body.dark .modal-chart-box,
body.dark .modal-right-col {
    background: #1e293b;
    border-color: #334155;
}

body.dark .modal-stat-value {
    color: #f1f5f9;
}

/* --- Animated Number Counter --- */
.count-up {
    display: inline-block;
    transition: opacity 0.3s ease;
}

/* --- Enhanced Toast with Icons --- */
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 14px 22px;
    border-radius: 12px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.toast.error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast.info {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
}

/* --- Heatmap Return Values in Performance Table --- */
.return-val {
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    display: inline-block;
    min-width: 52px;
    text-align: center;
}

.return-val.positive {
    color: #065f46;
    background: rgba(16, 185, 129, 0.12);
}

.return-val.negative {
    color: #991b1b;
    background: rgba(239, 68, 68, 0.1);
}

.return-val.strong-positive {
    color: #064e3b;
    background: rgba(16, 185, 129, 0.25);
    font-weight: 800;
}

.return-val.strong-negative {
    color: #7f1d1d;
    background: rgba(239, 68, 68, 0.2);
    font-weight: 800;
}

/* --- Skeleton Loader Placeholders --- */
.skeleton-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    min-height: 220px;
}

.skeleton-line {
    height: 14px;
    border-radius: 7px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 12px;
}

.skeleton-line.w-60 {
    width: 60%;
}

.skeleton-line.w-40 {
    width: 40%;
}

.skeleton-line.w-80 {
    width: 80%;
}

.skeleton-line.w-full {
    width: 100%;
}

.skeleton-line.h-lg {
    height: 24px;
    border-radius: 12px;
}

.skeleton-line.h-xl {
    height: 40px;
    border-radius: 12px;
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* --- Scroll Reveal Animation --- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children */
.reveal-stagger>* {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal-stagger.visible>*:nth-child(1) {
    transition-delay: 0.05s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(2) {
    transition-delay: 0.1s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(3) {
    transition-delay: 0.15s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(4) {
    transition-delay: 0.2s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(5) {
    transition-delay: 0.25s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(6) {
    transition-delay: 0.3s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(7) {
    transition-delay: 0.35s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(8) {
    transition-delay: 0.4s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(9) {
    transition-delay: 0.45s;
    opacity: 1;
    transform: none;
}

.reveal-stagger.visible>*:nth-child(10) {
    transition-delay: 0.5s;
    opacity: 1;
    transform: none;
}

/* --- Trending Card Rank Badge --- */
.trending-card {
    position: relative;
    overflow: hidden;
}

.trending-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-500), var(--purple-500));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.trending-card:hover::before {
    opacity: 1;
}

.rank-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    color: white;
    z-index: 2;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.rank-badge.silver {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.4);
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #d97706, #92400e);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.rank-badge.default {
    background: var(--primary-600);
}

/* --- Enhanced Trending Card Hover --- */
.trending-card:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-500);
    transform: translateY(-4px);
}

/* --- Tooltip for Stats --- */
.stat-tooltip {
    position: relative;
    cursor: help;
}

.stat-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1e293b;
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 250px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

.stat-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- Risk Gauge Improvement --- */
.risk-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.risk-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse-risk 2s ease-in-out infinite;
}

@keyframes pulse-risk {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.85);
    }
}

.risk-dot.low {
    background: #10b981;
}

.risk-dot.moderate {
    background: #f59e0b;
}

.risk-dot.high {
    background: #ef4444;
}

.risk-dot.very-high {
    background: #991b1b;
}

.risk-dot.moderately-low {
    background: #34d399;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- Search Result Enhancement --- */
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-item .result-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    padding: 2px;
    border: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
}

.result-item .result-info {
    flex: 1;
    min-width: 0;
}

.result-item .result-category {
    font-size: 0.75rem;
    color: var(--primary-600);
    font-weight: 600;
    background: var(--primary-50);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
}

.result-item .result-arrow {
    color: var(--gray-300);
    transition: all 0.2s;
    flex-shrink: 0;
}

.result-item:hover .result-arrow {
    color: var(--primary-500);
    transform: translateX(3px);
}

/* --- Modal Dark Mode Support --- */
body.dark .invest-modal {
    background: #1e293b;
}

body.dark .modal-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

body.dark .modal-body {
    background: #0f172a !important;
}

body.dark .fund-tab {
    color: #94a3b8;
}

body.dark .fund-tab:hover {
    background: #334155;
    color: #e2e8f0;
}

body.dark .fund-tab.active {
    background: #4f46e5;
    color: white !important;
}

body.dark .fund-tabs-container {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark .modal-title,
body.dark #modal-fund-name {
    color: #f1f5f9 !important;
}

body.dark #modal-fund-meta {
    color: #94a3b8 !important;
}

body.dark .close-modal {
    color: #94a3b8;
}

body.dark .close-modal:hover {
    color: #f1f5f9;
}

body.dark .inv-tab {
    color: #94a3b8;
    border-bottom-color: #334155;
}

body.dark .inv-tab.active {
    color: #818cf8;
    border-bottom-color: #818cf8;
}

body.dark .amount-input {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark .currency-symbol {
    color: #94a3b8;
}

body.dark .quick-pill {
    background: #312e81;
    color: #a5b4fc;
    border-color: #3730a3;
}

body.dark .quick-pill:hover {
    background: #3730a3;
}

body.dark .btn-outline {
    border-color: #6366f1;
    color: #a5b4fc;
    background: transparent;
}

body.dark .btn-outline:hover {
    background: #312e81;
}

body.dark .watchlist-heart-btn {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

body.dark #modal-fund-logo {
    background: #334155 !important;
    border-color: #475569 !important;
}

body.dark #modal-range-select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

/* --- Progress bar for loading --- */
.progress-bar-top {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa);
    z-index: 9999;
    transition: width 0.3s ease;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* --- Number highlight pulse --- */
@keyframes number-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

.number-pop {
    animation: number-pop 0.4s ease;
}

/* --- Market Sentiment Badge Enhancement --- */
.trending-sentiment {
    font-size: 1rem;
    padding: 6px 14px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* --- Improved Watchlist Card --- */
.watchlist-card {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.watchlist-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* --- Performance Table Row Hover --- */
.performance-table tbody tr {
    transition: all 0.15s ease;
}

.performance-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.performance-table tbody tr:hover .sticky-col {
    background: rgba(99, 102, 241, 0.04);
}

body.dark .performance-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.08);
}

body.dark .performance-table tbody tr:hover .sticky-col {
    background: rgba(99, 102, 241, 0.08);
}