/* Tweets Dashboard Styles */

.tweets-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    padding-top: 60px; /* Space for language switcher */
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

/* LTR Support for English */
html[dir="ltr"] .tweets-dashboard {
    direction: ltr;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid #e8ecef;
    margin-bottom: 20px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 28px;
}

.header-title h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1a1a2e;
}

.header-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.update-badge {
    background: #f0f4f8;
    color: #5a6c7d;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
}

.count-badge {
    background: #1da1f2;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* Stats Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e8ecef;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1da1f2;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: #5a6c7d;
    font-weight: 500;
}

/* Filter Bar */
.filter-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e8ecef;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 14px;
}

.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
    border: 1px solid transparent;
    font-size: 13px;
}

.radio-item:hover {
    background: #e8f4fd;
}

.radio-item:has(input:checked) {
    background: #1da1f2;
    color: white;
}

.radio-item input {
    display: none;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 8px;
    background: #f8f9fa;
    transition: all 0.2s;
    font-size: 13px;
}

.checkbox-item:hover {
    background: #e8f4fd;
}

.checkbox-item:has(input:checked) {
    background: #28a745;
    color: white;
}

.checkbox-item.hide-visited-item:has(input:checked) {
    background: #c53b60;
    color: white;
}

.checkbox-item input {
    display: none;
}

.refresh-btn {
    background: #f8f9fa;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #e8f4fd;
}

.refresh-btn.spinning .refresh-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.refresh-icon {
    display: inline-block;
    font-size: 16px;
}

/* Hints Section */
.hints-section {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding: 12px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e8ecef;
    flex-wrap: wrap;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #5a6c7d;
}

.hint-icon {
    font-size: 16px;
}

.hint-text {
    line-height: 1.5;
}

.hint-text strong {
    color: #1a1a2e;
}

.hint-pink {
    background: #fff0f3;
    padding: 2px 8px;
    border-radius: 4px;
    color: #c53b60;
    font-weight: 500;
}

/* Legend Section */
.legend-section {
    margin-bottom: 16px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
    border-radius: 10px;
    border: 1px solid #ffd6d6;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.legend-title {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 14px;
    flex-shrink: 0;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #5a6c7d;
}

.legend-badge {
    flex-shrink: 0;
}

.legend-text {
    line-height: 1.4;
}

/* Tag Filter Clickable Styles */
.tag-filter {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.tag-filter:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
}

.tag-filter.active {
    background: rgba(220, 53, 69, 0.15);
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.25);
}

.tag-filter.active .filter-badge {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.5);
}

.tag-filter .legend-text {
    font-size: 11px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tag-filter:hover .legend-text {
    opacity: 1;
}

.tag-filter.active .legend-text {
    opacity: 1;
    font-weight: 600;
    color: #dc3545;
}

.filter-badge {
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Clear Filters Button */
.clear-filters-btn {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: auto;
}

html[dir="ltr"] .clear-filters-btn {
    margin-right: 0;
    margin-left: auto;
}

.clear-filters-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

/* Show/hide hints based on screen size */
.hints-mobile {
    display: none;
}

.hints-desktop {
    display: flex;
}

/* Table Container */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e8ecef;
    margin-bottom: 20px;
}

.tweets-table {
    width: 100%;
    border-collapse: collapse;
    direction: ltr;
}

.tweets-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #1da1f2;
}

.tweets-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #1a1a2e;
    font-size: 14px;
    white-space: nowrap;
}

.tweets-table tbody tr {
    border-bottom: 1px solid #e8ecef;
    transition: background 0.2s;
    cursor: pointer;
}

.tweets-table tbody tr:hover {
    background: #f8fbfd;
}

.tweets-table tbody tr.visited {
    background: #fff0f3;
}

.tweets-table tbody tr.visited:hover {
    background: #ffe4e9;
}

.tweets-table td {
    padding: 14px 16px;
    vertical-align: top;
    font-size: 14px;
    color: #2d3748;
}

/* Column Widths */
.col-author { width: 140px; }
.col-content { width: auto; }
.col-iran { width: 50px; text-align: center !important; }
.col-replies { width: 80px; text-align: center !important; }
.col-likes { width: 80px; text-align: center !important; }
.col-views { width: 100px; text-align: center !important; }
.col-importance { width: 100px; text-align: center !important; }

/* Content Cell */
.tweet-content {
    line-height: 1.6;
    word-break: break-word;
    max-height: 100px;
    overflow: hidden;
}

.tweet-content.persian {
    direction: rtl;
    text-align: right;
}

.tweet-content.english {
    direction: ltr;
    text-align: left;
}

/* Author Cell */
.author-name {
    font-weight: 500;
    color: #1a1a2e;
}

