.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-widget {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    position: relative; 
    z-index: 10; /* Livello base per tutti i widget */
}

/* --- FIX FONDAMENTALE --- */
/* Diamo al widget "Country" un livello più alto degli altri widget (come lo sponsor) */
/* In questo modo il menu a tendina potrà sovrapporsi agli elementi sottostanti */
.country-widget {
    z-index: 50; 
}

.sidebar-widget h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-widget input {
    width: 100%;
    padding: 10px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.reset-filter {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: underline;
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-item {
    padding: 10px 15px;
    background: #252525;
    border-radius: 4px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.filter-item:hover {
    background: #333;
    color: white;
}

.filter-item.active {
    background: #2a2a2a;
    color: white;
    border-left-color: var(--primary);
}

/* --- STILI DROPDOWN COUNTRY --- */

.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-btn {
    width: 100%;
    padding: 12px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.dropdown-btn:hover {
    background: #333;
}

.dropdown-content {
    display: none; 
    position: absolute; 
    top: 100%;
    left: 0;
    width: 100%;
    background: #252525;
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 1000; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    overflow: hidden;
    margin-top: 5px;
}

/* Stili per la barra di ricerca nel menu */
#countrySearchInput {
    outline: none;
    transition: border-color 0.2s;
}

#countrySearchInput:focus {
    border-color: var(--primary) !important;
}

/* Stili per i link dei paesi */
.country-link {
    display: block;
    padding: 10px 15px;
    color: #ccc;
    text-decoration: none;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.country-link:last-child {
    border-bottom: none;
}

.country-link:hover {
    background: #333;
    color: white;
    padding-left: 20px;
}

.country-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.list-header {
    display: grid;
    grid-template-columns: 60px 1fr 100px 120px;
    padding: 10px 20px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.server-row {
    display: grid;
    grid-template-columns: 60px 80px 1fr 100px 120px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    align-items: center;
    padding: 15px;
    transition: transform 0.2s, border-color 0.2s;
}

.server-row:hover {
    transform: translateY(-2px);
    border-color: #555;
}

.server-row.sponsored {
    border: 1px solid var(--gold);
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.05), var(--bg-card));
}

.rank-box {
    text-align: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: #555;
}

.trophy-1 { color: #ffd700; font-size: 1.5rem; }
.trophy-2 { color: #c0c0c0; font-size: 1.4rem; }
.trophy-3 { color: #cd7f32; font-size: 1.3rem; }

.server-icon img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.server-details {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.server-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.server-name-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.server-name-wrap h3 {
    font-size: 1.1rem;
    color: white;
    margin: 0;
}

.badge-sponsor {
    background: var(--gold);
    color: black;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
}

.server-ip-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-text {
    background: #2a2a2a;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    color: #ccc;
    font-size: 0.9rem;
}

.btn-copy-small {
    background: none;
    border: 1px solid #444;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-copy-small:hover {
    border-color: var(--primary);
    color: white;
}

.server-desc-row {
    color: #aaa;
    font-size: 0.9rem;
    line-height: 1.3;
}

.server-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.server-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.tag {
    background: #333;
    color: #aaa;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 3px;
}

.server-votes {
    text-align: center;
}

.vote-box {
    background: #2a2a2a;
    padding: 8px 15px;
    border-radius: 6px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    border: 1px solid #333;
    transition: border-color 0.2s;
}

.vote-box:hover {
    border-color: var(--primary);
}

.vote-box i {
    color: var(--accent);
    margin-bottom: 2px;
}

.vote-box span {
    font-weight: 700;
    color: white;
}

.server-players {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.player-count {
    color: #ccc;
    font-weight: 600;
}

.status-online {
    color: #4ade80;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-online::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.page-btn {
    background: #252525;
    border: 1px solid #444;
    color: #ccc;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.page-btn:hover {
    background: #333;
    color: white;
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mobile-controls {
    display: none;
    gap: 10px;
    margin-bottom: 15px;
}

.mobile-btn {
    flex: 1;
    background: #252525;
    border: 1px solid #444;
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-dropdown {
    display: none;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.mobile-dropdown form {
    display: flex;
    gap: 10px;
}

.mobile-dropdown input {
    flex: 1;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
}

.mobile-dropdown button {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
}

@media (max-width: 900px) {
    .sidebar { display: none; }
    .mobile-controls { display: flex; }
    .list-header { display: none; }
    
    .server-row {
        grid-template-columns: 60px 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
        padding: 15px;
        position: relative;
    }

    .server-icon { grid-column: 1; grid-row: 1; }
    .server-details { grid-column: 2; grid-row: 1; padding: 0; }
    .server-header-row { flex-direction: column; align-items: flex-start; gap: 5px; }
    .server-name-wrap h3 { font-size: 1.2rem; }
    .server-ip-wrap { width: 100%; margin-top: 5px; flex-wrap: wrap; }
    
    .ip-text { font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
    
    .server-desc-row { grid-column: 1 / -1; grid-row: 2; margin-top: 5px; }
    
    .server-desc {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .server-tags { margin-top: 10px; }

    .server-votes {
        grid-column: 1 / -1;
        grid-row: 3;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 15px;
        margin-top: 5px;
        border-top: 1px solid #333;
    }

    .vote-box { flex-direction: row; gap: 10px; padding: 6px 15px; min-width: auto; }
    .vote-box i { margin-bottom: 0; }
    .server-players { display: flex; flex-direction: row; align-items: center; gap: 15px; text-align: right; }
    .rank-box { position: absolute; top: 10px; right: 10px; font-size: 1rem; }
    .trophy-1, .trophy-2, .trophy-3 { font-size: 1.2rem; }
}

@media (max-width: 480px) {
    .server-row { grid-template-columns: 40px 1fr; padding: 8px; }
    .server-icon img { width: 40px; height: 40px; }
    .server-name-wrap h3 { font-size: 0.95rem; }
}