/* ========================================
   RETIREMENT PORTFOLIO TABS CSS
   Tabbed interface for investments & net worth
   Follows In-Hand design system
   ======================================== */

/* ============= TABS CONTAINER ============= */
.portfolio-tabs-container {
    margin-bottom: 12px;
    background: var(--theme-bg-primary);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--theme-border);
    overflow: hidden;
}

.portfolio-tabs-wrapper {
    position: relative;
    background: var(--theme-bg-primary);
    z-index: 10;
    padding: 0 6px;
    border-bottom: 2px solid var(--theme-border);
}

.portfolio-tabs {
    display: flex;
    gap: 2px;
    width: 100%;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 0 0 0;
    background: transparent;
}

.portfolio-tabs::-webkit-scrollbar {
    display: none;
}

.portfolio-tab {
    flex: 1 1 0; /* Equal width tabs */
    padding: 8px 6px;
    background: transparent;
    border: 1px solid var(--theme-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--theme-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0;
    text-align: center;
    text-transform: capitalize;
    position: relative;
    margin-bottom: -2px; /* Overlap with border-bottom */
    overflow: hidden;
    text-overflow: ellipsis;
}

.portfolio-tab.investment-tab {
    /* Remove min-width to allow equal flex distribution */
}

.portfolio-tab:hover:not(.active) {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-secondary);
    border-color: var(--theme-border);
}

.portfolio-tab.active {
    background: var(--theme-bg-primary);
    color: var(--theme-primary);
    border-color: var(--theme-primary);
    border-bottom: 2px solid var(--theme-bg-primary);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    z-index: 1;
}

@media (max-width: 1366px) {
    .portfolio-tabs-wrapper {
        padding: 0 4px;
    }

    .portfolio-tab-content {
        padding: 16px 16px 12px 16px;
    }
}

@media (max-width: 768px) {
    .portfolio-tabs-wrapper {
        padding: 0 4px;
    }

    .portfolio-tab {
        padding: 6px 4px;
        font-size: 10px;
        letter-spacing: 0;
    }

    .portfolio-tab-content {
        padding: 12px 12px 8px 12px;
    }
}

/* ========================================
   RESULTS PANELS CSS
   Side-by-side panels for Results and Graphs
   ======================================== */

/* ============= RESULTS PANELS CONTAINER ============= */
.results-panels-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-top: 0;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.results-panel,
.graphs-panel {
    background: var(--theme-bg-primary);
    border-radius: 0;
    padding: 24px;
    overflow-y: auto;
    height: 100%;
    min-height: 0;
}

.results-panel {
    border-right: 1px solid var(--theme-border);
}

.graphs-panel {
    border-left: 1px solid var(--theme-border);
}

.results-panel .breakdown-section {
    width: 100%;
    align-items: flex-start;
}

.results-panel .corpus-table-container {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 1200px) {
    .results-panels-container {
        grid-template-columns: 1fr;
        gap: 0;
        height: auto;
        min-height: auto;
    }
    
    .results-panel {
        border-right: none;
        border-bottom: 1px solid var(--theme-border);
    }
    
    .graphs-panel {
        border-left: none;
        border-top: 1px solid var(--theme-border);
    }
}

/* ============= TAB CONTENT ============= */
.portfolio-tab-content {
    display: none;
    animation: portfolioFadeIn 0.2s ease;
    padding: 16px 20px 12px 20px;
    background: var(--theme-bg-primary);
    border-radius: 0 0 8px 8px;
    /* Height adjusts automatically based on number of items (3 in grouped, 6 in detailed) */
    height: auto;
}

.portfolio-tab-content.active {
    display: block;
}

@keyframes portfolioFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============= LIST ITEMS ============= */
.portfolio-list {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    /* Height adjusts automatically based on number of items */
}

.portfolio-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid transparent;
    transition: all 0.15s ease;
    gap: 8px; /* Consistent gap between name and values */
    border-radius: 4px;
    margin: 0 -4px;
}

.portfolio-list-item:hover {
    background: var(--theme-bg-secondary);
    border-bottom-color: var(--theme-border);
}

.portfolio-list-item:last-child {
    border-bottom: none;
}

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

.portfolio-item-name {
    font-size: 13px;
    font-weight: 400;
    color: var(--theme-text-primary);
    margin-bottom: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: 0;
}

/* Step Up Toggle Button */
.step-up-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(134, 142, 150, 0.3);
    border-radius: 4px;
    background: rgba(134, 142, 150, 0.1);
    color: rgba(134, 142, 150, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
    font-size: 12px;
    line-height: 1;
}

.step-up-toggle:hover {
    border-color: rgba(134, 142, 150, 0.5);
    background: rgba(134, 142, 150, 0.15);
}

.step-up-toggle.active {
    background: rgba(255, 146, 43, 0.15);
    border-color: rgba(255, 146, 43, 0.4);
    color: #ff922b;
}

.step-up-toggle.active:hover {
    background: rgba(255, 146, 43, 0.25);
    border-color: rgba(255, 146, 43, 0.6);
}

