/* ================================================================
   Portfolio Page — Holographic Edition
   ================================================================
   Rebuilt to use the Wealth Terminal holographic design system.
   All cards are .holo-card. All icons are .p-icon.
   Color tokens from dashboard-tokens.css — no hardcoded hex.
   ================================================================ */

/* ── Page Layout ──────────────────────────────────────────────── */

.portfolio-page {
    display: flex;
    width: 100%;
    min-height: 100vh;
    background: var(--content-bg);
}

.portfolio-main {
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 0;
    background: var(--content-bg);
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: 0;
}

.portfolio-container {
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    padding: 24px var(--page-padding-x) var(--page-padding-bottom);
    width: 100%;
    max-width: var(--page-max-width);
}

/* ── Portfolio Header ─────────────────────────────────────────── */

.portfolio-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--page-title-icon-gap);
    margin-top: 0;
    margin-bottom: var(--section-gap);
    padding: 0;
}

.portfolio-page-title {
    font-family: var(--font-family);
    font-size: var(--page-title-font-size);
    font-weight: var(--page-title-font-weight);
    line-height: var(--page-title-line-height);
    letter-spacing: -0.02em;
    color: var(--page-title-color);
    margin: 0;
}

/* ── Portfolio Value Card ─────────────────────────────────────── */

.portfolio-value-section {
    position: relative;
    padding-top: 0;
    margin-top: 0;
}

.portfolio-value-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--section-gap);
    width: 100%;
    min-height: 132px;
    margin-bottom: 0;
}

/* Holo-card handles border-radius, background, shadow, padding */

.portfolio-value-card-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    position: relative;
    z-index: 1;
}

.portfolio-value-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.portfolio-value-label-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.portfolio-value-label {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--label-color);
}

.portfolio-value-help-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.portfolio-value-amount-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.portfolio-value-amount {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 32px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--page-title-color);
}

.portfolio-value-badge {
    box-sizing: border-box;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    padding: 2px 10px 2px 8px;
    gap: 4px;
    background: var(--badge-success-bg);
    border: 1px solid #ABEFC6;
    border-radius: 16px;
}

.portfolio-value-badge span {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    line-height: 20px;
    color: var(--badge-success-color);
}

/* ── Actions / Show More ──────────────────────────────────────── */

.portfolio-value-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.portfolio-show-more-btn {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 8px 16px;
    gap: 4px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--btn-border-radius);
    cursor: pointer;
    transition: var(--btn-transition);
}

.portfolio-show-more-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--input-border-color);
}

.portfolio-show-more-btn span {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--body-color);
}

.portfolio-show-more-btn svg {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-show-more-btn svg path {
    stroke: var(--body-color);
}

.portfolio-show-more-btn svg.rotate-180 {
    transform: rotate(180deg);
}

/* ── Chart Section ────────────────────────────────────────────── */

.portfolio-chart-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    flex-shrink: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

/* Alpine.js transition helpers */
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.ease-out { transition-timing-function: cubic-bezier(0, 0, 0.2, 1); }
.ease-in { transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
.duration-500 { transition-duration: 500ms; }
.duration-300 { transition-duration: 300ms; }
.max-h-0 { max-height: 0; }
.max-h-96 { max-height: 24rem; }
.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }
.-translate-y-4 { transform: translateY(-1rem); }
.translate-y-0 { transform: translateY(0); }
[x-cloak] { display: none !important; }

/* Chart Header */
.portfolio-chart-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: 36px;
}

.portfolio-chart-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.chart-title-text {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 18px;
    line-height: 28px;
    color: var(--page-title-color);
    white-space: nowrap;
}

.chart-title-percentage {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 18px;
    line-height: 28px;
    color: var(--badge-success-color);
    white-space: nowrap;
}

.chart-title-percentage.chart-title-negative {
    color: var(--btn-danger-bg);
}

/* Chart Controls */
.portfolio-chart-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

.portfolio-chart-tabs {
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    height: 36px;
    background: var(--content-bg);
    border: 1px solid var(--table-border-color);
    border-radius: var(--btn-border-radius);
    padding: 3px;
}

