/* --- SERVER CARD --- */
.server-row {
    display: grid;
    /* Desktop: Icona 220px | Contenuto flessibile | Azione stretta 60px */
    grid-template-columns: 220px 1fr 60px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    align-items: stretch;
    padding: 0;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 20px;
    position: relative;
    height: 150px; 
    overflow: visible; 
    z-index: 1;
    transform: translateZ(0);
    will-change: transform, box-shadow;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    animation: slideUpFade 0.6s ease-out forwards;
}

.server-row:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px -5px rgba(37, 99, 235, 0.15);
    z-index: 1000; /* Priorità massima all'hover per mostrare il tooltip sopra tutto */
}

#serverListContainer { transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out; }
.loading-fade { opacity: 0; transform: translateY(10px); }

/* --- RANK & ICONS --- */
.rank-box {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    color: var(--primary-glow);
    font-weight: 800;
    font-size: 1rem;
    padding: 6px 12px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
}

.server-icon {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: #000;
    display: block;
    position: relative;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    overflow: hidden;
}

.server-icon a {
    width: 100%;
    height: 100%;
    display: block;
}

.server-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.85;
    transition: transform 0.5s ease, opacity 0.3s;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    will-change: transform, opacity;
}

.server-row:hover .server-icon img {
    opacity: 1;
    transform: scale(1.08);
}

.server-icon::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80px;
    background: linear-gradient(to right, transparent, var(--bg-card));
    z-index: 2;
    pointer-events: none;
}

/* --- DETTAGLI SERVER --- */
.server-details {
    padding: 15px 20px 12px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    z-index: 3;
    overflow: visible; /* IMPORTANTE: permette al tooltip di uscire dal box */
    height: 100%;
    box-sizing: border-box;
}

.server-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 2px;
    width: 100%;
}

.server-name-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0; 
}

.server-name-wrap h3 {
    font-size: 1.5rem;
    margin: 0;
    line-height: 1.2;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.025em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.server-details p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #94a3b8;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.8em;
    margin-bottom: auto; 
}

/* --- STILI SPECIALI CARD E NOMI --- */

/* 1. Bordo Neon Blu (Solo per Rank #1) */
.server-row.rank-one-card {
    border: 1px solid #00b4d8 !important; /* Blu Hytale */
    box-shadow: 0 0 20px rgba(0, 180, 216, 0.25), inset 0 0 10px rgba(0, 180, 216, 0.05);
    position: relative;
    z-index: 2;
    transform: scale(1.01);
    transition: all 0.3s ease;
}
.server-row.rank-one-card:hover {
    box-shadow: 0 0 35px rgba(0, 180, 216, 0.4), inset 0 0 15px rgba(0, 180, 216, 0.1);
    border-color: #48cae4 !important;
    transform: translateY(-4px) scale(1.02);
}

/* 2. Nome Animato BLU NEON (Per Rank #1) */
.neon-blue-anim {
    font-weight: 800;
    background: linear-gradient(
        to right, 
        #00b4d8, 
        #90e0ef, 
        #0077b6, 
        #90e0ef, 
        #00b4d8
    );
    background-size: 200% auto;
    color: #00b4d8;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 3s linear infinite;
    text-shadow: 0 0 10px rgba(0, 180, 216, 0.4);
    display: inline-block;
}

/* 3. Nome Animato ORO (Per Sponsor) */
.gold-anim {
    font-weight: 800;
    background: linear-gradient(
        to right, 
        #BF953F, 
        #FCF6BA, 
        #B38728, 
        #FBF5B7, 
        #AA771C
    );
    background-size: 200% auto;
    color: #ffd700;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 3s linear infinite;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    display: inline-block;
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}

.neon-blue-anim::before {
    content: '👑 ';
    font-size: 0.9em;
    -webkit-text-fill-color: initial;
    text-shadow: none;
    vertical-align: middle;
}

.gold-anim::before {
    content: '⭐ ';
    font-size: 0.8em;
    -webkit-text-fill-color: initial;
    text-shadow: none;
    vertical-align: middle;
}

/* --- STATO SERVER --- */
.server-status-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    line-height: 1.2;
    overflow: visible;
}

