/**
 * Table View Styles for Browse Page
 * Dark theme responsive table layout with votable columns
 */

/* View Toggle Buttons */
.view-toggle {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.view-toggle .btn {
    padding: 0.5rem 1rem;
    border: 1px solid #1a3a5c;
    background: #0f2d4d;
    color: white;
    transition: all 0.2s;
}

.view-toggle .btn:hover {
    background: rgba(251, 117, 0, 0.15);
    border-color: #fb7500;
}

.view-toggle .btn.active {
    background: #fb7500;
    color: white;
    border-color: #fb7500;
}

/* Table View Container */
.table-view-container {
    overflow-x: auto;
    background: #0a2240;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #1a3a5c;
}

/* Channel Table */
.channels-table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: white;
}

.channels-table th {
    background: #0f2d4d;
    border-bottom: 2px solid #1a3a5c;
    padding: 0.75rem 0.5rem;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    color: white;
}

.channels-table td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #1a3a5c;
    color: white;
}

.channels-table tbody tr {
    background: #0a2240;
    transition: background 0.2s ease;
}

.channels-table tbody tr:hover {
    background: rgba(251, 117, 0, 0.1);
}

/* Channel Name Column */
.channel-name-cell {
    min-width: 200px;
    max-width: 300px;
}

.channel-name-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.channel-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.25rem;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #1a3a5c;
}

.channel-title {
    font-weight: 500;
    color: white;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.channel-title:hover {
    color: #fb7500;
    text-decoration: underline;
}

/* Votable Score Cells */
.votable-score {
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    position: relative;
    display: inline-block;
}

.votable-score:hover {
    transform: scale(1.05);
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.3);
}

.votable-score.score-excellent { 
    background: rgba(25, 135, 84, 0.3);
    color: #75c794;
    border: 1px solid #198754;
}

.votable-score.score-good { 
    background: rgba(32, 201, 151, 0.3);
    color: #66d9b8;
    border: 1px solid #20c997;
}

.votable-score.score-fair { 
    background: rgba(255, 193, 7, 0.3);
    color: #ffd454;
    border: 1px solid #ffc107;
}

.votable-score.score-poor { 
    background: rgba(220, 53, 69, 0.3);
    color: #ff6b7a;
    border: 1px solid #dc3545;
}

/* Stimulation-specific scores (inverted: high stim = bad = red) */
.votable-score.stim-excellent { 
    background: rgba(25, 135, 84, 0.3);
    color: #75c794;
    border: 1px solid #198754;
}

.votable-score.stim-good { 
    background: rgba(255, 193, 7, 0.3);
    color: #ffd454;
    border: 1px solid #ffc107;
}

.votable-score.stim-fair { 
    background: rgba(253, 126, 20, 0.3);
    color: #ff9f52;
    border: 1px solid #fd7e14;
}

.votable-score.stim-poor { 
    background: rgba(139, 0, 0, 0.4);
    color: #ff6b6b;
    border: 1px solid #8b0000;
}

.votable-score:hover::after {
    content: 'Click to vote';
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: #0f2d4d;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    font-weight: normal;
    z-index: 1000;
    border: 1px solid #1a3a5c;
}

/* Vote Count Tooltip */
.vote-count {
    font-size: 0.7rem;
    opacity: 0.7;
    display: block;
    margin-top: 0.125rem;
}

/* Age Range Column */
.age-range {
    white-space: nowrap;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Content Type Column */
.content-type {
    white-space: nowrap;
    font-size: 0.875rem;
}

.content-type .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Boolean Icon Columns (Musical, Animated, Institutional) */
.channels-table td.text-center {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
}

/* Subscribers Column */
.subscribers {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.8);
}

/* Action Buttons Column */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    flex-wrap: nowrap;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    border: none;
}

.btn-recommend {
    background: #198754;
    color: white;
}

.btn-recommend:hover {
    background: #157347;
}

.btn-avoid {
    background: #dc3545;
    color: white;
}

.btn-avoid:hover {
    background: #bb2d3b;
}

.btn-list {
    background: #0d6efd;
    color: white;
}

.btn-list:hover {
    background: #0b5ed7;
}

/* Responsive: Force card view on small screens */
@media (max-width: 991px) {
    .table-view-container {
        display: none !important;
    }
    
    .view-toggle .btn[data-view="table"] {
        display: none;
    }
}

/* Loading State */
.table-loading {
    text-align: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.6);
}

.table-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-color: #fb7500;
    border-right-color: transparent;
}

/* Empty State */
.table-empty {
    text-align: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Sticky Column for Channel Names */
.channels-table th:first-child,
.channels-table td:first-child {
    position: sticky;
    left: 0;
    background: #0a2240;
    z-index: 5;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.2);
}

.channels-table th:first-child {
    z-index: 15;
    background: #0f2d4d;
}

.channels-table tbody tr:hover td:first-child {
    background: rgba(251, 117, 0, 0.1);
}

/* Sort Indicators */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.sortable:hover {
    background: rgba(251, 117, 0, 0.15);
}

.sortable::after {
    content: '⇅';
    margin-left: 0.5rem;
    opacity: 0.5;
    color: rgba(255, 255, 255, 0.5);
}

.sortable.sorted-asc::after {
    content: '↑';
    opacity: 1;
    color: #fb7500;
}

.sortable.sorted-desc::after {
    content: '↓';
    opacity: 1;
    color: #fb7500;
}

/* Horizontal scroll indicator */
.table-view-container::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(10, 34, 64, 0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.table-view-container.has-scroll::after {
    opacity: 1;
}
