/* File: /assets/style.css (VERSIONE OTTIMIZZATA E SPETTACOLARE) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* 🎨 Palette Colori Moderna */
    --primary-hue: 220; /* Blu istituzionale, ma più vibrante */
    --primary-color: hsl(var(--primary-hue), 90%, 60%);
    --primary-hover: hsl(var(--primary-hue), 90%, 55%);
    --primary-gradient: linear-gradient(135deg, hsl(var(--primary-hue), 90%, 65%) 0%, hsl(var(--primary-hue), 80%, 50%) 100%);
    --primary-glow: hsla(var(--primary-hue), 80%, 60%, 0.3);

    --success-color: #10B981; /* Verde brillante per successo */
    --error-color: #EF4444;   /* Rosso acceso per errori */
    --warning-color: #F59E0B; /* Ambra per avvisi */

    /* 🏙️ Sfondi e Superfici */
    --background-color: #f0f2f5; /* Grigio chiarissimo, riposante per gli occhi */
    --card-background: #ffffff;
    --sidebar-background: linear-gradient(180deg, #1f2937 0%, #111827 100%); /* Gradiente scuro più profondo */
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --input-bg: #f8f9fa;

    /* ✍️ Testi e Tipografia */
    --text-color: #1f2937; /* Quasi nero, per un contrasto elevato */
    --text-light: #6b7280; /* Grigio per testi secondari */
    --sidebar-text-color: #d1d5db;
    --sidebar-text-active: #ffffff;
    
    /* 🎨 Bordi, Ombre ed Effetti */
    --border-color: #e5e7eb;
    --border-radius: 12px; /* Bordi più arrotondati per un look moderno */
    --box-shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --box-shadow-lifted: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* ⚙️ Transizioni e Misure */
    --transition-speed: 0.3s;
    --transition-easing: cubic-bezier(0.25, 0.8, 0.25, 1);
    --sidebar-width: 260px;
}

/* ===== RESET E STILI GLOBALI ===== */
* { box-sizing: border-box; }

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
    display: flex; /* Aggiunto per centrare il login */
    min-height: 100vh;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LAYOUT PRINCIPALE E SIDEBAR ===== */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    min-width: 0; /* Previene overflow nei layout flex */
    padding: 2.5rem;
    overflow-y: auto;
    animation: fadeIn var(--transition-speed) var(--transition-easing);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -1px;
}

.sidebar {
    position: sticky; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-background);
    color: var(--sidebar-text-color);
    box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    display: flex; flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-speed) var(--transition-easing), width var(--transition-speed) var(--transition-easing);
    flex-shrink: 0;
}

.sidebar .logo {
    text-align: center;
    padding: 1.5rem 1.5rem 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .logo h1 {
    margin: 0;
    color: var(--sidebar-text-active);
    font-size: 1.8rem;
    font-weight: 700;
}

.sidebar-nav { flex-grow: 1; overflow-y: auto; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav ul li a {
    display: flex; align-items: center;
    padding: 0.9rem 1.5rem;
    margin: 0.25rem 1rem;
    color: var(--sidebar-text-color);
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--transition-speed);
}

.sidebar-nav ul li a:hover:not(.active) {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-nav ul li a.active {
    background: var(--primary-gradient);
    color: var(--sidebar-text-active);
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.sidebar-nav ul li a svg {
    margin-right: 1rem;
    width: 22px; height: 22px;
    opacity: 0.8; flex-shrink: 0;
}

.sidebar-nav .dropdown-content {
    background-color: rgba(0,0,0,0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
    margin: 0 1rem; border-radius: 8px;
}

.sidebar-nav .dropdown > a.active + .dropdown-content,
.sidebar-nav .dropdown:hover > .dropdown-content {
    max-height: 500px;
}

.sidebar-nav .dropdown-content li a {
    padding-left: 3.8rem;
    font-size: 0.9rem;
    margin: 0; border-radius: 0;
}

/* ===== ELEMENTI UI COMUNI ===== */
.card {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-soft);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}
.card h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }
.card p { color: var(--text-light); }

.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.form-group small { color: var(--text-light); font-size: 0.85em; margin-top: 0.5rem; display: block; }

input, textarea, select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--input-bg);
    transition: all var(--transition-speed);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: white;
}
textarea { resize: vertical; min-height: 100px; }

