/* ============================================================================
   News Impact Analysis
   - Timeframe toggle buttons
   - Event group table with expandable detail rows
   - Summary stats cards
   - Responsive layout
   ============================================================================ */

/* Account selector cards */
.news-account-card {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.news-account-single {
    border-left: 3px solid #667eea;
}

.news-account-group {
    border-left: 3px solid #fbbf24;
}

.news-account-single:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.news-account-group:hover {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}

.news-account-single.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.15);
}

.news-account-group.active {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
}

.news-account-upload {
    border: 2px dashed rgba(16, 185, 129, 0.4);
    border-left: 3px solid #10b981;
}

.news-account-upload:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.news-account-upload.active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

/* Match mode toggle (Open / Close) */
.news-match-mode-bar {
    display: flex;
    gap: 6px;
    background: var(--toggle-bg, rgba(30, 41, 59, 0.5));
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.news-match-mode-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.news-match-mode-btn:hover {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.1);
}

.news-match-mode-btn.active {
    background: #667eea;
    color: #ffffff;
}

/* Timeframe toggle buttons */
.news-timeframe-bar {
    display: flex;
    gap: 6px;
    background: var(--toggle-bg, rgba(30, 41, 59, 0.5));
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.news-timeframe-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.news-timeframe-btn:hover {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.1);
}

.news-timeframe-btn.active {
    background: #667eea;
    color: #ffffff;
}

