/* base.css - Stili fondamentali e layout di base */
/* UPDATED: Better mobile experience + scaled down for smaller screens */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

body {
    background: #16162e;
    color: #fff;
}

/* === MAIN CONTENT === */
.home-section {
    position: relative;
    background: #16162e;
    min-height: 100vh;
    top: 0;
    left: 78px;
    width: calc(100% - 78px);
    transition: all 0.5s ease;
    z-index: 2;
    padding: 20px;
}

.sidebar.open ~ .home-section {
    left: 250px;
    width: calc(100% - 250px);
}

/* === CONTAINER PER CENTRARE CONTENUTO === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    color: #fff;
    font-size: 28px;
    font-weight: 600;
}

.page-header p {
    color: #888;
    margin-top: 5px;
}

/* === STAT CARDS === */
.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    background: #11101D;
    border-radius: 12px;
    border: 1px solid transparent;
    position: relative;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Glow border effect */
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(135deg, transparent 0%, transparent 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Hover state - glow verde elegante */
.stat-card:hover {
    transform: translateY(-4px);
    background: #141324;
    box-shadow: 
        0 10px 40px -10px rgba(76, 175, 80, 0.3),
        0 0 0 1px rgba(76, 175, 80, 0.2);
}

.stat-card:hover::before {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 50%, #4CAF50 100%);
    opacity: 1;
}

/* Effetto shine su hover */
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(76, 175, 80, 0.08),
        transparent
    );
    transition: left 0.6s ease;
    pointer-events: none;
}

.stat-card:hover::after {
    left: 100%;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #4CAF50;
    margin-bottom: 5px;
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stat card per admin panel con icone */
.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4CAF50;
    color: white;
    font-size: 28px;
    flex-shrink: 0;
}

.stat-card .stat-icon.info {
    background: #2196F3;
}

.stat-card .stat-icon.success {
    background: #4CAF50;
}

.stat-card .stat-icon.warning {
    background: #FF9800;
}

.stat-card .stat-icon.danger {
    background: #F44336;
}

/* === CARDS === */
.card {
    background: #11101D;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header h3 {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
}

/* === BUTTONS === */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

/* === FORMS === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #fff;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    background: #1d1b31;
    color: #fff;
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    box-shadow: 0 0 0 2px #4CAF50;
}

/* === GRIDS === */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* === UTILITIES === */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

/* === TABELLE MIGLIORATED === */
.table-container {
    overflow-x: auto;
}

.leaderboard-table,
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #11101D;
    border-radius: 10px;
    overflow: hidden;
}

.leaderboard-table th,
.leaderboard-table td,
.admin-table th,
.admin-table td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid #1d1b31;
}

