﻿

/* Portfolio Manager Specific Styles */
.page-header {
    margin-bottom: 30px;
    border-bottom: 2px solid var(--accent-main);
    padding-bottom: 15px;
}

.watchlist-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--curve-box-border-color);
}

.watchlist-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.price-status {
    font-size: 12px;
    color: #6c757d;
    padding: 5px 10px;
    background: #e9ecef;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

    .price-status.loading {
        background: #fff3cd;
        color: #856404;
    }

    .price-status.updated {
        background: #d1edff;
        color: #0c5460;
    }

    .price-status.error {
        background: #f8d7da;
        color: #721c24;
    }

/*
select, input, button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

    select:focus, input:focus {
        outline: none;
        border-color: var(--link-color);
    }
        */

#customPortfolioTracker select, #customPortfolioTracker input, #customPortfolioTracker button, .btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.btn {
    background: var(--link-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

    .btn:hover {
        background: var(--link-color-hover);
    }

.btn-secondary {
    background: #6c757d;
}

    .btn-secondary:hover {
        background: #5a6268;
    }

.btn-danger {
    background: var(--ticker-down-color);
}

    .btn-danger:hover {
        background: #8b0000;
    }

.btn-refresh {
    background: var(--link-color-hover);
    font-size: 14px;
    padding: 8px 12px;
}

    .btn-refresh:hover {
        background: #00b894;
    }

    .btn-refresh:disabled {
        background: #6c757d;
        cursor: not-allowed;
    }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--curve-box-border-color);
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--main-font-color);
    margin-bottom: 5px;
}

.stat-label {
    color: #6c757d;
    font-size: 14px;
}

.add-stock-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border: 1px solid var(--curve-box-border-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

    .form-group label {
        margin-bottom: 5px;
        font-weight: 600;
        color: var(--main-font-color);
    }

.stock-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--curve-box-border-color);
    overflow-x: auto; /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

    .stock-table table {
        width: 100%;
        border-collapse: collapse;
        min-width: 800px; /* Minimum width to prevent cramping */
    }

/* Specific column width constraints */
.stock-table th:first-child,
.stock-table td:first-child {
    min-width: 120px; /* Symbol column */
    max-width: 120px;
}

.stock-table th:nth-child(2),
.stock-table td:nth-child(2) {
    min-width: 80px; /* Price column */
    text-align: right;
}

.stock-table th:nth-child(3),
.stock-table td:nth-child(3) {
    min-width: 70px; /* Change column */
    text-align: right;
}

.stock-table th:nth-child(4),
.stock-table td:nth-child(4) {
    min-width: 80px; /* Change % column */
    text-align: right;
}

.stock-table th:nth-child(5),
.stock-table td:nth-child(5) {
    min-width: 90px; /* Shares column */
    text-align: right;
}

.stock-table th:nth-child(6),
.stock-table td:nth-child(6) {
    min-width: 90px; /* Avg Cost column */
    text-align: right;
}

.stock-table th:nth-child(7),
.stock-table td:nth-child(7) {
    min-width: 110px; /* Market Value column */
    text-align: right;
}

.stock-table th:nth-child(8),
.stock-table td:nth-child(8) {
    min-width: 100px; /* Gain/Loss column */
    text-align: right;
}

.stock-table th:nth-child(9),
.stock-table td:nth-child(9) {
    min-width: 100px; /* Gain/Loss % column */
    text-align: right;
}

.stock-table th:nth-child(10),
.stock-table td:nth-child(10) {
    min-width: 80px; /* Weight % column */
    text-align: right;
}

/* Company name styling with ellipsis */
.stock-name {
    color: #6c757d;
    font-size: 12px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.stock-symbol {
    font-weight: 700;
    color: var(--main-font-color);
    font-size: 16px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Scrollbar styling for better mobile experience */
.stock-table::-webkit-scrollbar {
    height: 8px;
}

.stock-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.stock-table::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

    .stock-table::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

    .stock-table .numcell {
        font-family:monospace;
        font-size:16px
    }

    table {
        width: 100%;
        border-collapse: collapse;
    }
     
/* Improved cell styling with text overflow handling */
th, td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}


th {
    background: var(--header-bg);
    color: white;
    font-weight: 600;
    font-size: 13px;
}



tbody tr:nth-child(even) {
    background-color: #f8f8f8;
}
tbody tr:hover {
    background-color: rgb(232, 244, 255) !important;
}

.stock-symbol {
    font-weight: 700;
    color: var(--main-font-color);
    font-size: 16px;
}

.stock-name {
    color: #6c757d;
    font-size: 12px;
}

.editable-field {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px;
    border-radius: 3px;
    width: 70px;
    font-size: 13px;
}

    .editable-field:focus {
        background: white;
        border-color: var(--link-color);
        outline: none;
    }

.remove-btn {
    background: var(--ticker-down-color);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

    .remove-btn:hover {
        background: #8b0000;
    }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

    .empty-state h3 {
        margin-bottom: 10px;
        color: var(--main-font-color);
    }

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 25px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow);
}

