/**
 * Company Screener Styles - Finviz Style
 * 企業スクリーニングページ用CSS
 */

/* ==========================================
   CSS Variables
========================================== */
:root {
    --screener-primary-50: #EFF6FF;
    --screener-primary-100: #DBEAFE;
    --screener-primary-500: #3B82F6;
    --screener-primary-600: #2563EB;
    --screener-primary-700: #1D4ED8;
    --screener-success: #10B981;
    --screener-success-light: #D1FAE5;
    --screener-danger: #EF4444;
    --screener-danger-light: #FEE2E2;
    --screener-warning: #F59E0B;
    --screener-gray-50: #F8FAFC;
    --screener-gray-100: #F1F5F9;
    --screener-gray-200: #E2E8F0;
    --screener-gray-300: #CBD5E1;
    --screener-gray-400: #94A3B8;
    --screener-gray-500: #64748B;
    --screener-gray-600: #475569;
    --screener-gray-700: #334155;
    --screener-gray-800: #1E293B;
    --screener-gray-900: #0F172A;
    --screener-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --screener-radius-sm: 4px;
    --screener-radius-md: 8px;
    --screener-radius-lg: 12px;
}

/* ==========================================
   Screener Panel
========================================== */
.screener-panel {
    background: white;
    border-radius: var(--screener-radius-lg);
    box-shadow: var(--screener-shadow-sm);
    border: 1px solid var(--screener-gray-200);
    margin-bottom: 20px;
    overflow: hidden;
}

/* Search & Preset Row */
.screener-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--screener-gray-50);
    border-bottom: 1px solid var(--screener-gray-200);
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 0 1 280px;
}

.screener-search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    font-size: 0.85rem;
    border: 1px solid var(--screener-gray-300);
    border-radius: var(--screener-radius-md);
    outline: none;
    transition: all 0.2s;
}

.screener-search-input:focus {
    border-color: var(--screener-primary-500);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.search-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--screener-gray-400);
    font-size: 0.85rem;
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--screener-gray-300);
    border-radius: var(--screener-radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--screener-gray-600);
    white-space: nowrap;
}

.preset-btn:hover {
    border-color: var(--screener-primary-500);
    color: var(--screener-primary-600);
}

.preset-btn.active {
    background: var(--screener-primary-600);
    border-color: var(--screener-primary-600);
    color: white;
}

.preset-btn i {
    font-size: 0.75rem;
}

/* Reset Button */
.screener-reset-btn {
    padding: 6px 12px;
    background: var(--screener-gray-100);
    border: 1px solid var(--screener-gray-300);
    border-radius: var(--screener-radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--screener-gray-600);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.screener-reset-btn:hover {
    background: var(--screener-danger-light);
    border-color: var(--screener-danger);
    color: var(--screener-danger);
}

/* ==========================================
   Results Header
========================================== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--screener-gray-50);
    border-bottom: 1px solid var(--screener-gray-200);
}

.results-count {
    font-size: 0.85rem;
    color: var(--screener-gray-600);
}

.results-count strong {
    color: var(--screener-primary-600);
    font-weight: 700;
}

/* ==========================================
   Table Wrapper
========================================== */
.screener-table-wrapper {
    background: white;
    border-radius: var(--screener-radius-lg);
    overflow: hidden;
    box-shadow: var(--screener-shadow-sm);
    border: 1px solid var(--screener-gray-200);
}

.screener-table-scroll {
    overflow-x: auto;
}

/* ==========================================
   Screener Table
========================================== */
.screener-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.screener-table th {
    background: var(--screener-gray-50);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--screener-gray-600);
    border-bottom: 1px solid var(--screener-gray-200);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    user-select: none;
}

.screener-table th:hover {
    background: var(--screener-gray-100);
}

.screener-table th.sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 6px;
    color: var(--screener-gray-400);
    font-size: 0.65rem;
}

