/* Table styles for Between The Lines */

.table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    position: relative; /* Ensure proper scrolling context */
}

/* Top scrollbar for desktop */
@media (min-width: 769px) {
    .table-container-wrapper {
        position: relative;
        margin: 20px 0;
    }
    
    .table-container-top-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        height: 30px;
        margin-bottom: -5px;
    }
    
    /* Make the scrollbar itself thicker */
    .table-container-top-scroll::-webkit-scrollbar {
        height: 14px;
    }
    
    .table-container-top-scroll::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 7px;
    }
    
    .table-container-top-scroll::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 7px;
    }
    
    .table-container-top-scroll::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
    
    .table-container-top-scroll-inner {
        height: 1px;
    }
    
    .table-container {
        margin-top: 0;
    }
}

.analysis-table {
    width: 100%;
    min-width: 1200px; /* Increase minimum width to prevent compression */
    border-collapse: separate;
    border-spacing: 0;
    margin: 0; /* Remove margin as container handles it */
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed; /* Add fixed table layout for better column control */
}

.analysis-table th {
    background: #2c3e50;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #34495e;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: normal; /* Allow text wrapping in headers */
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Remove hyphens to prevent word splitting with dashes */
}

.analysis-table td {
    padding: 12px 15px;
    border: 1px solid #dee2e6;
    vertical-align: top;
    line-height: 1.5;
    white-space: normal; /* Allow text wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Remove hyphens to prevent word splitting with dashes */
    height: auto !important; /* Prevent height restrictions */
    max-height: none !important; /* Remove max-height limitations */
}

.analysis-table tr:nth-child(even) {
    background: #f8f9fa;
}

.analysis-table tr:hover {
    background: #f2f2f2;
}

/* Sentiment/Source column styles */
.sentiment-cell {
    width: 200px; /* Increase width slightly */
    min-width: 200px;
    max-width: 200px;
    font-weight: 600;
    background-color: #f8f9fa;
    border-right: 2px solid #dee2e6 !important;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Remove hyphens to prevent word splitting with dashes */
}

/* Sentiment styles */
.sentiment-positive {
    background-color: #e8f5e8 !important;
    color: #2e7d32;
}

.sentiment-positive strong {
    color: #1b5e20;
}

.sentiment-negative {
    background-color: #ffebee !important;
    color: #c62828;
}

.sentiment-negative strong {
    color: #b71c1c;
}

.sentiment-neutral {
    background-color: #f5f5f5 !important;
    color: #424242;
}

.sentiment-neutral strong {
    color: #212121;
}

.sentiment-not-mentioned {
    background-color: #fafafa !important;
    color: #9e9e9e;
}

/* Claims styles */
.claim-yes {
    background-color: #e8f5e9 !important;
    color: #2e7d32;
}

.claim-yes strong {
    color: #1b5e20;
}

.claim-no {
    background-color: #ffebee !important;
    color: #c62828;
    font-weight: 500;
}

.claim-delno {
    background-color: #f3f8ff !important;
    color: #313b60;
    font-weight: normal;
}

/* Key Differences column in tables */
.analysis-table .key-differences {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    background-color: #fff3e0 !important; /* Orange background */
    color: #495057; /* Normal dark gray text color */
    font-size: 13px;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Remove hyphens to prevent word splitting with dashes */
    cursor: default !important; /* Make it clear this is not clickable */
    border-left: 2px solid #dee2e6 !important; /* Normal border like other columns */
    font-style: italic; /* Subtle styling to differentiate */
    padding: 12px 15px !important;
}

/* Remove hover effects from key differences */
.key-differences:hover {
    background-color: #fff3e0 !important; /* Keep same background on hover */
    cursor: default !important;
}

/* Table header */
.table-title {
    font-size: 1.5em;
    color: #2c3e50;
    margin: 1em 0 0.5em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid #eee;
}

/* Articles table */
.articles-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    margin: 0;
    font-size: 14px;
    background: white;
}

