/**
 * Portfolio Heatmap Component - Professional Styling
 */

/* Main Component Container */
.portfolio-heatmap-component {
    background: white;
    border-radius: 12px;
    padding: 3rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-grey-dark, #f3f4f6);
    font-family: 'Poppins', sans-serif;
}

/* Header Section */
.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.heatmap-title-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.heatmap-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--color-dark, #1f2937);
    margin: 0;
    letter-spacing: -0.025em;
}

.heatmap-description {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-dark, #6b7280);
    margin: 0;
    opacity: 0.8;
}

/* Filter Buttons */
.heatmap-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.heatmap-filters .btn {
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* Button styling inherited from app.css:
 * - btn-primary uses --color-green
 * - btn-unselected uses --color-grey with green hover
 */

/* Loading State - Dashboard Consistent */
.heatmap-loading {
    display: none;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.heatmap-loading .loading-shimmer {
    width: 200px;
    height: 60px;
    background: linear-gradient(
            90deg,
            var(--color-grey, #f1f3f5) 25%,
            var(--color-grey-dark, #e9ecef) 50%,
            var(--color-grey, #f1f3f5) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    margin: 0 auto 1rem;
}

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

.heatmap-loading .loading-text {
    color: var(--color-dark, #6b7280);
    opacity: 0.6;
    font-size: 0.95rem;
    margin: 0;
    font-weight: 400;
}

/* Error State */
.heatmap-error-state {
    display: none;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.heatmap-error-state .error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.heatmap-error-state h4 {
    color: var(--color-dark, #374151);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.heatmap-error-state p {
    color: var(--color-dark, #6b7280);
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

.heatmap-error-state .retry-btn {
    font-family: 'Poppins', sans-serif;
}

/* Empty State */
.heatmap-empty-state {
    display: none;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.heatmap-empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.heatmap-empty-state h4 {
    color: var(--color-dark, #374151);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.heatmap-empty-state .empty-message {
    color: var(--color-dark, #6b7280);
    opacity: 0.8;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.heatmap-empty-state .btn {
    font-family: 'Poppins', sans-serif;
}

/* Visualization Container */
.portfolio-heatmap-container {
    position: relative;
    min-height: 600px;
    border-radius: 8px;
    overflow: hidden;
}

.heatmap-visualization {
    width: 100%;
    min-height: 600px;
    border-radius: 8px;
    background: white;
    transition: opacity 0.3s ease;
}

.heatmap-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* SVG Styles */
.portfolio-background {
    transition: all 0.2s ease;
}

.portfolio-label {
    transition: fill 0.15s ease;
    user-select: none;
}

.asset-rect {
    transition: stroke-width 0.2s ease, filter 0.2s ease;
}

.asset-rect:hover {
    stroke-width: 3 !important;
    filter: brightness(1.1) !important;
}

.asset-symbol,
.asset-change {
    user-select: none;
    pointer-events: none;
}

/* Professional Tooltip */
.portfolio-heatmap-tooltip {
    position: absolute;
    background: #1f2937;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-family: 'Poppins', sans-serif;
    min-width: 200px;
    max-width: 280px;
}

.portfolio-heatmap-tooltip .tooltip-header {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.portfolio-heatmap-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.portfolio-heatmap-tooltip .tooltip-row:last-child {
    margin-bottom: 0;
}

.portfolio-heatmap-tooltip .tooltip-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.portfolio-heatmap-tooltip .tooltip-value {
    color: white;
    font-weight: 600;
    text-align: right;
    margin-left: 1rem;
}

.portfolio-heatmap-tooltip .tooltip-value.positive {
    color: var(--color-positive);
}

.portfolio-heatmap-tooltip .tooltip-value.negative {
    color: var(--color-negative);
}

/* Legend */
.heatmap-footer {
    margin-top: 2rem;
}

.heatmap-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-dark, #6b7280);
    font-weight: 400;
}

.legend-color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Empty State (when no data) */
.heatmap-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.heatmap-empty-state p {
    font-size: 1rem;
    color: var(--color-dark, #6b7280);
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

/* Responsive Design */
@media (max-width: 992px) {
    .portfolio-heatmap-component {
        padding: 2rem;
    }

    .heatmap-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .heatmap-filters {
        width: 100%;
        justify-content: flex-start;
    }

    .heatmap-visualization {
        min-height: 500px;
    }

    .portfolio-heatmap-container {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .portfolio-heatmap-component {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .heatmap-title {
        font-size: 1.125rem;
    }

    .heatmap-filters .btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.875rem;
    }

    .heatmap-legend {
        gap: 1rem;
        justify-content: center;
    }

    .legend-item {
        font-size: 0.8125rem;
    }

    .legend-color {
        width: 16px;
        height: 16px;
    }

    .heatmap-visualization {
        min-height: 450px;
    }

    .portfolio-heatmap-container {
        min-height: 450px;
    }

    .portfolio-heatmap-tooltip {
        font-size: 0.875rem;
        padding: 0.875rem;
        min-width: 180px;
    }
}

@media (max-width: 576px) {
    .portfolio-heatmap-component {
        padding: 1rem;
        border-radius: 8px;
    }

    .heatmap-header {
        margin-bottom: 1.5rem;
    }

    .heatmap-title {
        font-size: 1rem;
    }

    .heatmap-filters {
        gap: 0.375rem;
    }

    .heatmap-filters .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .heatmap-legend {
        gap: 0.75rem;
    }

    .heatmap-visualization {
        min-height: 400px;
        border-radius: 6px;
    }

    .portfolio-heatmap-container {
        min-height: 400px;
    }

    .portfolio-heatmap-tooltip {
        font-size: 0.8125rem;
        padding: 0.75rem;
        min-width: 160px;
    }

    .portfolio-heatmap-tooltip .tooltip-header {
        font-size: 0.9375rem;
    }
}

/* Print Styles */
@media print {
    .portfolio-heatmap-component {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .heatmap-filters,
    .portfolio-heatmap-tooltip {
        display: none;
    }
}
