/* Global variables */
:root {
    --party-opacity: 0.15;  /* Basis-Transparenz, leicht zu ändern */
}

.stats-bar {
    background-color: #0d6efd;
    height: 25px;
    transition: width 0.5s ease-in-out;
    border-radius: 4px;
}

.stats-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-count {
    min-width: 50px;
    text-align: right;
}

/* Sticky header styles */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem 0;
}

/* Add padding to main content to prevent it from appearing under the sticky header */
.main-content {
    padding-top: 1rem;
}

/* Active button state */
.nav-btn.active {
    background-color: #0d6efd !important;
    color: white !important;
}

/* Posts count bar styles */
.posts-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.posts-bar {
    flex-grow: 1;
    background-color: #f8f9fa;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.posts-bar.recent-posts .posts-bar-fill {
    background-color: #198754;  /* Bootstrap success color */
}

.posts-bar.total-posts .posts-bar-fill {
    background-color: #0d6efd;  /* Bootstrap primary color */
}

.posts-bar-fill {
    height: 100%;
    transition: width 0.5s ease-in-out;
}

.recent-posts-count, .total-posts-count {
    font-size: 0.9em;
    color: #6c757d;
    white-space: nowrap;
    min-width: 80px;
}

.loading {
    opacity: 0.6;
    position: relative;
}

.loading::after {
    content: "Lade...";
    font-size: 0.8em;
    color: #6c757d;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Party background colors */
tr.party-spd > td { background-color: rgba(255, 0, 0, calc(var(--party-opacity) * 0.7)) !important; } /* Helleres Rot für SPD */
tr.party-cdu > td { background-color: rgba(0, 0, 0, calc(var(--party-opacity) * 0.75)) !important; }
tr.party-csu > td { background-color: rgba(0, 0, 0, calc(var(--party-opacity) * 0.75)) !important; }
tr.party-gruene > td { background-color: rgba(67, 176, 42, var(--party-opacity)) !important; }
tr.party-fdp > td { background-color: rgba(255, 237, 0, calc(var(--party-opacity) * 1.25)) !important; }
tr.party-linke > td { background-color: rgba(178, 0, 178, calc(var(--party-opacity) * 1.3)) !important; } /* Lila für Linke */
tr.party-piraten > td { background-color: rgba(255, 165, 0, var(--party-opacity)) !important; }
tr.party-afd > td { background-color: rgba(0, 158, 224, var(--party-opacity)) !important; }
tr.party-freie-waehler > td { background-color: rgba(0, 0, 139, var(--party-opacity)) !important; }
tr.party-volt > td { background-color: rgba(128, 0, 128, var(--party-opacity)) !important; }
tr.party-die-partei > td { background-color: rgba(0, 255, 255, var(--party-opacity)) !important; }
tr.party-none > td { background-color: rgba(0, 0, 0, calc(var(--party-opacity) * 0.25)) !important; }

/* Override Bootstrap hover effects */
.table > tbody > tr:hover > td {
    background-color: inherit !important;
}

/* Bot styles */
tr.is-bot {
    opacity: 0.5;
}

tr.is-bot:hover {
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

/* Party distribution styles */
.party-distribution-bar {
    height: 30px;
    width: 100%;
    background: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
}

.party-distribution-bar .party-segment {
    height: 100%;
    transition: all 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    flex-grow: 0;
    cursor: pointer;
    position: relative;
}

.party-segment:hover {
    opacity: 0.8;
}

.party-segment.active {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    z-index: 1;
}

.party-segment .regular-accounts {
    width: 100%;
    transition: all 0.3s ease-in-out;
}

.party-segment .bot-accounts {
    width: 100%;
    transition: all 0.3s ease-in-out;
    background-color: inherit;
    position: relative;
}

.party-segment .bot-accounts::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
}

.party-distribution-legend {
    font-size: 0.85em;
    color: #666;
}

.party-distribution-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.party-distribution-legend .color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.party-distribution-legend .color-box .bot-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: inherit;
}

.party-distribution-legend .color-box .bot-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
}

/* Reset Filter Button */
#resetFilter {
    font-size: 0.85em;
    color: #666;
    text-decoration: none;
    display: none;
    align-items: center;
    gap: 0.35rem;
}

#resetFilter:hover {
    color: #0d6efd;
}

#resetFilter.visible {
    display: inline-flex;
}