/* Mobile responsive articles table */
@media (max-width: 768px) {
    .articles-table {
        min-width: 100% !important; /* Remove fixed minimum width */
        font-size: 13px;
    }
    
    .articles-table th,
    .articles-table td {
        padding: 8px 6px !important;
        font-size: 13px;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Make source column narrower on mobile */
    .articles-table th:nth-child(1),
    .articles-table td:nth-child(1) {
        width: 25% !important;
        min-width: 80px !important;
        max-width: none !important;
    }
    
    /* Make title column flexible */
    .articles-table th:nth-child(2),
    .articles-table td:nth-child(2) {
        width: 65% !important;
        min-width: 0 !important;
    }
    
    /* Make link column compact */
    .articles-table th:nth-child(3),
    .articles-table td:nth-child(3) {
        width: 10% !important;
        min-width: 60px !important;
        max-width: none !important;
        text-align: center;
    }
    
    /* Smaller article links on mobile */
    .article-link {
        padding: 3px 8px !important;
        font-size: 11px !important;
        border-radius: 12px !important;
    }
}

@media (max-width: 480px) {
    .articles-table {
        font-size: 12px;
    }
    
    .articles-table th,
    .articles-table td {
        padding: 6px 4px !important;
        font-size: 12px;
        line-height: 1.3;
    }
    
    /* Even more compact on very small screens */
    .articles-table th:nth-child(1),
    .articles-table td:nth-child(1) {
        width: 30% !important;
        min-width: 70px !important;
    }
    
    .articles-table th:nth-child(2),
    .articles-table td:nth-child(2) {
        width: 55% !important;
    }
    
    .articles-table th:nth-child(3),
    .articles-table td:nth-child(3) {
        width: 15% !important;
        min-width: 50px !important;
    }
    
    .article-link {
        padding: 2px 6px !important;
        font-size: 10px !important;
    }
}

.articles-table th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: 600;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
}

.articles-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #dee2e6;
}

/* Articles table column widths */
.articles-table th:nth-child(1),
.articles-table td:nth-child(1) {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
}

.articles-table th:nth-child(2),
.articles-table td:nth-child(2) {
    width: auto;
    min-width: 400px;
}

.articles-table th:nth-child(3),
.articles-table td:nth-child(3) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    text-align: center;
}

.article-link {
    display: inline-block;
    padding: 5px 12px;
    background-color: #e9ecef;
    color: #495057;
    border-radius: 15px;
    text-decoration: none;
    font-size: 13px;
    transition: background-color 0.2s ease;
}

.article-link:hover {
    background-color: #dee2e6;
    text-decoration: none;
}

/* Source columns - increase width to accommodate content */
.analysis-table td:not(.sentiment-cell):not(.key-differences) {
    width: 280px; /* Increase from 270px */
    min-width: 280px;
    max-width: 280px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Remove hyphens to prevent word splitting with dashes */
}

/* Claims and sentiment analysis specific column widths on desktop */
@media (min-width: 769px) {
    .claims-table td:first-child,
    .claims-table th:first-child {
        width: 150px;
        min-width: 150px;
        max-width: 150px;
    }
    
    /* Key differences column (2nd column) for both tables */
    .claims-table td:nth-child(2),
    .claims-table th:nth-child(2),
    .sentiment-table td:nth-child(2),
    .sentiment-table th:nth-child(2) {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
    }
}

/* Mobile responsive table styles */
@media (max-width: 768px) {
    .table-container {
        margin: 15px 0;
        border-radius: 8px;
        position: relative;
        /* Add scroll indicator */
        background: linear-gradient(90deg, white 70%, rgba(255,255,255,0)),
                    linear-gradient(90deg, rgba(255,255,255,0), white 30%) 100% 0,
                    linear-gradient(90deg, rgba(0,0,0,.2), transparent 20px),
                    linear-gradient(270deg, rgba(0,0,0,.2), transparent 20px) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    .table-container::after {
        content: "← Scroll horizontally to see more →";
        position: absolute;
        bottom: -25px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px;
        color: #666;
        background: rgba(255,255,255,0.9);
        padding: 2px 8px;
        border-radius: 10px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0.8;
    }

    .analysis-table {
        min-width: 800px; /* Reduce minimum width for mobile */
        font-size: 13px;
    }
    
    .analysis-table th,
    .analysis-table td {
        padding: 10px 8px;
        font-size: 13px;
        line-height: 1.4;
    }
    
    .sentiment-cell {
        width: 150px;
        min-width: 150px;
        max-width: 150px;
        font-size: 12px;
    }
    
    /* Make content cells more readable on mobile */
    .analysis-table td:not(.sentiment-cell):not(.key-differences) {
        min-width: 120px;
        font-size: 12px;
        line-height: 1.3;
    }
    
    .analysis-table .key-differences {
        width: 200px;
        min-width: 200px;
        max-width: 200px;
        font-size: 11px;
    }

    .clickable {
        position: relative;
    }

    /* Adjust hover text for mobile */
    .clickable:hover::after {
        font-size: 10px;
        padding: 2px 6px;
    }

    /* Better scrollbar for mobile */
    .table-container::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .table-container::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }
    
    .table-container::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
}

