/* --- Stock Evaluator Page Styles --- */

/* Main Layout Container */
.penny-screener-container {
    display: flex;
    max-width: 1200px;
    margin: 40px auto; /* Added more top/bottom margin for better spacing */
    padding: 0 15px; /* Added padding for smaller screens */
    gap: 20px;
}

/* Filter Panel (Left Column) */
.filter-panel {
    width: 300px;
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0; /* Prevents the panel from shrinking on smaller screens */
}

.filter-panel h3 {
    color: #1e3a8a;
    margin-top: 0;
    margin-bottom: 20px; /* Added margin */
}

.filter-group {
    margin-bottom: 15px;
    position: relative;
}

.filter-group label {
    display: block;
    color: #1e3a8a;
    font-weight: bold;
    margin-bottom: 5px;
}

.filter-group label .tooltip {
    display: inline-block;
    cursor: help;
    margin-left: 5px;
    font-size: 12px;
    color: #3b82f6;
    border: 1px solid #3b82f6;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    text-align: center;
    line-height: 14px;
}

.filter-group label .tooltip-text {
    visibility: hidden;
    opacity: 0;
    width: 220px;
    background: #1e3a8a;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    margin-top: 5px;
    font-weight: normal;
    font-size: 12px;
    transition: opacity 0.3s;
}

.filter-group label:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.filter-group input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
}

.slider-container {
    margin: 10px 0;
}

.slider-container input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.slider-values {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #4b5563;
}

/* Results Panel (Right Column) */
.results-panel {
    flex: 1;
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

#stockSearch {
    margin-bottom: 15px;
}

/* Results Table */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

#resultsTable th, #resultsTable td {
    padding: 12px 15px; /* Increased padding */
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

#resultsTable th {
    background: #1e3a8a;
    color: #ffffff;
    cursor: pointer;
    position: sticky; /* Sticky headers for vertical scroll */
    top: 0;
    z-index: 3;
}

#resultsTable th:hover {
    background: #1e40af;
}

/* Sticky first column for horizontal scroll */
#resultsTable th:first-child,
#resultsTable td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
}

#resultsTable th:first-child {
    z-index: 4; /* Higher z-index to be above other sticky headers */
}

#resultsTable td:first-child {
    background: #ffffff;
    color: #333;
    font-weight: bold;
}

#resultsTable tr:nth-child(even) td:first-child {
    background: #f9fafb;
}

#resultsTable tr:nth-child(even) {
    background: #f9fafb;
}

/* Highlight for good-value metrics */
.low-value {
    color: #15803d;
    font-weight: bold;
}

/* Pagination and Buttons */
.pagination {
    margin-top: 20px;
    text-align: center;
}

.pagination button, .reset-button {
    background: #1e3a8a;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    margin: 0 5px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pagination button:hover:not(:disabled),
.reset-button:hover {
    background-color: #1e40af;
}

.pagination button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.reset-button {
    display: block;
    width: 100%;
    margin-top: 20px;
}

.error-message {
    color: #dc2626;
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
    padding: 15px;
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
}

/* Mobile Filter Toggle Button */
.toggle-filter {
    display: none; /* Hidden by default, shown in media query */
    background: #1e3a8a;
    color: #ffffff;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* Call to Action Button */
.best-stocks-btn-container {
    text-align: center;
    padding: 40px 20px;
    background: #f0f4f8;
    margin-top: 40px;
}

.best-stocks-btn {
    display: inline-block;
    background: #2ecc71;
    color: #ffffff;
    padding: 12px 25px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
}

.best-stocks-btn:hover {
    background: #27ae60;
}


/* --- Responsive Design --- */
@media (max-width: 768px) {
    .penny-screener-container {
        flex-direction: column;
        margin-top: 20px;
        margin-bottom: 20px;
    }

    .filter-panel {
        width: 100%;
    }

    .filter-panel.collapsed {
        display: none;
    }

    .toggle-filter {
        display: block;
    }

    .best-stocks-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .table-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    #resultsTable {
        min-width: 1000px; /* Ensure table is wide enough to scroll */
    }

    #resultsTable th, #resultsTable td {
        padding: 8px;
        font-size: 14px;
    }

    #resultsTable th:first-child, #resultsTable td:first-child {
        min-width: 120px; /* Adjust sticky column width for mobile */
    }
}