/* Supporter Labels */
.author-support-labels {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.supporter-badge {
    display: inline-block;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(220, 53, 69, 0.3);
}

/* Numeric Cells */
.num-cell {
    font-family: 'Consolas', monospace;
    font-weight: 500;
    text-align: center;
}

.iran-count {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.iran-count.highlight {
    background: #ffc107;
    color: #1a1a2e;
}

/* Loading */
.loading-row td {
    text-align: center;
    padding: 60px !important;
    color: #5a6c7d;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e8ecef;
    border-top-color: #1da1f2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

/* Empty State */
.empty-row td {
    text-align: center;
    padding: 60px !important;
    color: #5a6c7d;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.page-btn {
    background: white;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: #1a1a2e;
}

.page-btn:hover:not(:disabled) {
    background: #1da1f2;
    color: white;
    border-color: #1da1f2;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    color: #5a6c7d;
}

/* Row Link Effect */
.tweet-row {
    position: relative;
}

.tweet-row::after {
    content: '🔗';
    position: absolute;
    left: 16px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
}

html[dir="rtl"] .tweet-row::after {
    left: auto;
    right: 16px;
}

.tweet-row:hover::after {
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .tweets-dashboard {
        padding: 10px;
        padding-top: 60px;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 16px 0;
    }

    .header-title h1 {
        font-size: 18px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .radio-group {
        justify-content: center;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .radio-item {
        padding: 10px 8px;
        font-size: 12px;
        justify-content: center;
    }

    .filter-actions {
        justify-content: center;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 11px;
    }

    .hints-section {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .hint-item {
        font-size: 12px;
    }

    /* Show mobile hints, hide desktop hints */
    .hints-mobile {
        display: flex !important;
    }

    .hints-desktop {
        display: none !important;
    }

    /* Legend responsive */
    .legend-section {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .legend-title {
        font-size: 13px;
    }

    .legend-items {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .legend-item {
        font-size: 12px;
    }

    /* Tag filter mobile styles */
    .tag-filter {
        padding: 10px;
        width: 100%;
    }

    .clear-filters-btn {
        width: 100%;
        margin-top: 10px;
        padding: 12px;
    }

    /* Hide table on mobile */
    .table-container {
        display: none;
    }

    /* Show cards on mobile */
    .cards-container {
        display: flex !important;
    }
}

/* ============================================
   MOBILE CARD LAYOUT
   ============================================ */

.cards-container {
    display: none;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.tweet-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecef;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.tweet-card:active {
    transform: scale(0.98);
}

.tweet-card.visited {
    background: linear-gradient(135deg, #fff0f3 0%, #fff5f7 100%);
    border-color: #ffccd5;
}

.tweet-card.visited::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, transparent 50%, #ffb3c1 50%);
}

html[dir="ltr"] .tweet-card.visited::before {
    right: auto;
    left: 0;
    background: linear-gradient(225deg, transparent 50%, #ffb3c1 50%);
}

/* Card Header - Author */
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f2f5;
}

.card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1da1f2 0%, #0d8bd9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.card-author-info {
    flex: 1;
    min-width: 0;
}

.card-author-name {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 15px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-author-name.persian {
    direction: rtl;
    text-align: right;
}

/* Card Support Labels (Mobile) */
.card-support-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.card-support-labels .supporter-badge {
    font-size: 10px;
    padding: 2px 6px;
}

.card-timestamp {
    font-size: 12px;
    color: #8899a6;
    margin-top: 2px;
}

.card-importance-badge {
    background: linear-gradient(135deg, #1da1f2 0%, #0d8bd9 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Card Content */
.card-content {
    margin-bottom: 16px;
    line-height: 1.7;
    font-size: 15px;
    color: #2d3748;
    word-break: break-word;
    max-height: 150px;
    overflow: hidden;
    position: relative;
}

.card-content.persian {
    direction: rtl;
    text-align: right;
}

.card-content.english {
    direction: ltr;
    text-align: left;
}

.card-content.truncated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, white);
}

.tweet-card.visited .card-content.truncated::after {
    background: linear-gradient(transparent, #fff5f7);
}

/* Card Stats Grid */
.card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.card-stat {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    transition: background 0.2s;
}

.card-stat:hover {
    background: #e8f4fd;
}

.card-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    display: block;
    font-family: 'Consolas', monospace;
}

.card-stat-label {
    font-size: 10px;
    color: #8899a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.card-stat.iran-stat {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
}

.card-stat.iran-stat .card-stat-value {
    color: #856404;
}

.card-stat.iran-stat.highlight {
    background: linear-gradient(135deg, #ffc107 0%, #ffca2c 100%);
}

.card-stat.iran-stat.highlight .card-stat-value {
    color: #1a1a2e;
}

/* Card Footer */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid #f0f2f5;
}

.card-tap-hint {
    font-size: 12px;
    color: #8899a6;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-external-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.tweet-card:active .card-external-icon {
    background: #1da1f2;
}

/* Mobile Loading State */
.cards-container .loading-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecef;
}

.cards-container .empty-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecef;
    color: #5a6c7d;
}

/* Desktop: Show table, hide cards */
@media (min-width: 769px) {
    .table-container {
        display: block;
    }

    .cards-container {
        display: none !important;
    }
}

/* Scrollbar Styling */
.table-container {
    overflow-y: auto;
}

.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c9d0;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8b2bc;
}

/* Sticky Header */
.tweets-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