.chart-tab {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 12px;
    height: 30px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 20px;
    color: var(--table-header-color);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chart-tab.active {
    background: var(--card-bg);
    color: var(--page-title-color);
    box-shadow: var(--card-shadow);
}

.chart-tab:hover:not(.active) {
    color: var(--body-color);
    background: rgba(255, 255, 255, 0.5);
}

.portfolio-chart-filter {
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 12px;
    gap: 4px;
    height: 36px;
    background: var(--card-bg);
    border: 1px solid var(--input-border-color);
    border-radius: var(--btn-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.portfolio-chart-filter:hover {
    background: var(--table-row-hover-bg);
    border-color: var(--body-color);
}

.portfolio-chart-filter span {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--body-color);
}

/* Chart Container */
.portfolio-chart-container {
    position: relative;
    width: 100%;
    height: 240px;
    min-height: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    isolation: isolate;
    flex: 1;
}

/* Y-Axis Grid */
.chart-grid {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 222px;
    left: 0;
    top: 0;
    z-index: 0;
}

.grid-line {
    position: relative;
    width: 100%;
    height: 0px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.grid-line-base {
    border-bottom: 1px solid var(--table-border-color);
}

/* Chart Bars */
.chart-bars {
    position: absolute;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 16px;
    gap: 12px;
    left: 0;
    right: 0;
    top: 0;
    bottom: 27px;
    z-index: 2;
}

.chart-bar-week {
    margin: 0 auto;
    width: 8px;
    max-width: 8px;
    background: linear-gradient(180deg, #03FF88 0%, #00CC6F 100%);
    border-radius: 4px 4px 0 0;
    flex: 1;
    animation: growBar 0.5s ease-out forwards;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: filter 0.2s ease, transform 0.15s ease;
    cursor: pointer;
    position: relative;
}

.chart-bar-week:hover {
    filter: brightness(1.15);
    transform: scaleY(1.03);
    transform-origin: bottom;
}

@keyframes growBar {
    0% { transform: scaleY(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scaleY(1); opacity: 1; }
}

/* Trend Line */
.chart-trend-line {
    position: absolute;
    width: 100%;
    height: 93px;
    left: 0;
    top: calc(50% - 46px + 15px);
    pointer-events: none;
    z-index: 3;
}

.chart-trend-line path {
    stroke: rgba(0, 0, 255, 0.35);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    fill: none;
}

/* X-Axis Labels */
.chart-x-axis {
    position: absolute;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    width: 100%;
    height: 18px;
    bottom: 0;
    left: 0;
    z-index: 1;
    box-sizing: border-box;
}

.chart-x-axis span {
    font-family: var(--font-family);
    font-weight: 400;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    color: var(--label-color);
}

/* ── Key Financials Section ───────────────────────────────────── */

.key-financials-section {
    position: relative;
    margin-top: 0;
}



.key-financials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--section-gap);
    width: 100%;
}

.key-financials-card {
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    isolation: isolate;
    flex: 1;
    min-height: 108px;
    height: auto;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* When .holo-card is applied, these are the only overrides we need */
.key-financials-card.holo-card {
    overflow: visible;
}

.key-financials-card-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.financials-text-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.financials-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.financials-title {
    white-space: nowrap;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--label-color);
}

.financials-info {
    width: 14px;
    height: 14px;
    background: none;
    border: none;
    cursor: help;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.financials-value-wrapper {
    display: flex;
    flex-direction: row;
    align-items: baseline;
}

.financials-value {
    display: flex;
    align-items: baseline;
}

.financials-currency,
.financials-amount {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 24px;
    line-height: 32px;
    color: var(--page-title-color);
}

.financials-period-wrapper {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    z-index: 1;
}

.financials-change {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 2px 8px 2px 6px;
    gap: 4px;
    height: 24px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 6px;
}

.financials-change svg {
    width: 12px;
    height: 12px;
}

.financials-change.change-increase svg path { stroke: #17B26A; }
.financials-change.change-decrease svg path { stroke: var(--btn-danger-bg); }
.financials-change.change-neutral svg { display: none; }
.financials-change.change-increase .financials-percent { color: var(--badge-success-color); }
.financials-change.change-decrease .financials-percent { color: var(--btn-danger-bg); }
.financials-change.change-neutral .financials-percent { color: var(--label-color); }

.financials-percent {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--body-color);
}

.financials-period {
    font-family: var(--font-family);
    font-weight: 400;
    font-size: 12px;
    line-height: 18px;
    color: var(--label-color);
    white-space: nowrap;
}

/* ── Quick Insights ───────────────────────────────────────────── */

.insights-limit-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--section-gap);
    position: relative;
    margin-top: var(--section-gap);
    width: 100%;
}

.quick-insights-wrapper {
    display: flex;
    flex-direction: column;
}

.quick-insights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.quick-insights-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    min-height: 104px;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.quick-insights-card.holo-card {
    overflow: visible;
}

.insights-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.insights-icon-wrapper {
    flex-shrink: 0;
}

.insights-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.insights-title {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: var(--body-font-size);
    line-height: 20px;
    color: var(--label-color);
}

.insights-value {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 24px;
    line-height: 32px;
    color: var(--page-title-color);
    letter-spacing: -0.02em;
}

/* ── Assets Table ─────────────────────────────────────────────── */

.assets-section {
    position: relative;
    margin-top: 0;
    width: 100%;
}



/* Override holo-card padding for table container */
.portfolio-assets-table.holo-card {
    padding: 0 !important;
    overflow: hidden;
}

/* ── State Panels (Error / Empty) ─────────────────────────────── */

.hidden {
    display: none !important;
}

.portfolio-state-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 24px;
    text-align: center;
    width: 100%;
    margin-top: var(--section-gap);
}

.portfolio-state-panel.holo-card {
    border: 1px solid rgba(0, 0, 0, 0.03);
}

#portfolio-empty-state > img {
    opacity: 0.5;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.state-title {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    color: var(--page-title-color);
    margin: 0;
}

.state-desc {
    font-family: var(--font-family);
    font-weight: 400;
    font-size: var(--body-font-size);
    line-height: 20px;
    text-align: center;
    color: var(--label-color);
    max-width: 352px;
    margin: 0 0 16px 0;
}

.state-icon {
    width: 48px;
    height: 48px;
    color: var(--label-color);
    margin-bottom: 12px;
}

.retry-btn {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--body-font-size);
    line-height: 20px;
    padding: 10px 18px;
    background: var(--btn-primary-bg);
    color: #FFFFFF;
    border: none;
    border-radius: var(--btn-border-radius);
    cursor: pointer;
    transition: var(--btn-transition);
    text-decoration: none;
}

