/* ══════════════════════════════════════════════
   📊 STOCK SCREENER — Feature 12.2
   Complete styling for screener page
   ══════════════════════════════════════════════ */

/* ── Page Header ── */
.screener-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 12px;
}
.screener-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0;
}
.screener-title svg {
    width: 24px;
    height: 24px;
    color: #6366f1;
}
.screener-subtitle {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

/* ── Pre-built Screener Tabs ── */
.screener-presets {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.screener-presets::-webkit-scrollbar { display: none; }

.screener-preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 12px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.screener-preset-btn:hover {
    background: rgba(99,102,241,0.08);
    border-color: rgba(99,102,241,0.3);
}
.screener-preset-btn.active {
    background: rgba(99,102,241,0.12);
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}
.screener-preset-btn .preset-icon { font-size: 16px; }

/* ── Filter Panel ── */
.screener-filters {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}
.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.filter-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-header-title svg {
    width: 16px;
    height: 16px;
    color: #6366f1;
}
.filter-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.filter-toggle-btn:hover { color: #a5b4fc; }
.filter-toggle-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s;
}
.filter-toggle-btn.expanded svg {
    transform: rotate(180deg);
}

.filter-body {
    display: none;
}
.filter-body.show {
    display: block;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.filter-select,
.filter-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary, #0f172a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
    color: var(--text-primary, #fff);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}
.filter-select:focus,
.filter-input:focus {
    border-color: rgba(99,102,241,0.5);
}
.filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 32px;
}
.filter-range {
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-range .filter-input {
    flex: 1;
}
.filter-range-sep {
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    flex-shrink: 0;
}

.filter-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}
.filter-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.filter-btn-apply {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}
.filter-btn-apply:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.filter-btn-reset {
    background: var(--bg-secondary, #0f172a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    color: var(--text-secondary, #cbd5e1);
}
.filter-btn-reset:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

/* ── Results Summary ── */
.screener-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px;
}
.results-count {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
}
.results-count strong {
    color: var(--text-primary, #fff);
    font-weight: 700;
}
.results-sort {
    display: flex;
    align-items: center;
    gap: 6px;
}
.results-sort label {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}
.results-sort select {
    padding: 4px 28px 4px 10px;
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 6px;
    color: var(--text-primary, #fff);
    font-size: 12px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 12px;
}

/* ── Results Table ── */
.screener-table-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    background: var(--bg-elevated, #1e293b);
}
.screener-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
.screener-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary, rgba(0,0,0,0.15));
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    position: sticky;
    top: 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
}
.screener-table th:hover {
    color: var(--text-primary, #fff);
}
.screener-table th.sorted {
    color: #a5b4fc;
}
.screener-table th .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.15s;
}
.screener-table th:hover .sort-arrow,
.screener-table th.sorted .sort-arrow {
    opacity: 1;
}
.screener-table td {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary, #fff);
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
    white-space: nowrap;
}
.screener-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
.screener-table tbody tr:hover {
    background: rgba(99,102,241,0.05);
}
.screener-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table Cell Styles */
.td-stock {
    display: flex;
    align-items: center;
    gap: 10px;
}
.td-stock-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(99,102,241,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #a5b4fc;
    overflow: hidden;
    flex-shrink: 0;
}
.td-stock-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.td-stock-info {}
.td-stock-code {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary, #fff);
}
.td-stock-name {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-price {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.td-change {
    font-weight: 600;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}
.td-change.positive {
    color: #22c55e;
    background: rgba(34,197,94,0.1);
}
.td-change.negative {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}
.td-change.neutral {
    color: var(--text-muted, #94a3b8);
    background: rgba(148,163,184,0.08);
}
.td-volume {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary, #cbd5e1);
}
.td-mcap {
    color: var(--text-secondary, #cbd5e1);
    font-variant-numeric: tabular-nums;
}
.td-pe, .td-div {
    font-variant-numeric: tabular-nums;
}
.td-sector {
    font-size: 11px;
    padding: 3px 8px;
    background: rgba(99,102,241,0.08);
    border-radius: 6px;
    color: #a5b4fc;
    display: inline-block;
}
.td-action-btns {
    display: flex;
    gap: 6px;
}
.td-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.td-btn svg {
    width: 16px;
    height: 16px;
}
.td-btn-trade {
    background: rgba(34,197,94,0.1);
    color: #22c55e;
}
.td-btn-trade:hover {
    background: #22c55e;
    color: #fff;
}
.td-btn-alert {
    background: rgba(99,102,241,0.1);
    color: #a5b4fc;
}
.td-btn-alert:hover {
    background: rgba(99,102,241,0.25);
    color: #c7d2fe;
}

/* ── Loading & Empty States ── */
.screener-loading {
    text-align: center;
    padding: 60px 20px;
}
.screener-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, rgba(255,255,255,0.1));
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: screener-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes screener-spin { to { transform: rotate(360deg); } }
.screener-loading-text {
    font-size: 14px;
    color: var(--text-muted, #94a3b8);
}
.screener-empty {
    text-align: center;
    padding: 60px 20px;
}
.screener-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.screener-empty h3 {
    font-size: 16px;
    color: var(--text-primary, #fff);
    margin: 0 0 8px;
}
.screener-empty p {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    margin: 0;
}
.screener-error {
    text-align: center;
    padding: 40px 20px;
    color: #f87171;
}
.screener-error button {
    margin-top: 12px;
    padding: 8px 20px;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 8px;
    color: #a5b4fc;
    font-size: 13px;
    cursor: pointer;
}

/* ── Toast ── */
.screener-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid rgba(99,102,241,0.3);
}
.screener-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .screener-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
    .screener-results-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
@media (max-width: 400px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
}
