/**
 * Stock Screener CSS
 * Phase 3: Research & Discovery Engine
 * WCAG 2.1 AA Compliant
 * Matches dashboard.php design system
 */

.screener-main {
    min-height: calc(100vh - 200px);
    padding: 2rem 1rem;
}

.screener-container {
    max-width: 1800px;
    margin: 0 auto;
}

/* Header */
.screener-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 1rem;
}

.screener-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary, #e2e8f0);
    font-weight: 700;
}

.screener-header .subtitle {
    color: var(--text-secondary, #94a3b8);
    font-size: 1rem;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Screener Layout */
.screener-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
}

@media (max-width: 1200px) {
    .screener-layout {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.screener-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.criteria-panel {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.panel-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
}

.btn-icon {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    font-size: 1rem;
    transition: all 0.2s;
    line-height: 1;
}

.btn-icon:hover {
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.5);
    color: var(--text-primary, #e2e8f0);
}

/* Templates Section */
.templates-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.templates-section h3 {
    font-size: 1rem;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 1rem;
    font-weight: 600;
}

.templates-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.template-btn {
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.template-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
}

.template-btn.selected {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    border-width: 2px;
}

.template-name {
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.template-desc {
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
}

/* Criteria Sections */
.criteria-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.criteria-section:last-of-type {
    border-bottom: none;
}

.criteria-section h3 {
    font-size: 1rem;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 1rem;
    font-weight: 600;
}

.criteria-group {
    margin-bottom: 1rem;
}

.criteria-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.85rem;
    font-weight: 500;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-inputs input {
    flex: 1;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.9rem;
}

.range-inputs input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.range-inputs span {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.85rem;
}

.criteria-group select {
    width: 100%;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.9rem;
}

.criteria-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.criteria-group select[multiple] {
    min-height: 100px;
}

/* Criteria Actions */
.criteria-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-full {
    width: 100%;
    margin-bottom: 0.75rem;
}

.btn-full:last-child {
    margin-bottom: 0;
}

/* Saved Screens Panel */
.saved-screens-panel {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.saved-screens-panel h3 {
    font-size: 1rem;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 1rem;
    font-weight: 600;
}

.saved-screens-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.saved-screen-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.screen-info {
    flex: 1;
}

.screen-name {
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.screen-meta {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
}

.screen-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-primary, #e2e8f0);
}

/* Results Area */
.screener-results {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.results-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.results-count {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.9rem;
}

.results-container {
    min-height: 400px;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table thead {
    background: rgba(148, 163, 184, 0.1);
}

.results-table th {
    padding: 0.75rem;
    text-align: left;
    color: var(--text-primary, #e2e8f0);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid rgba(148, 163, 184, 0.2);
}

.results-table td {
    padding: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.results-table tbody tr:hover {
    background: rgba(148, 163, 184, 0.05);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.match-score {
    font-weight: 600;
    color: #3b82f6;
}

/* Signal Badges */
.signal-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 4px;
    white-space: nowrap;
}

.signal-badge.earnings-warning {
    background: #f59e0b;
    color: white;
}

.signal-badge.insider-positive {
    background: #10b981;
    color: white;
}

.signal-badge.insider-negative {
    background: #ef4444;
    color: white;
}

.signal-badge.upside-high {
    background: #10b981;
    color: white;
}

.signal-badge.upside-moderate {
    background: #3b82f6;
    color: white;
}

/* Aggressive Growth Template Styles */
.aggressive-growth-row {
    border-left: 3px solid #9b59b6;
}

.aggressive-growth-row:hover {
    background: rgba(155, 89, 182, 0.05);
}

.revenue-growth-mega {
    color: #e74c3c;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.priority-score {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.7rem;
    display: inline-block;
    margin-bottom: 4px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: rgba(155, 89, 182, 0.15);
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 4px;
    white-space: nowrap;
    color: #d8b4fe;
}

/* Momentum Template Styles */
.momentum-row {
    border-left: 3px solid #3b82f6;
}

.momentum-row:hover {
    background: rgba(59, 130, 246, 0.05);
}

.momentum-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 11px;
    display: inline-block;
    margin-bottom: 4px;
}

.momentum-badge.score-6,
.momentum-badge.score-7 {
    background: #51cf66;
    color: white;
}

.momentum-badge.score-4,
.momentum-badge.score-5 {
    background: #ffd93d;
    color: #333;
}

.momentum-badge.score-1,
.momentum-badge.score-2,
.momentum-badge.score-3 {
    background: #ff6b6b;
    color: white;
}

.returns {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 0;
    display: block;
}

.returns.near-high {
    color: #51cf66;
    font-weight: 600;
}

/* Combined Score Display */
.combined-score {
    font-size: 18px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 4px;
}

.combined-score.score-5 {
    background: #51cf66;
    color: white;
}

.combined-score.score-4 {
    background: #69db7c;
    color: white;
}

.combined-score.score-3 {
    background: #ffd93d;
    color: #333;
}

.combined-score.score-2 {
    background: #ff922b;
    color: white;
}

.combined-score.score-1 {
    background: #ff6b6b;
    color: white;
}

.combined-score-display {
    font-size: 16px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

.combined-score-display.score-5 {
    background: #51cf66;
    color: white;
}

.combined-score-display.score-4 {
    background: #69db7c;
    color: white;
}

.combined-score-display.score-3 {
    background: #ffd93d;
    color: #333;
}

.combined-score-display.score-2 {
    background: #ff922b;
    color: white;
}

.combined-score-display.score-1 {
    background: #ff6b6b;
    color: white;
}

.score-breakdown {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.score-breakdown .suitability {
    color: var(--text-secondary);
}

.warnings-section {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.warning-badge {
    background: #ff6b6b;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.warning-badge.info {
    background: #64748b; /* Gray, not red */
    color: white;
}

/* Insider Details */
.insider-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-secondary);
}

.insider-ratio {
    font-weight: 600;
    color: var(--text-primary);
}

.insider-transactions {
    color: var(--text-secondary);
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 4rem 2rem;
}

.spinner {
    border: 3px solid rgba(148, 163, 184, 0.2);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-state p {
    color: var(--text-secondary, #94a3b8);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h2 {
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 0.5rem;
}

.empty-state .hint {
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 1rem;
}

/* Modal Styles (reuse from watchlists) */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    margin: 0 auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary, #e2e8f0);
}

.modal-body {
    padding: 1.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary, #e2e8f0);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: #3b82f6;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.5);
}

/* Responsive */
@media (max-width: 1200px) {
    .screener-layout {
        grid-template-columns: 1fr;
    }
    
    .criteria-panel {
        max-height: none;
    }
    
    .results-table {
        font-size: 0.85rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    /* Prevent horizontal overflow on mobile */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    .screener-main {
        padding: 1rem 0.75rem;
        min-height: auto;
        overflow-x: hidden;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    .screener-container {
        max-width: 100%;
        padding: 0;
        margin: 0;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .screener-header {
        flex-direction: column;
        padding: 1rem;
        margin-bottom: 1rem;
        gap: 0.75rem;
    }
    
    .screener-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .screener-header .subtitle {
        font-size: 0.85rem;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-actions button {
        width: 100%;
    }
    
    .screener-layout {
        gap: 1rem;
        overflow-x: hidden;
    }
    
    .screener-sidebar {
        gap: 1rem;
    }
    
    .criteria-panel {
        padding: 1rem;
        max-height: none;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .panel-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    .templates-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .templates-section h3 {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .template-btn {
        padding: 0.625rem;
    }
    
    .template-name {
        font-size: 0.85rem;
    }
    
    .template-desc {
        font-size: 0.75rem;
    }
    
    .criteria-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .criteria-section h3 {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .criteria-group {
        margin-bottom: 0.875rem;
    }
    
    .criteria-group label {
        font-size: 0.8rem;
        margin-bottom: 0.375rem;
    }
    
    .range-inputs {
        gap: 0.375rem;
        flex-wrap: nowrap;
    }
    
    .range-inputs input {
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.375rem;
        font-size: 0.85rem;
        box-sizing: border-box;
    }
    
    .range-inputs span {
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .criteria-group select {
        padding: 0.5rem 0.375rem;
        font-size: 0.85rem;
        box-sizing: border-box;
    }
    
    .criteria-actions {
        margin-top: 1.5rem;
        padding-top: 1rem;
    }
    
    .btn-full {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .screener-results {
        padding: 1rem;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .results-header h2 {
        font-size: 1.25rem;
    }
    
    .results-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .results-actions button {
        width: 100%;
    }
    
    .results-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
    }
    
    .results-table {
        min-width: 600px;
        width: 100%;
        font-size: 0.8rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
    .screener-main {
        padding: 0.75rem 0.5rem;
    }
    
    .screener-header {
        padding: 0.75rem;
    }
    
    .screener-header h1 {
        font-size: 1.25rem;
    }
    
    .criteria-panel {
        padding: 0.75rem;
    }
    
    .screener-results {
        padding: 0.75rem;
    }
    
    .range-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .range-inputs span {
        display: none;
    }
    
    .range-inputs input {
        width: 100%;
    }
}