.status-online {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    animation: online-pulse 2s infinite;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.status-offline {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.player-count-header {
    font-size: 0.95rem;
    color: #cbd5e1;
    font-weight: 600;
    font-family: 'Inter', monospace;
}

/* --- COLONNA RIGHT (STRISCIA BLU STRETTA) --- */
.server-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--primary);
    border-left: none;
    text-decoration: none;
    position: relative;
    transition: background 0.3s ease;
    overflow: hidden;
    cursor: pointer;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.server-stats:hover {
    background: var(--primary-glow);
}

.action-text { display: none !important; }

.action-icon {
    color: white;
    font-size: 1.4rem;
    transition: transform 0.2s ease;
    transform: translateX(0);
    opacity: 1;
    margin: 0;
}

.server-stats:hover .action-icon {
    transform: translateX(3px);
}

/* --- FOOTER CARD --- */
.server-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end; 
    margin-top: 0;
    padding-top: 5px;
    gap: 15px;
    height: 40px; 
    flex-shrink: 0;
}

.server-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow: hidden;
    height: 100%;
    align-items: flex-end;
    padding-bottom: 2px;
    flex: 1;
    min-width: 0;
}

.server-ip-wrap-modern {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #333;
    border-radius: 50px;
    padding: 4px 5px 4px 15px;
    transition: all 0.3s ease;
    height: 36px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin-left: auto;
    flex-shrink: 0;
}

.server-ip-wrap-modern:hover {
    border-color: var(--primary);
    background: #000;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
    transform: translateY(-2px);
}

.ip-text-modern {
    color: #f1f5f9;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    margin-right: 12px;
    letter-spacing: 0.5px;
    user-select: all;
    white-space: nowrap;
}

.btn-copy-modern {
    background: var(--primary);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-size: 0.85rem;
}

.btn-copy-modern:hover {
    background: white;
    color: var(--primary);
    transform: rotate(15deg) scale(1.1);
}

.btn-copy-modern:active {
    transform: scale(0.9);
}

/* --- TAGS --- */
.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 0;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.tag:hover {
    border-color: rgba(255,255,255,0.2);
    color: #fff;
    cursor: default;
}