/* Timeline styles */
.timeline-container {
    margin-top: 1rem;
    margin-bottom: 35px;  /* Space for year scale only */
}

.timeline-bar {
    position: relative;
    width: 100%;
    background-color: #f8f9fa;
    border-radius: 4px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    padding: 2px;
}

.timeline-party-row {
    position: relative;
    height: 20px;  /* Height for multi-party view */
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 2px;
    margin: 1px 0;
}

/* When only one party is shown, adjust the row height */
.timeline-bar.filtered .timeline-party-row {
    height: 100%;  /* Full height when filtered */
    margin: 0;
}

.timeline-marker {
    position: absolute;
    width: 6px;  /* Default width for squares */
    height: 6px;  /* Default height for squares */
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.8;
    transition: all 0.2s ease-in-out;
    pointer-events: all;
    cursor: help;
    border-radius: 0;  /* Perfect squares */
    z-index: 2;
}

/* Adjust markers when filtered */
.timeline-bar.filtered .timeline-marker {
    width: 3px;  /* Thinner width for lines */
    height: 100%;  /* Full height */
    top: 0;
    transform: translateX(-50%);  /* Only center horizontally */
}

.timeline-marker:hover {
    opacity: 1;
    width: 10px;
    height: 10px;
    z-index: 10;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* Adjust hover state when filtered */
.timeline-bar.filtered .timeline-marker:hover {
    width: 5px;  /* Slightly wider on hover */
    height: 100%;  /* Maintain full height */
}

.timeline-marker.is-bot {
    opacity: 0.4;
    width: 4px;
    height: 4px;
}

/* Adjust bot markers when filtered */
.timeline-bar.filtered .timeline-marker.is-bot {
    width: 2px;  /* Thinner width for bot lines */
    height: 100%;  /* Full height */
    opacity: 0.3;
}

.timeline-marker.is-bot:hover {
    opacity: 0.6;
    width: 8px;
    height: 8px;
}

/* Adjust bot marker hover state when filtered */
.timeline-bar.filtered .timeline-marker.is-bot:hover {
    width: 4px;  /* Slightly wider on hover */
    height: 100%;  /* Maintain full height */
}

/* Grid lines - REMOVED */
/* .timeline-party-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent calc(20% - 1px),
        rgba(0, 0, 0, 0.1) 20%,
        transparent calc(20% + 1px)
    );
    pointer-events: none;
    z-index: 1;
} */

/* Year scale */
.timeline-scale {
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
    height: 20px;
}

.timeline-year {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.8em;
    color: #666;
}

.timeline-year::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    height: 5px;
    width: 2px;
    background-color: rgba(0, 0, 0, 0.3);
}

/* Month markers */
.timeline-months {
    position: absolute;
    bottom: -15px;
    left: 0;
    right: 0;
    height: 10px;
}

.timeline-month {
    position: absolute;
    width: 1px;
    height: 3px;
    background-color: rgba(0, 0, 0, 0.15);
    transform: translateX(-50%);
}

/* Search styles */
.input-group .form-control.rounded-pill {
    padding-right: 2.5rem !important;
}

.input-group .btn-link {
    color: #adb5bd;
}

.input-group .btn-link:hover {
    color: #6c757d;
}

