/* 🎨 LIKE-IT - MAIN STYLES COMPLETO */
/* ⚡ Estratto dalla index.html originale - ZERO perdite */

/* ========================================= */
/* 🔧 FIX LAYOUT GLOBALI */
/* ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================= */
/* 🔧 FIX HEADER CENTRATO */
/* ========================================= */
#appHeader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1001 !important;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.mobile-header {
    max-width: 440px;
    margin: 0 auto;
    position: relative;
}

/* ========================================= */
/* 🔧 FIX BOTTOM NAV CENTRATO */
/* ========================================= */
#bottomNav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    display: flex !important;
    justify-content: center !important;
}

.bottom-navigation {
    max-width: 440px !important;
    margin: 0 auto !important;
    background: var(--bg-card) !important;
    box-shadow: 0 -2px 10px var(--shadow-color) !important;
    border-top: 1px solid var(--border-color) !important;
    width: 100% !important;
}

[data-theme="dark"] .bottom-navigation {
    background: #2d2d2d !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.4) !important;
    border-top: 1px solid rgba(102, 126, 234, 0.3) !important;
}

/* ========================================= */
/* 🎨 VARIABILI CSS TEMA BEIGE PANNA */
/* ========================================= */
:root {
    --bg-primary: #faf9f6;
    --bg-secondary: #f5f3ee;
    --bg-card: #fefcf7;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: rgba(102, 126, 234, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --nav-bg: #fefcf7;
    --nav-border: rgba(102, 126, 234, 0.2);
    --nav-shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #333333;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: rgba(102, 126, 234, 0.3);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --nav-bg: #2d2d2d;
    --nav-border: rgba(102, 126, 234, 0.3);
    --nav-shadow: rgba(0, 0, 0, 0.4);
}

/* ========================================= */
/* 🔥 FEED CONTAINER SCROLL VERTICALE */
/* ========================================= */
.content-area {
    padding-top: 52px;
    padding-bottom: 80px;
    min-height: 100vh;
    background: var(--bg-secondary);
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ========================================= */
/* 🔥 FEED SCROLL CONTAINER */
/* ========================================= */
.feed-scroll-container {
    max-width: 440px;
    margin: 0 auto;
    padding: 0 10px;
}

/* ========================================= */
/* 🔥 SINGOLO POST CARD */
/* ========================================= */
.post-card {
    background: var(--bg-card);
    border-radius: 16px;
    margin: 20px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* ========================================= */
/* 🔥 HEADER POST */
/* ========================================= */
.post-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.post-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.user-details {
    flex: 1;
}

.username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.post-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========================================= */
/* 🔥 POST CONTENT OTTIMIZZATO PER TOUCH */
/* ========================================= */
.post-content {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    background: var(--bg-secondary);
    cursor: pointer;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 0.3s ease;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Loading placeholder animation */
.post-image[style*="opacity: 0"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ========================================= */
/* 🔥 FOOTER POST */
/* ========================================= */
.post-footer {
    padding: 15px 20px;
    background: var(--bg-card);
}

.photo-description {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    background: rgba(102, 126, 234, 0.05);
    padding: 8px 10px;
    border-radius: 8px;
    border-left: 3px solid rgba(102, 126, 234, 0.3);
    margin-bottom: 15px;
}

.photo-actions {
    display: flex;
    gap: 8px;
    padding: 0;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: transparent;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    min-height: 64px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.action-icon {
    font-size: 18px;
}

/* ========================================= */
/* 🔥 INTERACTION ZONES */
/* ========================================= */
.like-zone {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 107, 107, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    transform: translate(-50%, -50%);
    z-index: 10;
    border: 2px solid rgba(255, 255, 255, 0.8);
    animation: likeAppear 0.4s ease;
    pointer-events: none;
}

.user-like {
    background: rgba(255, 20, 50, 0.95) !important;
    border: 3px solid white !important;
    box-shadow: 0 4px 12px rgba(255, 20, 50, 0.4) !important;
}

.user-note {
    background: rgba(102, 126, 234, 0.95) !important;
    border: 3px solid white !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    font-size: 16px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    z-index: 15 !important;
}

.other-note {
    background: rgba(34, 139, 34, 0.95) !important;
    border: 3px solid white !important;
    box-shadow: 0 4px 12px rgba(34, 139, 34, 0.4) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    font-size: 16px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    z-index: 15 !important;
}

/* ========================================= */
/* 🔥 PULSE ANIMATION PER NOTE */
/* ========================================= */
@keyframes notePulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 1;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.05); 
        opacity: 0.9;
    }
}

/* ========================================= */
/* 🔥 HOVER EFFECTS PER NOTE */
/* ========================================= */
.user-note:hover,
.other-note:hover {
    transform: translate(-50%, -50%) scale(1.2) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4) !important;
    z-index: 20 !important;
}

@keyframes likeAppear {
    from { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.3); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
}

/* ========================================= */
/* 🌟 CLUSTER STYLES */
/* ========================================= */
.cluster-element {
    position: absolute;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #2c3e50;
    transform: translate(-50%, -50%);
    z-index: 20;
    cursor: pointer;
    font-size: 11px;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
    animation: clusterGlow 2s infinite;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6);
    pointer-events: auto;
}