button, .action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.8rem 1.5rem;
    background: var(--primary-gradient);
    color: white;
    border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 600;
    cursor: pointer;
    box-shadow: var(--box-shadow-soft);
    transition: all var(--transition-speed) var(--transition-easing);
    text-decoration: none;
    text-align: center;
}
button:hover, .action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-lifted);
}
button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.delete-btn { background: var(--error-color); }
.delete-btn:hover { background: #c02d3a; }
.button-secondary { background: #6c757d; }
.button-secondary:hover { background: #5a6268; }

.form-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr 1fr;
}

.feedback { padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; }
.feedback.success { background-color: #d1fae5; color: #065f46; }
.feedback.error { background-color: #fee2e2; color: #991b1b; }
.feedback.info { background-color: #dbeafe; color: #1e40af; }

/* ===== TABELLE E LISTE ===== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    font-size: 0.95em;
}
.results-table th, .results-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}
.results-table th {
    background-color: #f9fafb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8em;
    color: var(--text-light);
    position: sticky; top: 0; z-index: 1;
}
.results-table tbody tr:hover { background-color: #f9fafb; }

.site-list { list-style: none; padding: 0; }
.site-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem; border-bottom: 1px solid var(--border-color);
}
.site-list li:last-child { border-bottom: none; }

/* ===== DASHBOARD (HOME) & VISITATORI LIVE ===== */
.pulsing-dot {
    display: inline-block; width: 10px; height: 10px;
    background-color: var(--success-color); border-radius: 50%;
    margin-right: 10px; animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.live-layout-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    align-items: start;
}
.realtime-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.realtime-stat-card {
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
    transition: all var(--transition-speed); position: relative; overflow: hidden;
}
.realtime-stat-card:hover { transform: translateY(-4px); box-shadow: var(--box-shadow-lifted); }
.realtime-stat-card .card-header { display: flex; align-items: center; gap: 0.75rem; }
.realtime-stat-card .favicon { width: 24px; height: 24px; border-radius: 4px; }
.realtime-stat-card .site-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.realtime-stat-card .visitor-count { font-size: 2.5rem; font-weight: 800; line-height: 1; color: var(--text-color); }
.realtime-stat-card .activity-bar-bg { width: 100%; height: 8px; background-color: #e5e7eb; border-radius: 8px; overflow: hidden; }
.realtime-stat-card .activity-bar-fg { height: 100%; background: var(--primary-gradient); border-radius: 8px; transition: width 0.5s var(--transition-easing); }
.realtime-stat-card.rank-1 { border-color: #ffd700; background: #fffbeb; }
.realtime-stat-card.rank-2 { border-color: #c0c0c0; background: #fafafa; }
.realtime-stat-card.rank-3 { border-color: #cd7f32; background: #fff7ed; }
.total-live-card {
    background: var(--primary-gradient); color: white; padding: 1.5rem 2rem;
    border-radius: var(--border-radius); text-align: center; box-shadow: var(--box-shadow-lifted);
    position: sticky; top: 2.5rem;
}
.total-live-card h3 { margin: 0; font-size: 1.1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.8; }
.total-live-card p { margin: 0.25rem 0 0 0; font-size: 4.5rem; font-weight: 800; line-height: 1.1; color: white; }
.loading-placeholder, .error-placeholder { padding: 2rem; text-align: center; color: var(--text-light); grid-column: 1 / -1; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.feature-card { text-align: center; padding: 1.5rem; border: 1px solid var(--border-color); border-radius: var(--border-radius); transition: all var(--transition-speed); }
.feature-card:hover { transform: scale(1.03); box-shadow: var(--box-shadow-lifted); }
.feature-card .icon { font-size: 2.5rem; }
.feature-card h3 { margin: 0.5rem 0; }
.feature-card .action-btn { margin-top: 1rem; }


/* ===== PAGINA LOGIN ===== */
.login-card {
    margin: auto; max-width: 400px; width: 100%;
}
.login-card .error { color: var(--error-color); margin-top: 1rem; text-align: center; }

/* ===== RESPONSIVE ===== */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; z-index: 1100; }
.menu-toggle .icon-bar { display: block; width: 24px; height: 3px; background-color: var(--text-color); border-radius: 3px; margin: 5px 0; transition: all var(--transition-speed); }

@media (max-width: 1024px) {
    .menu-toggle { display: block; }
    .sidebar { position: fixed; transform: translateX(-100%); }
    .app-container.sidebar-visible .sidebar { transform: translateX(0); }
    .live-layout-grid { grid-template-columns: 1fr; }
    .total-live-card { position: static; }
    .main-content { padding: 1.5rem; }
    header { margin-bottom: 1.5rem; padding-bottom: 1rem; }
    header h1 { font-size: 1.8rem; }
    .form-grid { grid-template-columns: 1fr; }
}

/* Stili specifici per la dashboard guadagni (go = guadagni online) */
.go-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; }
.go-card { background-color: #fff; padding: 1.5rem; border-radius: var(--border-radius); box-shadow: var(--box-shadow-soft); text-align: center; border: 1px solid var(--border-color); }
.go-card h2 { font-size: 1rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; margin: 0 0 0.5rem 0; padding: 0; border: none; }
.go-card .go-value { font-size: 2.5rem; font-weight: 700; color: var(--text-color); margin: 0; line-height: 1.1; }
.go-card small { font-size: 0.85rem; color: var(--text-light); }
.go-table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; font-size: 1rem; }
.go-table th, .go-table td { padding: 1rem; border-bottom: 1px solid var(--border-color); }
.go-table th { background-color: #f9fafb; font-weight: 600; }
.go-table .go-center { text-align: center; }

/* Stili per tabelle con barre di progresso */
.progress-bar-background { background-color: #e9ecef; border-radius: .25rem; overflow: hidden; }
.progress-bar-foreground { background-color: var(--primary-color); height: 20px; text-align: center; color: white; line-height: 20px; transition: width .6s ease; }

/* ============================================= */
/* == STILI PAGINA GESTIONE SERVER == */
/* ============================================= */

#server-map-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 1.5rem;
}

.server-group {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: var(--box-shadow-soft);
}
.server-group:hover {
    box-shadow: var(--box-shadow-lifted);
    transform: translateY(-4px);
}

.server-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}
.server-group-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}
.server-group-header .site-count {
    font-size: 0.9rem;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
}

.ip-block {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    padding: 1rem;
}

.ip-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.ip-block-header svg {
    width: 20px;
    height: 20px;
    color: var(--text-light);
}

.site-list-ul {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.site-list-li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 1px solid #f1f3f5;
}
.site-list-li:first-child {
    border-top: none;
}
.site-info strong {
    font-weight: 500;
}
.site-info a {
    font-size: 0.85rem;
    color: var(--primary-hover);
    text-decoration: none;
}
.site-info a:hover {
    text-decoration: underline;
}

.site-status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.site-status-badge[data-status="attivo"] {
    background-color: #d1fae5;
    color: #065f46;
}

.site-status-badge[data-status="parking"] {
    background-color: #e5e7eb;
    color: #4b5563;
}

.slot-libero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    margin-top: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    font-weight: 500;
}
.slot-libero svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.5rem;
    color: #adb5bd;
}

/* Stili per l'ordinamento della tabella */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px; /* Spazio per la freccia */
}

/* Nasconde le frecce di default */
th.sortable::before,
th.sortable::after {
    content: "";
    position: absolute;
    right: 8px;
    opacity: 0.3;
    border: 4px solid transparent;
}

/* Freccia SU */
th.sortable::before {
    bottom: 50%;
    margin-bottom: -1px;
    border-bottom-color: var(--text-color);
}

/* Freccia GIU */
th.sortable::after {
    top: 50%;
    margin-top: -1px;
    border-top-color: var(--text-color);
}

/* Mostra la freccia attiva */
th.sortable.asc::before,
th.sortable.desc::after {
    opacity: 1;
}

/* =================================================================
   STILI PER LE TAB
   ================================================================= */

/* --- 1. Il Menu delle Tab --- */

.tabs-container {
    width: 100%;
}

ul.tabs-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    display: flex;
    border-bottom: 2px solid #ccc;
}

ul.tabs-nav li {
    margin: 0 5px 0 0;
    padding: 0;
}

ul.tabs-nav li a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--primary-color, #0073aa); /* Colore link */
    background: #f4f4f4; /* Sfondo tab inattiva */
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    font-weight: 500;
    position: relative;
    top: 2px; /* Si allinea con il bordo inferiore */
}

/* Stile per la tab ATTIVA */
ul.tabs-nav li.tab-active a {
    background: #fff; /* Sfondo tab attiva (bianco) */
    border-bottom: 2px solid #fff; /* Copre il bordo grigio */
    color: var(--text-color, #333);
    font-weight: 600;
}

/* --- 2. Il Contenuto delle Tab (La tua soluzione) --- */

.tabs-content {
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Nasconde TUTTI i pannelli di default */
.tab-pane {
    display: none;
}

/* Mostra SOLO il pannello che ha anche la classe .tab-active */
.tab-pane.tab-active {
    display: block;
}