/* Mobile navigation styles */
@media screen and (max-width: 896px) {
    .sticky-header {
        padding: 0.5rem 0 !important;
    }
    
    .sticky-header h1 {
        font-size: 1.25rem !important;
    }
    
    .btn-group .nav-btn {
        padding: 0.5rem !important;
        aspect-ratio: 1 !important;
        width: 40px !important;
    }
    
    .btn-group .nav-btn i {
        font-size: 1.2rem !important;
        margin: 0 !important;
    }

    .btn-group .nav-btn .loading-text {
        position: absolute !important;
        bottom: -20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        white-space: nowrap !important;
        font-size: 0.75rem !important;
    }

    /* Hide export button on mobile */
    .btn-group #exportButton {
        display: none !important;
    }

    /* Mobile account header adjustments */
    #accountsContainer .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    #accountsContainer .card-header h2 {
        font-size: 0.9rem !important;
        margin-bottom: 0 !important;
    }

    #accountsContainer .card-header .input-group {
        width: 100% !important;
        max-width: none !important;
    }

    /* Optimize container and table layout for mobile */
    .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        max-width: 100% !important;
    }

    .card {
        border-left: none !important;
        border-right: none !important;
        border-radius: 0 !important;
    }

    .table-responsive {
        margin: 0 -0.5rem !important;
    }

    /* Optimize table cell spacing */
    .table td {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.85rem !important;
    }

    /* Hide icon column on mobile */
    .table th:first-child,
    .table td:first-child {
        display: none !important;
    }

    /* Adjust account column */
    .table td:nth-child(2) {
        padding-left: 0.5rem !important;
        max-width: 180px !important;
    }

    /* Make party column more compact */
    #accountsTableBody td:nth-child(3) {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
    }

    /* Optimize posts bar container */
    .posts-bar-container {
        min-width: 70px !important;
        gap: 4px !important;
        padding-right: 0.5rem !important;
    }

    .posts-bar {
        height: 6px !important;
    }

    .recent-posts-count, .total-posts-count {
        font-size: 0.75rem !important;
        min-width: 35px !important;
    }

    /* Ensure the button group doesn't wrap */
    .sticky-header .d-flex {
        flex-wrap: nowrap !important;
    }

    footer {
        font-size: 0.7rem !important;
        padding: 0.75rem;
        white-space: nowrap;
    }

    /* Reduce size of party distribution heading */
    .card-header h2 {
        font-size: 1rem !important;
    }
}

/* Additional breakpoint for very small devices */
@media screen and (max-width: 390px) {
    .container {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    .table td {
        padding: 0.4rem 0.2rem !important;
        font-size: 0.8rem !important;
    }

    .posts-bar-container {
        min-width: 60px !important;
        padding-right: 0.25rem !important;
    }

    footer {
        font-size: 0.65rem !important;
        padding: 0.5rem;
    }

    /* Make party distribution heading even smaller on very small devices */
    .card-header h2 {
        font-size: 0.9rem !important;
    }
}

/* Tooltip enhancements for touch devices */
@media (min-width: 768px) {
    .tooltip {
        display: none !important;
    }
}

footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: #6c757d;
}

footer a {
    color: #0d6efd;
    text-decoration: none;
}

footer a:hover {
    color: #0a58ca;
    text-decoration: underline;
}

footer.fixed-bottom {
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    z-index: 1030;
    text-align: center;
    padding: 0.75rem;
}

footer.fixed-bottom a {
    color: #0d6efd !important;
    text-decoration: none;
}

footer.fixed-bottom a:hover {
    color: #0a58ca !important;
    text-decoration: underline;
}