.tag-survival { background-color: rgba(39, 174, 96, 0.15); color: #2ecc71; border-color: rgba(39, 174, 96, 0.3); }
.tag-creative { background-color: rgba(155, 89, 182, 0.15); color: #d7bde2; border-color: rgba(155, 89, 182, 0.3); }
.tag-pvp { background-color: rgba(231, 76, 60, 0.15); color: #ec7063; border-color: rgba(231, 76, 60, 0.3); }
.tag-minigames { background-color: rgba(22, 160, 133, 0.15); color: #1abc9c; border-color: rgba(22, 160, 133, 0.3); }
.tag-votes { background-color: rgba(255, 193, 7, 0.1); border: 1px solid rgba(255, 193, 7, 0.3); color: #ffd54f; display: inline-flex; align-items: center; gap: 5px; }

/* --- SPONSOR --- */
.server-row.sponsored {
    animation: sponsor-pulse 3s infinite ease-in-out;
    position: relative;
    z-index: 5;
    background: linear-gradient(145deg, var(--bg-card) 60%, rgba(255, 215, 0, 0.05) 100%);
    transform: translateZ(0);
    will-change: box-shadow;
}

.badge-sponsor {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%) !important;
    color: #000 !important;
    font-weight: 800;
    text-transform: uppercase;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    letter-spacing: 0.5px;
    font-size: 0.7rem; 
    padding: 2px 6px;
    border-radius: 4px;
}

.server-row.sponsored:hover {
    border-color: #ffd700 !important;
    box-shadow: 0 10px 50px rgba(255, 215, 0, 0.15) !important;
    transition: all 0.3s ease;
    z-index: 1001; 
}

/* --- GHOST MODE & TOOLTIP --- */
.ghost-warning-wrapper { 
    position: relative; 
    display: inline-block; 
    margin-top: 5px; 
    cursor: help; 
    z-index: 20; 
}

.ghost-icon { color: #f39c12; font-size: 0.9rem; animation: ghost-pulse 2s infinite; }

.ghost-tooltip {
    visibility: hidden;
    opacity: 0;
    width: 320px;
    background-color: #0f1014;
    color: #e2e8f0; 
    text-align: center;
    border-radius: 10px;
    padding: 18px;
    position: absolute;
    z-index: 10000;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    border: 1px solid var(--border-color);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    pointer-events: none;
    font-size: 0.9rem; 
    line-height: 1.5;
}

/* Regola per forzare colore dei testi dentro il tooltip */
.ghost-tooltip p, 
.ghost-tooltip span {
    color: #cbd5e1;
    margin: 0 0 10px 0;
    display: block;
}

.ghost-header { 
    font-weight: 700; 
    color: #f39c12; 
    margin-bottom: 8px; 
    font-size: 0.95rem; 
    text-transform: uppercase; 
    border-bottom: 1px solid rgba(255,255,255,0.1); 
    padding-bottom: 8px; 
    display: block;
}

.ghost-desc { 
    font-size: 0.85rem; 
    color: #94a3b8; 
    line-height: 1.5; 
    margin-bottom: 12px; 
    display: block;
}

.ghost-countdown { 
    background: rgba(243, 156, 18, 0.1); 
    color: #f39c12; 
    font-weight: 800; 
    padding: 8px 12px;
    border-radius: 6px; 
    font-family: monospace; 
    font-size: 1.1rem; 
    border: 1px solid rgba(243, 156, 18, 0.2); 
    display: inline-block;
    margin-top: 5px;
}

.ghost-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #0f1014 transparent transparent transparent;
}

.ghost-warning-wrapper:hover .ghost-tooltip { 
    visibility: visible; 
    opacity: 1; 
    transform: translateX(-50%) translateY(0); 
}

/* --- RESPONSIVE CARDS --- */
@media (min-width: 1600px) {
    .server-row { grid-template-columns: 280px 1fr 70px; height: 170px; } 
    .server-name-wrap h3 { font-size: 1.8rem; }
    .server-details p { max-height: 3em; -webkit-line-clamp: 3; } 
    .tag { font-size: 0.8rem; padding: 5px 10px; }
    .server-ip-wrap-modern { height: 42px; }
    .ip-text-modern { font-size: 1.05rem; }
    .btn-copy-modern { width: 32px; height: 32px; }
    .player-count-header { font-size: 1.1rem; }
}

/* FIX MOBILE AGGRESSIVO PER TAGS E IP */
@media (max-width: 768px) {
    /* 1. Layout Griglia Mobile: Icona piccola (75px) | Contenuto | Azione piccola */
    .server-row {
        grid-template-columns: 75px 1fr 40px !important;
        height: auto !important; /* Altezza automatica per adattarsi al contenuto */
        min-height: 110px;
        margin-bottom: 15px;
    }

    /* 2. Fix Icona Mobile */
    .server-icon {
        border-bottom-left-radius: 0;
        border-right: 1px solid var(--border-color);
    }
    .server-icon::after { display: none; } /* Rimuove sfumatura su mobile */

    /* 3. Dettagli Compatti */
    .server-details {
        padding: 10px;
        gap: 8px;
    }

    .server-name-wrap h3 { font-size: 1.1rem; }
    .server-details p { font-size: 0.85rem; -webkit-line-clamp: 2; margin-bottom: 8px; }

    /* 4. FIX FOOTER: STACK VERTICALE */
    .server-footer-row {
        flex-direction: column; /* Impila gli elementi */
        align-items: flex-start;
        gap: 8px; /* Spazio tra Tags e IP */
        height: auto;
        padding-top: 0;
    }

    /* 5. Tags Scorrevoli Orizzontalmente */
    .server-tags {
        width: 100%;
        overflow-x: auto; /* Scroll orizzontale */
        white-space: nowrap;
        padding-bottom: 4px;
        mask-image: linear-gradient(to right, black 90%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
        scrollbar-width: none; /* Nasconde scrollbar Firefox */
    }
    .server-tags::-webkit-scrollbar { display: none; /* Nasconde scrollbar Chrome */ }

    /* 6. IP Full Width e Ben Visibile */
    .server-ip-wrap-modern {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
        height: 32px;
        background: rgba(255, 255, 255, 0.05); /* Più evidente su mobile */
    }
     
    /* Fix Tooltip Ghost su Mobile */
    .ghost-tooltip { position: fixed; top: 50%; left: 50%; bottom: auto; width: 85%; max-width: 320px; transform: translate(-50%, -50%); z-index: 10000; box-shadow: 0 20px 50px rgba(0,0,0,0.9), 0 0 0 1000px rgba(0,0,0,0.7); background-color: #0f1014; border: 1px solid var(--border-color); }
    .ghost-warning-wrapper:hover .ghost-tooltip { transform: translate(-50%, -50%); }
    .ghost-tooltip::after { display: none; }
}