.step-up-icon {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.portfolio-item-details {
    display: none;
}

.portfolio-item-values {
    text-align: right;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 9px;
    justify-content: flex-end; /* Align all items to the right */
    flex-shrink: 0; /* Prevent shrinking */
}

.portfolio-item-amount {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    letter-spacing: -0.02em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
}

/* Input with ₹ prefix */
.portfolio-input-with-prefix {
    display: inline-flex;
    align-items: center;
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 6px;
    padding: 0 8px;
    transition: all 0.15s ease;
    width: 80px; /* Reduced width for shorthand notation (was 110px) */
    flex-shrink: 0; /* Prevent shrinking */
}

.portfolio-input-with-prefix:focus-within {
    border-color: var(--theme-input-focus);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

.portfolio-input-prefix {
    font-size: 13px;
    font-weight: 500;
    color: var(--theme-text-secondary);
    margin-right: 2px;
    flex-shrink: 0;
}

/* Editable amount input */
.portfolio-item-amount-input {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    letter-spacing: -0.02em;
    background: transparent;
    border: none;
    padding: 5px 0;
    text-align: right;
    width: 100%; /* Take full available width within the prefix container */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.15s ease;
}

.portfolio-item-amount-input:focus {
    outline: none;
}

.portfolio-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(81, 207, 102, 0.12);
    color: var(--theme-success);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
    width: 60px; /* Fixed width to accommodate "xx.xx%" format */
    min-width: 60px;
    justify-content: center;
    flex-shrink: 0;
    text-align: center;
}

.portfolio-item-badge.negative {
    background: rgba(255, 107, 107, 0.12);
    color: var(--theme-danger);
}

.portfolio-item-badge.editable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.portfolio-item-badge.editable:hover {
    opacity: 0.85;
}

.portfolio-item-badge.editing {
    cursor: text;
    transition: none;
    transform: none;
}

.portfolio-item-badge.editing .rate-value {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 2px;
    border-radius: 2px;
}

.portfolio-item-badge .edit-hint {
    font-size: 9px;
    opacity: 0.5;
    margin-left: -1px;
}

.portfolio-item-badge.editing .edit-hint {
    display: none;
}

.portfolio-item-badge .rate-value {
    user-select: none;
    transition: none;
    display: inline-block;
}

.portfolio-item-badge.editing .rate-value {
    user-select: text;
    -webkit-user-select: text;
}

.portfolio-item-badge.editing .rate-value:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

/* Badge rate input */
.portfolio-badge-input {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 10px;
    padding: 3px 8px;
}

.portfolio-badge-input input {
    width: 42px;
    border: none;
    background: transparent;
    color: var(--theme-text-primary);
    font-size: 11px;
    font-weight: 600;
    text-align: right;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.portfolio-badge-input input:focus {
    outline: none;
}

.portfolio-badge-input .rate-suffix {
    font-size: 11px;
    font-weight: 600;
    color: var(--theme-text-secondary);
}

/* ============= EMPTY STATE ============= */
.portfolio-empty-state {
    text-align: center;
    padding: 24px 20px;
    color: var(--theme-text-secondary);
}

.portfolio-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.3;
}

.portfolio-empty-text {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--theme-text-muted);
}

.portfolio-add-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    background: var(--theme-primary);
    color: #ffffff;
    border: none;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.portfolio-add-button:hover {
    background: var(--theme-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--theme-shadow-medium);
}

.portfolio-add-button:active {
    transform: translateY(0);
}

/* ============= FAB (Floating Action Button) ============= */
.portfolio-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--theme-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--theme-shadow-heavy);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    border: none;
}

.portfolio-fab:hover {
    transform: scale(1.1) rotate(90deg);
    background: var(--theme-primary-hover);
    box-shadow: 0 8px 32px rgba(77, 171, 247, 0.4);
}

.portfolio-fab:active {
    transform: scale(0.95);
}

/* ============= SECTION DIVIDER ============= */
.portfolio-section-divider {
    height: 1px;
    background: var(--theme-border);
    margin: 12px 0;
    opacity: 0.5;
}

/* ============= INVESTMENT INPUT ROW ============= */
.portfolio-investment-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.portfolio-amount-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 12px;
    padding: 0 12px;
    transition: all 0.2s ease;
}

.portfolio-amount-input-wrapper:focus-within {
    border-color: var(--theme-input-focus);
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.1);
}

.portfolio-amount-input-wrapper .input-prefix {
    color: var(--theme-text-secondary);
    font-size: 16px;
    margin-right: 4px;
}

.portfolio-amount-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--theme-text-primary);
    font-size: 16px;
    font-weight: 600;
    padding: 12px 4px;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.portfolio-amount-input-wrapper input:focus {
    outline: none;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    .portfolio-tabs-wrapper {
        top: 0;
    }

    .portfolio-fab {
        bottom: 80px; /* Account for mobile navigation */
    }

    .portfolio-item-amount {
        font-size: 14px;
    }

    .portfolio-input-with-prefix {
        width: 95px; /* Slightly smaller on mobile but still consistent */
    }

    .portfolio-item-amount-input {
        width: 100%; /* Still take full width within container */
        font-size: 13px;
    }

    .portfolio-input-prefix {
        font-size: 12px;
    }

    .portfolio-item-name {
        font-size: 13px;
    }

    .portfolio-item-values {
        gap: 7px;
    }

    .portfolio-item-badge {
        padding: 3px 8px;
        font-size: 10px;
        width: 55px; /* Fixed width for mobile, slightly smaller */
        min-width: 55px;
    }
}

/* ============= PERIOD TOGGLE (M/Y) INTEGRATION ============= */
.portfolio-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--theme-border);
    opacity: 0.9;
}

.portfolio-header-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-secondary);
    letter-spacing: -0.01em;
}

/* Use existing period-toggle styles from retirement-planner.css */
.portfolio-period-toggle {
    display: flex;
    background: var(--theme-bg-tertiary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.portfolio-period-toggle input[type="radio"] {
    display: none;
}

.portfolio-period-toggle label {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.portfolio-period-toggle input[type="radio"]:checked + label {
    background: var(--theme-primary);
    color: #ffffff;
}