.stock-count {
    font-size: 14px;
    color: #6c757d;
    font-weight: 600;
}

/* Ticker Suggestions Dropdown */
.ticker-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.ticker-suggestion {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    line-height: 1.4;
}

    .ticker-suggestion:hover {
        background: #f8f9fa;
    }

    .ticker-suggestion:last-child {
        border-bottom: none;
    }

    .ticker-suggestion strong {
        color: var(--link-color);
        font-weight: 600;
    }

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

    .sortable:hover {
        background: rgb(6, 121, 193);
    }

.sort-indicator {
    font-size: 12px;
    margin-left: 5px;
    opacity: 0.5;
}

    .sort-indicator.active {
        opacity: 1;
    }

/* QuoteMedia widget container */
#qm_wl {
    position: absolute;
    left: -9999px;
    top: -9999px;
    visibility: hidden;
}

/* Responsive Design */
@media (max-width: 800px) {
    /* Form adjustments */
    .form-row {
        grid-template-columns: 1fr;
    }

    .watchlist-controls,
    .portfolio-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .refresh-controls {
        justify-content: center;
    }

    /* Table adjustments for mobile */
    .stock-table {
        margin: 0 -10px; /* Allow table to extend slightly beyond container */
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

        .stock-table table {
            min-width: 700px; /* Slightly reduced for mobile */
            font-size: 12px;
        }

         

    th, td {
        padding: 8px 6px;
        font-size: 11px;
    }

    /* Reduce column widths slightly for mobile */
    .stock-table th:first-child,
    .stock-table td:first-child {
        min-width: 100px;
        max-width: 100px;
    }

    .stock-table th:nth-child(2),
    .stock-table td:nth-child(2) {
        min-width: 70px;
    }

    .stock-table th:nth-child(3),
    .stock-table td:nth-child(3) {
        min-width: 60px;
    }

    .stock-table th:nth-child(4),
    .stock-table td:nth-child(4) {
        min-width: 70px;
    }

    .stock-table th:nth-child(5),
    .stock-table td:nth-child(5) {
        min-width: 80px;
    }

    .stock-table th:nth-child(6),
    .stock-table td:nth-child(6) {
        min-width: 80px;
    }

    .stock-table th:nth-child(7),
    .stock-table td:nth-child(7) {
        min-width: 90px;
    }

    .stock-table th:nth-child(8),
    .stock-table td:nth-child(8) {
        min-width: 85px;
    }

    .stock-table th:nth-child(9),
    .stock-table td:nth-child(9) {
        min-width: 85px;
    }

    .stock-table th:nth-child(10),
    .stock-table td:nth-child(10) {
        min-width: 70px;
    }

    /* Adjust company name and symbol for mobile */
    .stock-name {
        font-size: 10px;
        max-width: 80px;
    }

    .stock-symbol {
        font-size: 14px;
        max-width: 80px;
    }

    /* Editable field adjustments */
    .editable-field {
        width: 50px;
        font-size: 11px;
    }

    /* Stats grid adjustments */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 15px 10px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 12px;
    }
}



/* Horizontal scroll indicator for users */
.stock-table::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 800px) {
    .stock-table::before {
        opacity: 1;
    }
}

/* Loading state improvements for mobile */
.stock-table.loading {
    position: relative;
}

    .stock-table.loading::after {
        content: 'Swipe left to see more →';
        position: absolute;
        bottom: 10px;
        right: 10px;
        background: rgba(0,0,0,0.7);
        color: white;
        padding: 5px 10px;
        border-radius: 15px;
        font-size: 12px;
        opacity: 0.8;
        pointer-events: none;
    }

@media (min-width: 801px) {
    .stock-table.loading::after {
        display: none;
    }
}