@keyframes clusterGlow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

.cluster-element .cluster-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.cluster-element .cluster-count {
    font-size: 10px;
    font-weight: bold;
}

/* ========================================= */
/* 📱 INTERACTION MENU OTTIMIZZATO PER MOBILE */
/* ========================================= */
.interaction-menu {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 20px;
    padding: 12px;
    display: flex;
    gap: 12px;
    z-index: 20;
    transform: translate(-50%, -50%);
    animation: menuAppear 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

@keyframes menuAppear {
    from { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
}

.interaction-option {
    padding: 12px 16px;
    border-radius: 15px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 60px;
    min-height: 60px;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.interaction-option:hover,
.interaction-option:active {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.2);
}

.interaction-option.like-option {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
}

.interaction-option.like-option:hover {
    background: linear-gradient(135deg, #ff5252, #d32f2f);
}

.interaction-option.note-option {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.interaction-option.note-option:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

/* ========================================= */
/* 📝 NOTE POPUP MIGLIORATO */
/* ========================================= */
.note-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    max-width: 380px;
    width: calc(100vw - 40px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 200;
    border: 2px solid rgba(102, 126, 234, 0.3);
    animation: notePopupAppear 0.4s ease;
    backdrop-filter: blur(10px);
}

@keyframes notePopupAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) rotateY(-10deg);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotateY(0deg);
    }
}

.note-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.note-popup-user {
    font-size: 15px;
    color: #667eea;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.note-popup-close {
    background: rgba(231, 76, 60, 0.1);
    border: 2px solid #e74c3c;
    color: #e74c3c;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.note-popup-close:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1) rotate(90deg);
}

.note-popup-text {
    font-size: 17px;
    color: var(--text-primary);
    line-height: 1.6;
    background: rgba(102, 126, 234, 0.08);
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    min-height: 80px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.note-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 190;
    animation: overlayAppear 0.3s ease;
    backdrop-filter: blur(3px);
}

@keyframes overlayAppear {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================= */
/* 📝 NOTE INPUT MODAL OTTIMIZZATO PER MOBILE */
/* ========================================= */
.note-input-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.note-input-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 350px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.note-textarea {
    width: 100%;
    height: 100px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    margin: 12px 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    line-height: 1.4;
}

.note-textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.note-input-buttons {
    display: flex;
    gap: 12px;
}

.note-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.note-btn:hover,
.note-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.note-btn.cancel {
    background: #f0f0f0;
    color: #666;
}

.note-btn.cancel:hover {
    background: #e0e0e0;
}

.note-btn.confirm {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.note-btn.confirm:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

/* ========================================= */
/* 🎛️ GLOBAL CONTROLS */
/* ========================================= */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
    cursor: pointer;
    white-space: nowrap;
}

/* ========================================= */
/* 👁️ HIDE INTERACTIONS WHEN TOGGLED OFF */
/* ========================================= */
.interactions-hidden .like-zone,
.interactions-hidden .user-like,
.interactions-hidden .user-note,
.interactions-hidden .other-note,
.interactions-hidden .cluster-element {
    display: none !important;
}

/* ========================================= */
/* ⏳ LOADING SCREEN */
/* ========================================= */
.feed-loading {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================= */
/* ⭐ FAVORITE BUTTON STATES */
/* ========================================= */
.favorite-btn.favorited {
    border-color: #e74c3c;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* ========================================= */
/* 📭 EMPTY STATE */
/* ========================================= */
.empty-feed {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-feed-icon {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.7;
}

/* ========================================= */
/* ➕ FLOATING ACTION BUTTON */
/* ========================================= */
.fab-upload {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-upload:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* ========================================= */
/* 📢 AD CONTAINER PER VERTICAL LAYOUT */
/* ========================================= */
.ad-container {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.ad-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
}

.ad-banner {
    position: relative;
}

.ad-banner .ad-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.ad-banner .ad-content {
    padding: 15px;
}

.ad-banner .ad-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ad-banner .ad-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.ad-banner .ad-cta {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.ad-banner .ad-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ========================================= */
/* 📢 NATIVE AD */
/* ========================================= */
.ad-native {
    background: var(--bg-card);
}

.ad-native .ad-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.ad-native .ad-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.ad-native .ad-advertiser {
    flex: 1;
}

.ad-native .ad-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ad-native .ad-label {
    position: static;
    display: inline-block;
    background: transparent;
    color: var(--text-muted);
    padding: 0;
    font-size: 12px;
}

.ad-native .ad-image-native {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
}

.ad-native .ad-native-content {
    padding: 15px;
}

.ad-native .ad-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

/* ========================================= */
/* 🌙 DARK MODE ADJUSTMENTS */
/* ========================================= */
[data-theme="dark"] .ad-container,
[data-theme="dark"] .post-card {
    background: #2d2d2d;
    border-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .post-header,
[data-theme="dark"] .post-footer {
    background: #2d2d2d;
}

/* ========================================= */
/* 📱 RESPONSIVE */
/* ========================================= */
@media (max-width: 768px) {
    .feed-scroll-container {
        padding: 0 5px;
    }
    
    .post-card {
        margin: 15px 0;
    }
}

/* ========================================= */
/* 📈 SCROLL INDICATOR */
/* ========================================= */
.scroll-indicator {
    position: fixed;
    top: 52px;
    left: 0;
    height: 3px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    z-index: 999;
    transition: width 0.1s ease;
}

/* ============== DARK: via toggle interno ============== */
html[data-theme="dark"] .frame-statistics {
  background: #1a1a1a !important;
  border: 1px solid #2a2a2a !important;
  color: #eaeaea !important;
}

html[data-theme="dark"] .frame-statistics .stats-header {
  background: #2a1a1a !important;
  color: #ff9999 !important;
  border: 1px solid #3a2a2a !important;
}

html[data-theme="dark"] .frame-statistics .stat-item {
  background: #161616 !important;
  color: #eaeaea !important;
  border: 1px solid #2a2a2a !important;
}

html[data-theme="dark"] .frame-statistics .stat-number {
  color: #ffffff !important;
}

html[data-theme="dark"] .frame-statistics .stat-label {
  color: #b8b8b8 !important;
}

html[data-theme="dark"] .frame-statistics .stats-row {
  background: transparent !important;
}

/* ============== DARK: via preferenza di sistema ============== */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .frame-statistics {
    html:not([data-theme]) background: #1a1a1a !important;
    html:not([data-theme]) border: 1px solid #2a2a2a !important;
    html:not([data-theme]) color: #eaeaea !important;
  }
  .frame-statistics .stats-header {
    background: #2a1a1a !important;
    color: #ff9999 !important;
    border: 1px solid #3a2a2a !important;
  }
  .frame-statistics .stat-item {
    background: #161616 !important;
    color: #eaeaea !important;
    border: 1px solid #2a2a2a !important;
  }
  .frame-statistics .stat-number { color: #ffffff !important; }
  .frame-statistics .stat-label  { color: #b8b8b8 !important; }
  .frame-statistics .stats-row   { background: transparent !important; }
}

/* ☀️ Light theme explicit overrides when toggled */
html[data-theme="light"] .frame-statistics {
  background: #ffffff !important;
  border: 1px solid #e5e5e5 !important;
  color: #222222 !important;
}
html[data-theme="light"] .frame-statistics .stats-header {
  background: #fff5f5 !important;
  color: #cc0000 !important; /* tipico header rosso chiaro */
  border: 1px solid #f0caca !important;
}
html[data-theme="light"] .frame-statistics .stat-item {
  background: #ffffff !important;
  color: #222222 !important;
  border: 1px solid #e5e5e5 !important;
}
html[data-theme="light"] .frame-statistics .stat-number { color: #111111 !important; }
html[data-theme="light"] .frame-statistics .stat-label  { color: #555555 !important; }
html[data-theme="light"] .frame-statistics .stats-row   { background: transparent !important; }

/* === Fix Top 3 Frames Width & Dark Mode Title Color === */

/* Ridurre leggermente larghezza top frame per evitare scroll */
.top-frames-container {
  display: flex;
  justify-content: space-between;
  overflow-x: hidden; /* rimuove slider */
}

.top-frame {
  flex: 0 0 32%; /* era ~33.33% */
  box-sizing: border-box;
}

/* Tema scuro: titolo bianco */
html[data-theme="dark"] .top-frames-title,
html:not([data-theme])[data-theme="dark"] .top-frames-title {
  color: #fff !important;
}

/* === Top 3 Frames: elimina overflow con calc + gap === */
.top-frames-container {
  display: flex;
  gap: 8px;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.top-frame {
  flex: 0 0 calc((100% - 16px) / 3); /* 3 elementi, gap 8px => 2 gap tra 3 elementi */
  box-sizing: border-box;
}


/* === Hide horizontal scrollbar for frames containers === */
.frames-container,
.top-frames-container,
.top-frames {
  overflow-x: hidden !important;
  scrollbar-width: none;           /* Firefox */
  -ms-overflow-style: none;        /* IE 10+ */
}
.frames-container::-webkit-scrollbar,
.top-frames-container::-webkit-scrollbar,
.top-frames::-webkit-scrollbar {
  display: none;                   /* Chrome/Safari/Opera */
  width: 0;
  height: 0;
}

/* Ensure frame cards and images don't overflow */
.top-frame,
.frame-thumb { box-sizing: border-box; min-width: 0; }
.frame-thumb img { max-width: 100%; height: auto; display: block; }



/* ===== Header sizing guard (prevent accidental growth) ===== */
header.site-header,
header[role="banner"],
header.app-header,
header {
  min-height: 32px !important;
  padding-top: 2px !important;
  padding-bottom: 2px !important;
}

header .logo img,
header .brand img,
header img.logo {
  max-height: 28px !important;
  height: auto !important;
  display: block !important;
}

header .btn, header .button, header nav a {
  line-height: 1.1 !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
}