@media screen and (max-width: 896px) {
    footer.fixed-bottom {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
}

@media screen and (max-width: 390px) {
    footer.fixed-bottom {
        font-size: 0.65rem;
        padding: 0.4rem;
    }
}

.posts-col {
    width: 100px;  /* Increased from 90px */
    white-space: nowrap;
}

.fedipol-brand { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; flex-shrink: 0; }
.header-controls { display: flex; align-items: center; gap: 0.5rem; }
.language-switch { width: auto; min-width: 4.4rem; font-size: 0.875rem; padding-left: 0.5rem; }
html[lang="en"] .brand-country::after { content: " Germany"; }
html[lang="en"] .loading::after { content: "Loading..."; }
@media (max-width: 1199px) {
    .brand-country { display: none; }
}
@media (max-width: 575px) {
    .sticky-header .container { padding-left: 0.5rem; padding-right: 0.5rem; }
    .fedipol-brand { font-size: 1.15rem; gap: 0.25rem; }
    .header-controls { gap: 0.25rem; }
    .header-controls .btn { padding-left: 0.35rem; padding-right: 0.35rem; }
    .header-controls .language-switch { min-width: 3.6rem; width: 3.8rem; padding-right: 1.4rem; }
    .info-header { flex-wrap: wrap; gap: 0.75rem; }
    #accountsContainer .card-header { flex-wrap: wrap; gap: 0.5rem; }
    .main-content > .card > .card-header { flex-wrap: wrap; gap: 0.5rem; }
}
.fedipol-brand-icon { width: 1.35em; height: 1.35em; flex: none; color: #0d6efd; }

/* Account actions: stable trailing column; room for a future second action. */
.account-table td { vertical-align: middle; }
.account-table .account-identity { min-width: 13rem; overflow-wrap: anywhere; }
.account-table .account-party { overflow-wrap: anywhere; }
.account-actions-header { width: 1%; text-align: right; white-space: nowrap; }
.account-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; flex-wrap: nowrap; }
.account-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 36px;
    padding: 0.45rem 0.7rem;
    border: 1px solid #cbd2da;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.85);
    color: #344054;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.account-action:hover { color: #182230; background: #fff; border-color: #667085; box-shadow: 0 2px 5px #10182812; }
.account-action:focus-visible { outline: 3px solid #0d6efd; outline-offset: 3px; }
.action-external { font-size: 0.65rem; color: #667085; }
.action-label-mobile, .posts-count-label { display: none; }
@media (pointer: coarse) { .account-action { min-height: 44px; } }

/* „Folgen“-Button (button-Element) erbt .account-action-Styling */
.account-action.follow-action {
    font-family: inherit;
    cursor: pointer;
}
.account-action.is-pending {
    opacity: 0.6;
    pointer-events: none;
}
#followStatus:not(:empty) {
    position: fixed;
    right: 1rem;
    bottom: 3rem;
    z-index: 1050;
    max-width: min(30rem, calc(100vw - 2rem));
    padding: 0.8rem 1rem;
    background: #fff;
    border: 1px solid #cbd2da;
    border-radius: 0.65rem;
    box-shadow: 0 4px 18px #10182825;
}
.account-action.is-following { color: #146c43; border-color: #a3cfbb; background: #e9f6ef; }
.account-action.is-requested { color: #664d03; border-color: #ffe69c; background: #fff8e1; }
.account-action:disabled { cursor: default; }
.follow-return-highlight { outline: 3px solid #0d6efd; outline-offset: -3px; }

@media screen and (max-width: 896px) {
    #accountsContainer .table-responsive { margin: 0 !important; overflow: visible; }
    #accountsContainer .account-table { display: block; width: 100%; }
    #accountsContainer .account-table thead { display: block; margin-bottom: 0.75rem; }
    #accountsContainer .account-table thead tr { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
    #accountsContainer .account-table thead th { display: none; }
    #accountsContainer .account-table thead .start-date-header,
    #accountsContainer .account-table thead .posts-header { display: block; padding: 0; border: 0; font-size: 0.8rem; }
    #accountsContainer .account-table thead .posts-header > div > span { display: none; }
    #accountsTableBody { display: block; }
    #accountsTableBody tr {
        display: grid;
        grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "platform identity identity" "party party date" "posts posts posts" "actions actions actions";
        margin-bottom: 0.75rem;
        border: 1px solid #dce1e7;
        border-radius: 0.9rem;
        overflow: hidden;
    }
    #accountsContainer #accountsTableBody tr > td {
        display: block !important;
        min-width: 0;
        max-width: none !important;
        padding: 0.65rem 0.8rem !important;
        border: 0;
        white-space: normal !important;
    }
    #accountsTableBody .account-platform { grid-area: platform; }
    #accountsContainer #accountsTableBody .account-platform { padding-right: 0 !important; }
    #accountsTableBody .account-identity { grid-area: identity; }
    #accountsTableBody .account-identity > div:first-child { font-weight: 600; font-size: 1rem; }
    #accountsTableBody .account-party { grid-area: party; }
    #accountsTableBody .account-start-date { grid-area: date; text-align: right; }
    #accountsTableBody .account-start-date::before { content: 'Seit '; color: #667085; font-size: 0.75rem; }
    html[lang="en"] #accountsTableBody .account-start-date::before { content: 'Joined '; }
    #accountsTableBody .account-posts { grid-area: posts; }
    #accountsTableBody .posts-bar-container { min-width: 0 !important; gap: 0.75rem !important; padding-right: 0 !important; }
    #accountsTableBody .account-post-count { display: flex; gap: 0.5rem; justify-content: space-between; align-items: center; }
    #accountsTableBody .posts-count-label { display: inline; color: #475467; font-size: 0.7rem; }
    #accountsTableBody .recent-posts-count, #accountsTableBody .total-posts-count { text-align: right; }
    #accountsContainer #accountsTableBody .account-actions-cell { grid-area: actions; border-top: 1px solid #10182815; }
    #accountsTableBody .account-actions { justify-content: flex-start; }
    #accountsTableBody .account-action { min-height: 44px; flex: 1 1 auto; }
    #accountsTableBody .action-label-desktop { display: none; }
    #accountsTableBody .action-label-mobile { display: inline; }
    #accountsTableBody .account-actions-cell:has(.account-actions:empty) { display: none !important; }
}