@media (max-width: 480px) {
    .analysis-table {
        min-width: 600px; /* Further reduce for very small screens */
        font-size: 12px;
    }
    
    .analysis-table th,
    .analysis-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .sentiment-cell {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
        font-size: 11px;
    }

    .analysis-table td:not(.sentiment-cell):not(.key-differences) {
        min-width: 100px;
        font-size: 11px;
    }

    .analysis-table .key-differences {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
        font-size: 10px;
    }

    .table-title {
        font-size: 1.2em;
        margin: 0.8em 0 0.3em;
    }
}

/* Mobile Card Layout for Sentiment/Claims Tables */
.analysis-cards-container {
    display: none; /* Hidden by default, shown on mobile */
    padding: 0 5px;
}

.analysis-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    padding: 20px 15px 50px 15px; /* Extra bottom padding for expand button */
    border: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

/* Collapsed state */
.analysis-card.collapsed {
    max-height: 280px;
}

/* Gradient overlay for collapsed cards */
.analysis-card.collapsed::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent 0%, rgba(255,255,255,0.7) 40%, rgba(255,255,255,0.95) 70%, white 100%);
    pointer-events: none;
    z-index: 1;
}

/* Expand/Collapse button */
.card-expand-btn {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 5px 15px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-expand-btn:hover {
    background: #f5f5f5;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Arrow icon */
.card-expand-btn::after {
    content: '▼';
    font-size: 10px;
    margin-left: 3px;
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Rotate arrow when expanded */
.analysis-card:not(.collapsed) .card-expand-btn::after {
    transform: rotate(180deg);
}

/* Smooth height transition */
.analysis-card {
    transition: max-height 0.4s ease-out;
}

.analysis-card:not(.collapsed) {
    max-height: 2000px; /* Large enough for any content */
}

.analysis-card-header {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.analysis-card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-field {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.card-field:last-child {
    border-bottom: none;
}

.card-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-field-value {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    padding: 6px 10px;
    background: #f9f9f9;
    border-radius: 8px;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Special styling for Key Differences field */
.card-field-value.key-differences {
    background-color: #fff3e0 !important;
    font-style: italic;
    color: #333 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
}

/* Sentiment coloring in cards */
.card-field-value.sentiment-positive {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.card-field-value.sentiment-negative {
    background-color: #ffebee;
    color: #c62828;
}

.card-field-value.sentiment-neutral {
    background-color: #f5f5f5;
    color: #424242;
}

.card-field-value.sentiment-not-mentioned {
    background-color: #fafafa;
    color: #9e9e9e;
}

/* Claims coloring in cards */
.card-field-value.claim-yes {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.card-field-value.claim-no {
    background-color: #ffebee;
    color: #c62828;
    font-weight: 500;
}

.card-field-value.claim-delno {
    background-color: #f3f8ff;
    color: #48588d;
    font-weight: normal;
}

/* Clickable fields in cards */
.card-field-value.clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-field-value.clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Responsive switching between table and cards */
@media (max-width: 768px) {
    /* Hide table on mobile */
    .table-container.mobile-cards {
        display: none;
    }
    
    /* Show cards on mobile - extend width moderately */
    .analysis-cards-container {
        display: block;
        width: calc(100vw - 50px);
        margin-left: calc(-50vw + 50% + 25px);
        padding: 0;
        box-sizing: border-box;
    }
    
    /* Remove scroll hint when using cards */
    .table-container.mobile-cards::after {
        display: none;
    }
}

/* Keep table view for larger screens */
@media (min-width: 769px) {
    .analysis-cards-container {
        display: none !important;
    }
    
    .table-container {
        display: block !important;
    }
} 