.leaderboard-table th,
.admin-table th {
    background: #1d1b31;
    font-weight: 600;
    color: #fff;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-table tbody tr,
.admin-table tbody tr {
    transition: background-color 0.3s ease;
}

.leaderboard-table tbody tr:hover,
.admin-table tbody tr:hover {
    background: #1d1b31;
}

/* === RANK BADGES === */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    box-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #B8860B);
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.rank-badge.rank-other {
    background: #6c757d;
    color: #fff;
}

.credits-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.stat-icon-wrapper .credits-icon {
    width: 28px;
    height: 28px;
}
/* === FLAG SUPPORT === */
.flag-img {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    margin-right: 8px;
    object-fit: cover;
}

/* Admin panel - bandiere piccole */
.admin-participant-item .participant-flag .flag-img,
.admin-table td .flag-img {
    width: 16px !important;
    height: 12px !important;
    margin-right: 4px;
}

/* === RESPONSIVE - SMALLER DESKTOP/LAPTOP (1920x1080 and below) === */
@media (max-width: 1920px) {
    html {
        font-size: 14px; /* Base font reduction */
    }
    
    body {
        zoom: 0.80; /* 20% reduction for 1920px and below */
    }
    
    .home-section {
        left: 70px;
        width: calc(100% - 70px);
        padding: 18px;
    }
    
    .sidebar.open ~ .home-section {
        left: 220px;
        width: calc(100% - 220px);
    }
    
    .container {
        max-width: 1200px;
        padding: 0 30px;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .stat-card {
        padding: 16px 20px;
        gap: 12px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-card .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .card {
        padding: 16px;
    }
    
    .card-header h3 {
        font-size: 18px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .form-control {
        padding: 10px;
        font-size: 14px;
    }
}

/* === RESPONSIVE - LAPTOP (1440px and similar) === */
@media (max-width: 1440px) {
    body {
        zoom: 0.80; /* Keep 20% reduction */
    }
    
    .home-section {
        left: 65px;
        width: calc(100% - 65px);
        padding: 16px;
    }
    
    .sidebar.open ~ .home-section {
        left: 200px;
        width: calc(100% - 200px);
    }
    
    .container {
        max-width: 1000px;
        padding: 0 25px;
    }
    
    .page-header {
        margin-bottom: 20px;
    }
    
    .page-header h1 {
        font-size: 22px;
    }
    
    .page-header p {
        font-size: 13px;
    }
    
    .stat-card {
        padding: 14px 18px;
        gap: 10px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .stat-card .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
    
    .card {
        padding: 14px;
        margin-bottom: 16px;
    }
    
    .card-header h3 {
        font-size: 16px;
    }
    
    .btn {
        padding: 7px 14px;
        font-size: 12px;
    }
    
    .form-control {
        padding: 9px;
        font-size: 13px;
    }
    
    .grid {
        gap: 16px;
    }
    
    .grid-2 {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .grid-4 {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    
    .leaderboard-table th,
    .leaderboard-table td,
    .admin-table th,
    .admin-table td {
        padding: 12px 10px;
        font-size: 13px;
    }
}

/* === RESPONSIVE - SMALL LAPTOP (1366x768 and similar) === */
@media (max-width: 1366px) {
    body {
        zoom: 0.80; /* Keep 20% reduction - same as 1920 */
    }
}

/* === RESPONSIVE - TABLET (768px - 1024px) === */
@media (max-width: 1024px) {
    .home-section {
        left: 60px;
        width: calc(100% - 60px);
        padding: 14px;
    }
    
    .sidebar.open ~ .home-section {
        left: 200px;
        width: calc(100% - 200px);
    }
    
    .container {
        padding: 0 20px;
    }
    
    .stat-card {
        padding: 12px 15px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* === RESPONSIVE - MOBILE (below 768px) === */
@media (max-width: 768px) {
    body {
        zoom: 1; /* Reset zoom for mobile */
    }
    
    html {
        font-size: 16px; /* Reset base font for mobile */
    }
    
    .home-section {
        left: 0;
        width: 100%;
        padding: 70px 15px 20px 15px; /* Top padding for mobile menu button */
        min-height: 100vh;
    }
    
    .sidebar.open ~ .home-section {
        left: 0;
        width: 100%;
        /* Prevent scrolling when sidebar is open */
        overflow: hidden;
        height: 100vh;
    }
    
    .container {
        padding: 0 10px;
        max-width: 100%;
    }
    
    .page-header {
        margin-bottom: 20px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .page-header p {
        font-size: 12px;
    }
    
    .grid {
        gap: 12px;
    }
    
    /* Hide elements on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: row;
        text-align: left;
        gap: 12px;
    }
    
    .stat-card .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 16px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
    }
    
    .form-control {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Table responsive */
    .table-container {
        margin: 0 -10px;
        padding: 0 10px;
    }
    
    .leaderboard-table,
    .admin-table {
        font-size: 12px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td,
    .admin-table th,
    .admin-table td {
        padding: 10px 8px;
    }
    
    .rank-badge {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .flag-img {
        width: 18px;
        height: 13px;
    }
}

/* === RESPONSIVE - SMALL MOBILE (below 480px) === */
@media (max-width: 480px) {
    .home-section {
        padding: 65px 12px 15px 12px;
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    .page-header p {
        font-size: 11px;
    }
    
    .card {
        padding: 12px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* === UTILITY CLASSES FOR MOBILE === */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .full-width-mobile {
        width: 100% !important;
    }
}
