/**
 * Portfolio & Watchlist Page Styles
 * Professional investment tracking interface
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --portfolio-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

/* ============================================
   Header Section
   ============================================ */
.portfolio-header {
    padding: 120px 0 40px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, transparent 100%);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
}

.title-icon {
    font-size: 36px;
}

.page-subtitle {
    font-size: 16px;
    color: var(--color-text-secondary);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.action-btn.primary {
    background: var(--portfolio-gradient);
    color: white;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
}

/* ============================================
   Summary Cards
   ============================================ */
.summary-section {
    padding: 20px 0 40px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--color-border);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.summary-card.total {
    border-left: 4px solid #3b82f6;
}

.summary-card.profit {
    border-left: 4px solid #10b981;
}

.summary-card.daily {
    border-left: 4px solid #8b5cf6;
}

.summary-card.assets {
    border-left: 4px solid #f59e0b;
}

.card-icon {
    font-size: 36px;
}

.card-content {
    display: flex;
    flex-direction: column;
}

.card-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.card-value {
    font-size: 24px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
}

.card-change {
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
}

.card-change.positive {
    color: var(--color-positive);
}

.card-change.negative {
    color: var(--color-negative);
}

.card-sub {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs-section {
    padding: 20px 0;
    position: sticky;
    top: 60px;
    z-index: 100;
    background: var(--color-bg);
}

.tabs-bar {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    width: fit-content;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--color-text);
}

.tab-btn.active {
    background: var(--portfolio-gradient);
    color: white;
}

/* ============================================
   Content Section
   ============================================ */
.content-section {
    padding: 40px 0 80px;
}

.content-section.hidden {
    display: none;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    color: var(--color-text-secondary);
    min-width: 280px;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text);
    font-size: 14px;
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-chip {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background: rgba(255, 255, 255, 0.06);
}

.filter-chip.active {
    background: var(--portfolio-gradient);
    border-color: transparent;
    color: white;
}

.add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--portfolio-gradient);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-btn:hover {
    transform: translateY(-2px);
}

/* ============================================
   Portfolio Table
   ============================================ */
.portfolio-table {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--color-border);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 40px;
}

.portfolio-table table {
    width: 100%;
    border-collapse: collapse;
}

.portfolio-table th {
    text-align: left;
    padding: 16px 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--color-border);
}

.portfolio-table td {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.portfolio-table tbody tr {
    transition: background 0.2s ease;
    cursor: pointer;
}

.portfolio-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.asset-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.asset-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
}

.asset-info {
    display: flex;
    flex-direction: column;
}

.asset-symbol {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
}

.asset-name {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.value-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.pnl-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.pnl-cell.positive {
    color: var(--color-positive);
}

.pnl-cell.negative {
    color: var(--color-negative);
}

.allocation-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.allocation-bar {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.allocation-fill {
    height: 100%;
    background: var(--portfolio-gradient);
    border-radius: 3px;
}

.allocation-text {
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.action-icons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
}

.icon-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-negative);
}

/* ============================================
   Allocation Chart
   ============================================ */
.allocation-section {
    margin-top: 40px;
}

.section-subtitle {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
}

.allocation-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
    padding: 32px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--color-border);
    border-radius: 20px;
}

.allocation-chart {
    display: flex;
    align-items: center;
    justify-content: center;
}

.allocation-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.legend-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
}

.legend-percent {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--color-text-secondary);
    min-width: 50px;
    text-align: right;
}

/* ============================================
   Watchlist Grid
   ============================================ */
.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.watchlist-card {
    padding: 24px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--color-border);
    border-radius: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.watchlist-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.watchlist-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.watchlist-header img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
}

.watchlist-info {
    flex: 1;
}

.watchlist-symbol {
    font-size: 16px;
    font-weight: 700;
}

.watchlist-name {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.watchlist-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.watchlist-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-negative);
    color: var(--color-negative);
}

.watchlist-price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}

.price-value {
    font-size: 24px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
}

.price-change {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}

.price-change.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-positive);
}

.price-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-negative);
}

.watchlist-stats {
    display: flex;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.watchlist-stat {
    flex: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   History List
   ============================================ */
.date-range {
    display: flex;
    gap: 8px;
}

.date-btn {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.date-btn.active {
    background: var(--portfolio-gradient);
    border-color: transparent;
    color: white;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--color-border);
    border-radius: 16px;
}

.history-type {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.history-type.buy {
    background: rgba(16, 185, 129, 0.15);
}

.history-type.sell {
    background: rgba(239, 68, 68, 0.15);
}

.history-asset {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.history-asset img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.history-asset-info .history-symbol {
    font-size: 14px;
    font-weight: 700;
}

.history-asset-info .history-action {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.history-details {
    text-align: right;
}

.history-value {
    font-size: 16px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.history-quantity {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.history-date {
    min-width: 100px;
    text-align: right;
}

.history-date-value {
    font-size: 14px;
    font-weight: 600;
}

.history-date-time {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal.open {
    visibility: visible;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal.open .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-body {
    padding: 24px 32px 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    color: var(--color-text);
    font-size: 15px;
}

.form-group input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
}

.type-selector {
    display: flex;
    gap: 10px;
}

.type-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.type-btn.active {
    background: var(--portfolio-gradient);
    border-color: transparent;
    color: white;
}

.asset-search-box {
    position: relative;
}

.asset-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.asset-suggestions.show {
    display: block;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.suggestion-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.suggestion-item img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--portfolio-gradient);
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 15px;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .allocation-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .tabs-bar {
        width: 100%;
        overflow-x: auto;
    }

    .portfolio-table th:nth-child(4),
    .portfolio-table td:nth-child(4),
    .portfolio-table th:nth-child(5),
    .portfolio-table td:nth-child(5) {
        display: none;
    }
}