/* ============================================================================
   Skeleton Loading Placeholders
   ============================================================================ */

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

.skeleton-line {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
    border-radius: 4px;
    height: 14px;
}

body.light-theme .skeleton-line {
    background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.10) 50%, rgba(0,0,0,0.06) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

.skeleton-line-xs { height: 10px; }
.skeleton-line-sm { height: 12px; }
.skeleton-line-md { height: 16px; }
.skeleton-line-lg { height: 22px; }

.skeleton-portfolio-hero-wrapper {
    display: flex;
    gap: 14px;
    margin-bottom: 25px;
    align-items: stretch;
}

.skeleton-portfolio-hero {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow);
    overflow: hidden;
}

.skeleton-portfolio-chart {
    padding: 20px 20px 0 20px;
    display: flex;
    flex-direction: column;
}

.skeleton-chart-area {
    height: 140px;
    margin-top: 12px;
    background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
    border-radius: 8px;
}

body.light-theme .skeleton-chart-area {
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.06) 50%, rgba(0,0,0,0.03) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

.skeleton-metrics-grid {
    width: 430px;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr 1fr;
    gap: 10px;
}

.skeleton-metric-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 10px 30px var(--shadow);
}

body.light-theme .skeleton-metric-box {
    background: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.skeleton-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.skeleton-card {
    background: var(--bg-card);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    border-left: 5px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 10px 30px var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.skeleton-card-header {
    padding: 14px 16px 0 16px;
}

.skeleton-card-balance {
    padding: 8px 16px 0 16px;
}

.skeleton-card-chart {
    flex: 1;
    min-height: 70px;
    margin: 8px 0 0 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

body.light-theme .skeleton-card-chart {
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.06) 50%, rgba(0,0,0,0.03) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.8s infinite ease-in-out;
}

/* Skeleton responsive */
@media (max-width: 768px) {
    .skeleton-portfolio-hero-wrapper {
        flex-direction: column;
    }

    .skeleton-metrics-grid {
        width: auto;
        grid-template-columns: repeat(4, 1fr);
    }

    .skeleton-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .skeleton-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================================
   Account Cards Styles
   - Account cards grid
   - Card hover and drag states
   - Combined accounts
   - Balance and stats display
   ============================================================================ */

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    grid-auto-rows: minmax(200px, auto);
}

.account-card {
    background: var(--bg-card);
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s, opacity 0.3s, background 0.3s;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-left: 5px solid #667eea;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.account-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-left: 5px solid #764ba2;
}

.account-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.account-card.drag-over {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Drag Handle */
.drag-handle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0;
    pointer-events: none;
}

.account-card:hover .drag-handle {
    opacity: 0.6;
    pointer-events: auto;
}

.account-card:hover .drag-handle:hover {
    background: rgba(148, 163, 184, 0.25);
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

body.light-theme .drag-handle {
    background: rgba(71, 85, 105, 0.1);
}

body.light-theme .drag-handle:hover {
    background: rgba(71, 85, 105, 0.2);
}

/* Combined Account Styles */
.combined-account {
    border: 2px solid rgba(251, 191, 36, 0.4);
    border-left: 5px solid #fbbf24;
    background: linear-gradient(135deg,
        rgba(251, 191, 36, 0.05) 0%,
        rgba(15, 23, 34, 0.9) 100%);
}

body.light-theme .combined-account {
    background: linear-gradient(135deg,
        rgba(251, 191, 36, 0.08) 0%,
        rgba(255, 255, 255, 1) 100%);
}

.combined-account:hover {
    border: 2px solid rgba(251, 191, 36, 0.6);
    border-left: 5px solid #fbbf24;
}

.combined-icon {
    display: inline-block;
    font-size: 1.2em;
    vertical-align: middle;
    margin-right: 8px;
}

.account-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 16px 0 16px;
}

.account-header-left {
    flex: 1;
    min-width: 0;
}

.account-header-right {
    flex-shrink: 0;
    text-align: right;
}

.account-header-right .updated-indicator {
    font-size: 0.75em;
    color: #a0aec0;
}

.account-name {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-number {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.account-balance-section {
    padding: 8px 16px 0 16px;
}

.balance-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.gain-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 4px;
}

.gain-value {
    font-size: 0.95em;
    font-weight: 600;
}

.gain-value.positive {
    color: #48bb78 !important;
}

.gain-value.negative {
    color: #f56565 !important;
}

.gain-percent {
    font-size: 0.85em;
    font-weight: 500;
}

.gain-percent.positive {
    color: #48bb78 !important;
}

.gain-percent.negative {
    color: #f56565 !important;
}

/* Equity curve container */
.equity-curve-container {
    flex: 1;
    min-height: 70px;
    padding: 8px 0 0 0;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 15px 10px;
}

.equity-curve-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Legacy stat styles kept for table view and detail pages */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-item {
    padding: 12px;
    background: #0f172a;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    font-size: 0.8em;
    color: #94a3b8;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.1em;
    font-weight: 600;
    color: #f1f5f9;
}

.stat-value.positive {
    color: #48bb78 !important;
}

.stat-value.negative {
    color: #f56565 !important;
}

.positive {
    color: #48bb78 !important;
}

.negative {
    color: #f56565 !important;
}

/* Portfolio Hero */
.portfolio-hero-wrapper {
    display: flex;
    gap: 14px;
    margin-bottom: 25px;
    align-items: stretch;
}

.portfolio-hero {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.portfolio-hero-chart {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 0 20px;
    min-width: 0;
    width: 100%;
    position: relative;
}

.portfolio-hero-header {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.portfolio-hero-balance {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.portfolio-hero-gain {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
    font-size: 0.85em;
    font-weight: 500;
}

.portfolio-hero-canvas-wrap {
    flex: 1;
    min-height: 120px;
    margin-top: 8px;
    position: relative;
    width: 100%;
}

.portfolio-hero-canvas-wrap canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

.portfolio-hero-metrics {
    width: 430px;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr 1fr;
    gap: 10px;
}

.hero-metric-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 10px 30px var(--shadow);
}

body.light-theme .hero-metric-box {
    background: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.hero-metric-box-tall {
    align-self: stretch;
}

.hero-metric-box-header {
    display: flex;
    align-items: center;
    gap: 5px;
}

.hero-metric-icon {
    width: 14px;
    height: 14px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

.hero-metric-label {
    font-size: 0.7em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.hero-metric-value {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-metric-value.positive {
    color: #48bb78;
}

.hero-metric-value.negative {
    color: #f56565;
}

.hero-metric-sub {
    font-size: 0.75em;
    color: var(--text-secondary);
}

.hero-metric-sub.positive {
    color: #48bb78;
}

.hero-metric-sub.negative {
    color: #f56565;
}

.portfolio-hero-account-count {
    font-size: 0.85em;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 6px;
}

/* Light theme stat-item overrides */
body.light-theme .stat-item {
    background: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-theme .stat-label {
    color: #475569;
}

body.light-theme .stat-value {
    color: #0f172a;
}

/* Desktop - smaller text for account cards */
@media (min-width: 1024px) {
    /* Account cards */
    .account-name {
        font-size: 1em;
    }

    .account-number {
        font-size: 0.75em;
    }

    .balance-value {
        font-size: 1.25em;
    }

    .gain-value {
        font-size: 0.85em;
    }

    .gain-percent {
        font-size: 0.8em;
    }

    .stat-label {
        font-size: 0.7em;
    }

    .stat-value {
        font-size: 0.95em;
    }

    .stat-item {
        padding: 10px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Portfolio hero on mobile */
    .portfolio-hero-wrapper {
        flex-direction: column;
    }

    .portfolio-hero-metrics {
        width: auto;
        grid-template-columns: repeat(4, 1fr);
    }

    .portfolio-hero-chart {
        padding: 12px 16px 0 16px;
    }

    .portfolio-hero-header {
        margin-bottom: 2px;
    }

    .portfolio-hero-balance {
        font-size: 1.6em;
        display: inline;
    }

    .portfolio-hero-gain {
        display: inline;
        margin-top: 0;
        margin-left: 8px;
    }

    /* Cards grid on mobile - single column */
    .accounts-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    /* Account card text - smaller on mobile */
    .account-name {
        font-size: 1.1em;
    }

    .balance-value {
        font-size: 1.3em;
    }

    .equity-curve-container {
        min-height: 60px;
    }

    .hero-metric-label {
        white-space: normal;
    }

    /* Detail page account name - smaller on mobile */
    #detailAccountName {
        font-size: 1.2em !important;
    }
}

@media (max-width: 480px) {
    .portfolio-hero-balance {
        font-size: 1.5em;
    }

    .portfolio-hero-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    /* AVG WIN / AVG LOSS — same row, slightly taller to balance the grid */
    .hero-metric-box-tall {
        min-height: 90px;
    }

    /* Reduce card padding on small screens */
    .account-header {
        padding: 12px 10px 0 10px;
    }

    .account-balance-section {
        padding: 6px 10px 0 10px;
    }
}
