/* ========================================
   ROG RESPONSIVE SYSTEM - Tutti i Dispositivi
   Breakpoint: Mobile → Tablet → Desktop → Large
   ======================================== */

/* ====================
   BASE RESET & OPTIMIZATION
   ==================== */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

html {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    font-size: 16px; /* base per rem */
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* previeni scroll orizzontale */
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ====================
   BREAKPOINT STANDARD
   ==================== */
/* 
   Mobile:  < 768px  (iPhone, Android phone)
   Tablet:  768px - 1024px (iPad, Android tablet)
   Desktop: 1025px - 1439px (Laptop, PC)
   Large:   ≥ 1440px (Desktop grande, 4K)
*/

/* ====================
   MOBILE FIRST (< 768px)
   ==================== */
@media (max-width: 767px) {
    /* Typography mobile */
    h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
    h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
    h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
    p  { font-size: clamp(0.9rem, 2.5vw, 1.1rem); line-height: 1.6; }
    
    /* Container mobile */
    .container,
    .admin-container,
    .donation-container {
        padding: 0 16px;
        width: 100%;
    }
    
    /* Buttons mobile - più grandi per tocco */
    .btn,
    .home-btn-main,
    .donate-btn,
    .connect-wallet-btn {
        min-height: 48px; /* Apple HIG recommendation */
        font-size: 1rem;
        padding: 14px 20px;
        width: 100%;
        margin-bottom: 12px;
    }
    
    /* Grid → Stack su mobile */
    .home-buttons-grid,
    .donation-amounts,
    .grid-2,
    .grid-3 {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    /* Tabs scrollabili */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 120px;
    }
    
    /* Form inputs mobile */
    .input-field,
    .input-group input,
    .input-group textarea {
        font-size: 16px !important; /* previeni zoom iOS */
        padding: 14px 16px;
        width: 100%;
    }
    
    /* Modal/Popup fullscreen su mobile */
    .modal,
    .popup,
    .metamask-modal {
        padding: 10px;
    }
    
    .modal-content,
    .popup-content,
    .metamask-popup {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Admin panel mobile */
    .admin-hero-title {
        font-size: 2rem !important;
    }
    
    .admin-hero-subtitle {
        font-size: 1.1rem !important;
    }
    
    .login-container {
        padding: 24px 20px !important;
        width: 100%;
    }
    
    /* Area personale mobile */
    .area-welcome-header,
    .posizioni-data,
    .persone-data,
    .referral-data {
        margin-bottom: 60px !important; /* più spazio tra sezioni */
        padding: 20px 16px !important;
    }
    
    .area-welcome-title {
        font-size: 2rem !important;
    }
    
    /* Messages/Chat mobile */
    .messages-data {
        width: 95% !important;
        max-width: 100% !important;
    }
    
    #messagesList {
        max-height: 60vh;
    }
    
    /* Return arrow mobile - più piccolo */
    .return-arrow {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.6rem !important;
        top: 20px !important;
        right: 10px !important;
    }
}

/* ====================
   MOBILE PICCOLI (< 480px)
   iPhone SE, Android piccoli
   ==================== */
@media (max-width: 479px) {
    html {
        font-size: 14px; /* base leggermente più piccola */
    }
    
    .home-title-main {
        font-size: 1.8rem !important;
    }
    
    .home-subtitle-block {
        font-size: 1.1rem !important;
    }
    
    .donation-form {
        padding: 20px 16px !important;
    }
    
    /* Bottoni amount in singola colonna */
    .donation-amounts .amount-btn {
        width: 100%;
    }
}

/* ====================
   TABLET (768px - 1024px)
   iPad, Android tablet
   ==================== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Container tablet */
    .container {
        max-width: 720px;
        margin: 0 auto;
        padding: 0 30px;
    }
    
    /* Grid 2 colonne su tablet */
    .home-buttons-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px 20px !important;
    }
    
    .donation-amounts {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Typography tablet */
    .home-title-main {
        font-size: 3rem !important;
    }
    
    .home-subtitle-block {
        font-size: 1.5rem !important;
    }
    
    /* Logo dimensione intermedia */
    .home-hero-logo {
        width: 350px !important;
        height: 350px !important;
    }
}

/* ====================
   DESKTOP (1025px - 1439px)
   Laptop, Desktop standard
   ==================== */
@media (min-width: 1025px) and (max-width: 1439px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* Grid 2 colonne ottimizzate */
    .home-buttons-grid {
        grid-template-columns: repeat(2, minmax(200px, 280px)) !important;
    }
}

/* ====================
   LARGE DESKTOP (≥ 1440px)
   Desktop grande, 4K
   ==================== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Typography grande */
    .home-title-main {
        font-size: 5.5rem !important;
    }
    
    .home-subtitle-block {
        font-size: 2.45rem !important;
    }
}

/* ====================
   LANDSCAPE MOBILE (orientamento orizzontale)
   ==================== */
@media (max-width: 767px) and (orientation: landscape) {
    /* Riduci padding verticale in landscape */
    .home-hero,
    section {
        padding-top: 60px;
        padding-bottom: 40px;
    }
    
    /* Logo più piccolo in landscape */
    .home-hero-logo {
        width: 200px !important;
        height: 200px !important;
    }
    
    /* Bottoni più compatti */
    .home-btn-main {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* ====================
   TOUCH DEVICE OPTIMIZATION
   ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Dispositivi touch: aumenta area cliccabile */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 18px;
    }
    
    /* Rimuovi hover effects su touch */
    .home-btn-main:hover,
    .btn:hover {
        transform: none;
    }
    
    /* Active state più evidente */
    .home-btn-main:active,
    .btn:active {
        transform: scale(0.97);
        opacity: 0.8;
    }
}

/* ====================
   PRINT MEDIA
   ==================== */
@media print {
    .return-arrow,
    .translate-widget,
    nav,
    .home-btn-main {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* ====================
   ACCESSIBILITY - REDUCE MOTION
   ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====================
   DARK MODE SUPPORT (se richiesto)
   ==================== */
@media (prefers-color-scheme: dark) {
    /* Opzionale: variabili per dark mode */
    :root {
        --bg-primary: #001122;
        --text-primary: #ffffff;
    }
}