.retry-btn:hover {
    background: var(--btn-primary-hover-bg);
}

/* ── Loading Skeleton ─────────────────────────────────────────── */

@keyframes portfolio-shimmer {
    0% { background-position: -800px 0; }
    100% { background-position: 800px 0; }
}

.skeleton-box {
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.06) 37%, rgba(0,0,0,0.03) 63%);
    background-size: 800px 100%;
    animation: portfolio-shimmer 1.4s infinite linear;
    border-radius: 24px;
}

.portfolio-loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    padding-top: 16px;
    width: 100%;
}

.portfolio-sk-row {
    display: flex;
    gap: 16px;
}

.portfolio-sk-value-card { height: 132px; width: 100%; }
.portfolio-sk-card { height: 108px; flex: 1; }
.portfolio-sk-insights { height: 160px; flex: 1; }
.portfolio-sk-table { height: 320px; width: 100%; }

/* ── Pulse animation for loading text ─────────────────────────── */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Smooth scrollbar ─────────────────────────────────────────── */

.portfolio-main::-webkit-scrollbar { width: 6px; }
.portfolio-main::-webkit-scrollbar-track { background: transparent; }
.portfolio-main::-webkit-scrollbar-thumb { background: var(--input-border-color); border-radius: 3px; }
.portfolio-main::-webkit-scrollbar-thumb:hover { background: var(--label-color); }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 1400px) {
    .key-financials-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .key-financials-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-insights-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .key-financials-grid {
        grid-template-columns: 1fr;
    }
    .quick-insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .portfolio-main {
        width: 100%;
        margin-left: 0;
        padding: 16px;
        padding-top: 80px;
    }

    .portfolio-page-title {
        font-size: 28px !important;
    }

    .portfolio-value-section,
    .key-financials-section,
    .insights-limit-section,
    .assets-section {
        padding: 0;
    }

    .quick-insights-grid {
        grid-template-columns: 1fr;
    }

    .key-financials-grid {
        grid-template-columns: 1fr;
    }

    .financials-period-wrapper {
        position: static;
        transform: none;
        align-items: flex-start;
        margin-top: 8px;
    }
}