/* Data range info */
.news-data-range {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.news-range-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.news-range-label {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.news-range-dates {
    white-space: nowrap;
}

.news-range-count {
    opacity: 0.7;
    white-space: nowrap;
}

/* Filter bar layout */
.news-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Symbol button bar (desktop) */
.news-symbol-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.news-symbol-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.news-symbol-btn:hover {
    color: var(--text-primary);
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.news-symbol-btn.active {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    border-color: #667eea;
}

/* Hide mobile-only dropdown on desktop */
.news-mobile-only {
    display: none;
}

/* Multi-select event filter */
.news-multiselect-wrap {
    position: relative;
}

.news-multiselect-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    min-width: 140px;
    white-space: nowrap;
    transition: border-color 0.2s;
}

.news-multiselect-btn:hover {
    border-color: #667eea;
}

.news-multiselect-btn span {
    flex: 1;
    text-align: left;
}

.news-multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 260px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    padding: 6px 0;
}

.news-multiselect-all {
    padding: 8px 14px;
    font-size: 0.88em;
    font-weight: 600;
    color: #667eea;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.news-multiselect-all:hover {
    background: rgba(102, 126, 234, 0.08);
}

.news-multiselect-groups {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.news-multiselect-group-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s;
    white-space: nowrap;
}

.news-multiselect-group-item:hover {
    border-color: #667eea;
    color: var(--text-primary);
}

.news-multiselect-group-item:has(input:checked) {
    background: rgba(102, 126, 234, 0.15);
    border-color: #667eea;
    color: #667eea;
}

.news-multiselect-group-item input[type="checkbox"] {
    accent-color: #667eea;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.news-multiselect-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.88em;
    color: var(--text-primary);
    transition: background 0.15s;
}

.news-multiselect-item:hover {
    background: rgba(102, 126, 234, 0.08);
}

.news-multiselect-item input[type="checkbox"] {
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.news-multiselect-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-filter-select {
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    min-width: 140px;
}

.news-filter-select option {
    background: #1e293b;
    color: var(--text-primary);
}

.news-filter-select:focus {
    outline: none;
    border-color: #667eea;
}

/* Event group table */
.news-impact-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.news-impact-table thead th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.news-impact-table thead th.right {
    text-align: right;
}

.news-impact-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.news-impact-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.news-impact-table tbody tr.news-group-row {
    cursor: pointer;
}

.news-impact-table tbody td {
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.9em;
    white-space: nowrap;
}

.news-impact-table tbody td.right {
    text-align: right;
}

.news-group-toggle {
    display: inline-block;
    width: 16px;
    font-size: 0.8em;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.news-group-toggle.expanded {
    transform: rotate(90deg);
}

.news-country-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
}

/* Expandable detail rows */
.news-detail-row {
    display: none;
}

.news-detail-row.visible {
    display: table-row;
}

.news-detail-row td {
    padding: 0 !important;
    background: var(--bg-secondary);
}

.news-detail-trades {
    padding: 8px 16px 16px 40px;
}

/* Detail sub-table */
.news-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.news-detail-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85em;
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.news-detail-table th.right {
    text-align: right;
}

.news-detail-table td {
    padding: 8px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    white-space: nowrap;
}

.news-detail-table td.right {
    text-align: right;
}

/* Positive/negative coloring */
.news-positive {
    color: #48bb78 !important;
}

.news-negative {
    color: #ef4444 !important;
}

/* No data placeholder */
.news-no-data {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.news-no-data h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.news-no-data p {
    max-width: 400px;
    margin: 0 auto;
}

/* Loading state */
.news-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.news-progress-bar {
    width: 300px;
    max-width: 80%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin: 16px auto 8px;
    overflow: hidden;
}

.news-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent, #6366f1);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.news-progress-text {
    font-size: 0.85em;
    color: var(--text-muted, #64748b);
    margin-top: 4px;
}

/* Time offset badge */
.news-time-offset {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

/* Light theme overrides */
body.light-theme .news-match-mode-btn {
    color: #64748b;
}

body.light-theme .news-match-mode-btn:hover {
    color: #1e293b;
    background: rgba(102, 126, 234, 0.08);
}

body.light-theme .news-match-mode-btn.active {
    background: #667eea;
    color: #ffffff;
}

body.light-theme .news-timeframe-btn {
    color: #64748b;
}

body.light-theme .news-timeframe-btn:hover {
    color: #1e293b;
    background: rgba(102, 126, 234, 0.08);
}

body.light-theme .news-timeframe-btn.active {
    background: #667eea;
    color: #ffffff;
}

body.light-theme .news-filter-select {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

body.light-theme .news-multiselect-btn {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

body.light-theme .news-multiselect-dropdown {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

body.light-theme .news-multiselect-item {
    color: #1e293b;
}

body.light-theme .news-multiselect-item:hover {
    background: rgba(102, 126, 234, 0.05);
}

body.light-theme .news-multiselect-group-item {
    border-color: #e2e8f0;
    color: #64748b;
}

body.light-theme .news-multiselect-group-item:hover {
    border-color: #667eea;
    color: #1e293b;
}

body.light-theme .news-multiselect-group-item:has(input:checked) {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
    color: #667eea;
}

body.light-theme .news-symbol-btn {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #64748b;
}

body.light-theme .news-symbol-btn:hover {
    color: #1e293b;
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

body.light-theme .news-symbol-btn.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-color: #667eea;
}

body.light-theme .news-range-label {
    color: #1e293b;
}

body.light-theme .news-range-item {
    color: #64748b;
}

body.light-theme .news-impact-table thead th {
    background: #f8fafc;
    color: #64748b;
    border-bottom-color: #e2e8f0;
}

body.light-theme .news-impact-table tbody tr {
    border-bottom-color: #e2e8f0;
}

body.light-theme .news-detail-row td {
    background: #f8fafc;
}

body.light-theme .news-detail-table th {
    border-bottom-color: #e2e8f0;
}

body.light-theme .news-detail-table td {
    border-bottom-color: rgba(226, 232, 240, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .news-data-range {
        flex-direction: column;
        gap: 8px;
    }

    .news-range-item {
        flex-wrap: wrap;
        gap: 6px;
    }

    .news-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .news-symbol-bar {
        display: none;
    }

    .news-mobile-only {
        display: block;
    }

    .news-timeframe-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .news-timeframe-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .news-impact-table {
        font-size: 0.85em;
    }

    .news-impact-table thead th,
    .news-impact-table tbody td {
        padding: 8px 10px;
    }

    .news-detail-trades {
        padding: 8px 8px 12px 16px;
        overflow-x: auto;
    }

    .news-detail-table {
        min-width: 600px;
    }
}