.screener-table th.sorted-asc::after {
    content: '\f0de';
    color: var(--screener-primary-600);
}

.screener-table th.sorted-desc::after {
    content: '\f0dd';
    color: var(--screener-primary-600);
}

.screener-table th.text-right,
.screener-table td.text-right {
    text-align: right;
}

.screener-table th.text-center,
.screener-table td.text-center {
    text-align: center;
}

.screener-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--screener-gray-100);
    font-size: 0.85rem;
}

.screener-table tbody tr:hover {
    background: var(--screener-primary-50);
}

/* Company Code */
.screener-company-code {
    font-family: 'Outfit', monospace;
    font-weight: 600;
    color: var(--screener-gray-800);
    text-decoration: none;
}

.screener-company-code:hover {
    color: var(--screener-primary-600);
}

/* Company Name */
.screener-company-name {
    font-weight: 500;
    color: var(--screener-gray-800);
    text-decoration: none;
    display: block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.screener-company-name:hover {
    color: var(--screener-primary-600);
}

/* Sector Badge */
.screener-sector-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 10px;
    background: var(--screener-gray-100);
    color: var(--screener-gray-700);
    white-space: nowrap;
}

/* Sector column width constraint */
.sector-cell {
    width: 120px;
    max-width: 120px;
}

/* Sector Colors */
.screener-sector-badge.technology { background: #DBEAFE; color: #1D4ED8; }
.screener-sector-badge.financial-services { background: #D1FAE5; color: #047857; }
.screener-sector-badge.consumer-cyclical { background: #FEF3C7; color: #A16207; }
.screener-sector-badge.industrials { background: #CFFAFE; color: #0891B2; }
.screener-sector-badge.healthcare { background: #FCE7F3; color: #BE185D; }
.screener-sector-badge.communication-services { background: #FEF9C3; color: #A16207; }
.screener-sector-badge.basic-materials { background: #FFEDD5; color: #C2410C; }
.screener-sector-badge.consumer-defensive { background: #E0E7FF; color: #4338CA; }
.screener-sector-badge.energy { background: #FEE2E2; color: #DC2626; }
.screener-sector-badge.utilities { background: #ECFDF5; color: #059669; }
.screener-sector-badge.real-estate { background: #EDE9FE; color: #7C3AED; }

/* Metric Values */
.metric-value {
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
}

.metric-value.positive {
    color: var(--screener-success);
}

.metric-value.negative {
    color: var(--screener-danger);
}

.metric-value.na {
    color: var(--screener-gray-400);
}

/* Stock Price with Change */
.stock-price {
    font-weight: 600;
    color: var(--screener-gray-800);
    white-space: nowrap;
}

.price-change {
    font-size: 0.75rem;
    margin-left: 4px;
    white-space: nowrap;
}

.price-change.positive {
    color: var(--screener-success);
}

.price-change.negative {
    color: var(--screener-danger);
}

/* ==========================================
   Pagination
========================================== */
.screener-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px;
}

.pagination-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--screener-gray-300);
    border-radius: var(--screener-radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--screener-gray-700);
    transition: all 0.15s;
}

.pagination-btn:hover:not(.active):not(:disabled) {
    background: var(--screener-gray-100);
}

.pagination-btn.active {
    background: var(--screener-primary-600);
    border-color: var(--screener-primary-600);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   Loading State
========================================== */
.screener-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--screener-gray-500);
}

.screener-loading i {
    font-size: 2rem;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================
   No Results
========================================== */
.screener-no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--screener-gray-500);
}

.screener-no-results i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--screener-gray-300);
}

/* ==========================================
   Responsive
========================================== */
@media (max-width: 768px) {
    .screener-top {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-wrapper {
        flex: 1 1 100%;
    }

    .preset-buttons {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .screener-reset-btn {
        margin-left: 0;
    }

    .results-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .screener-company-name {
        max-width: 150px;
    }
}
