/* =================================================================
   FILE: assets/css/mobile.css
   VERSIONE: DEFINITIVA (Include Fix Hero Buttons + Pannello Utente)
   ================================================================= */

/* -----------------------------------------------------------------
   1. RESET GLOBALE & SICUREZZA
   ----------------------------------------------------------------- */
html, body {
    overflow-x: hidden; /* Blocca scroll orizzontale */
    width: 100%;
    min-width: 0;
    -webkit-text-size-adjust: 100%;
    padding-bottom: 70px; /* Spazio per la Navbar in basso */
}

/* Immagini e video fluidi */
img, video, iframe, .video-container {
    max-width: 100%;
    height: auto;
}

/* -----------------------------------------------------------------
   2. HEADER COMPATTO & NAVIGAZIONE
   ----------------------------------------------------------------- */
@media (max-width: 1024px) {
    .header {
        height: 60px;
        min-height: 60px;
        padding: 5px 15px;
        position: sticky;
        top: 0;
        z-index: 9990;
    }

    .header-inner {
        padding: 0;
        gap: 10px;
    }

    .logo img {
        height: 35px !important;
        width: auto !important;
        margin-top: 5px;
    }

    /* Nascondi elementi Desktop */
    .main-nav, 
    .user-area .welcome-message,
    .user-area .btn-auth,
    .theme-controls-container,
    #advanced-search-toggle {
        display: none !important;
    }

    /* Search Bar Mobile */
    .user-area {
        flex: 1;
        justify-content: flex-end;
        margin-left: 0;
    }
    #main-search-form {
        margin-right: 5px;
        flex: 1;
        max-width: 180px;
    }
    .search-form-container {
        padding: 2px 10px !important;
    }
    .search-input {
        font-size: 0.9rem !important;
    }

    /* Profilo Icona */
    .profile-controls-container {
        margin-left: 5px;
        gap: 8px;
    }
    .profile-avatar {
        width: 30px !important;
        height: 30px !important;
    }

    /* Menu a tendina posizionato per mobile */
    #profile-menu {
        position: fixed !important;
        top: 60px !important;
        right: 10px !important;
        width: 260px !important;
        max-height: 80vh;
        overflow-y: auto;
    }

    /* NAVBAR INFERIORE (Fissa in basso) */
    .mobile-nav-bar {
        display: flex !important;
        position: fixed;
        bottom: 0; left: 0; width: 100%; height: 60px;
        background: rgba(15, 15, 15, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid rgba(255,255,255,0.1);
        z-index: 9999;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }
    .mobile-nav-bar a.active {
        color: var(--color-accent);
    }
}

/* -----------------------------------------------------------------
   3. FIX HERO BUTTONS (Il problema dello Screenshot)
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Riduciamo l'altezza dell'Hero per dare spazio */
    .hero-carousel-container {
        height: 55vh; 
        min-height: 350px;
    }

    /* Nascondiamo il poster 3D laterale che ruba spazio */
    .hero-poster { display: none !important; }

    /* Centriamo il contenuto e lo adattiamo */
    .hero-slide .hero-content {
        max-width: 100%;
        padding: 0 15px;
        text-align: center;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-slide h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
        line-height: 1.1;
    }

    /* Wrapper per i bottoni (se non esiste, agisce sui bottoni stessi) */
    .hero-slide .hero-content > div,
    .hero-actions-row {
        display: flex;
        flex-direction: column; /* Impila i bottoni verticalmente */
        gap: 10px; /* Spazio tra i bottoni */
        width: 100%;
        align-items: center;
        margin-top: 10px;
    }

    /* STILE BOTTONI FIX */
    .hero-slide .hero-content .btn-watch-now, 
    .hero-slide .hero-content .btn-secondary-details,
    .btn-play-main,
    .anime-actions-bar .btn-primary {
        width: 80% !important; /* Larghezza quasi piena */
        max-width: 250px;
        padding: 12px 0 !important; /* Padding verticale maggiore */
        text-align: center;
        justify-content: center;
        margin: 0 !important; /* Reset margini */
        font-size: 1rem !important;
        flex-shrink: 0 !important; /* VIETA di schiacciarsi */
        white-space: nowrap;
    }
}

/* -----------------------------------------------------------------
   4. HOME & LISTE (Updated.php / Index.php)
   ----------------------------------------------------------------- */
@media (max-width: 900px) {
    /* Rimuove i margini dal pannello di vetro "Monolite" */
    .master-glass-panel {
        width: 100% !important;
        margin: 20px 0 0 !important;
        border-radius: 0 !important;
        border: none;
        box-shadow: none;
        background: rgba(18, 18, 18, 0.95); /* Più scuro su mobile */
    }

    /* Griglie Anime (Updated.php) */
    .updated-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 colonne fisse */
        gap: 10px !important;
    }
    
    .ep-card .ep-title { font-size: 0.9rem; }
    .ep-card .ep-category { font-size: 0.75rem; }
    
    /* Nasconde frecce caroselli (si usa il touch) */
    .scroll-button { display: none !important; }
    .carousel-wrapper { padding: 0 10px; }
}

/* -----------------------------------------------------------------
   5. DASHBOARD UTENTE (Profile.php)
   ----------------------------------------------------------------- */
@media (max-width: 900px) {
    /* Layout Colonna Singola */
    .dashboard-layout {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 20px;
    }

    /* Sidebar diventa un blocco superiore */
    .dashboard-sidebar {
        position: static;
        width: 100%;
        margin-bottom: 20px;
        padding: 20px;
    }

    /* Content */
    .dashboard-content {
        padding: 20px;
    }

    /* Griglia Form a 1 colonna */
    .form-grid { grid-template-columns: 1fr; }
    
    /* Card "Following" a 2 colonne */
    .following-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* -----------------------------------------------------------------
   6. WATCHLIST (Watchlist.php)
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
    .watchlist-header { padding: 20px; }
    .watchlist-header h1 { font-size: 1.8rem; }
    
    .watchlist-section { padding: 15px; }
    
    /* Nasconde le frecce di navigazione orizzontale */
    .nav-btn { display: none; }
    
    /* Card Watchlist più compatte */
    .wl-card {
        flex: 0 0 140px; /* Larghezza fissa minore */
    }
    .wl-poster { height: 200px; }
}

/* -----------------------------------------------------------------
   7. MESSAGGI & CHAT (Messages.php)
   ----------------------------------------------------------------- */
@media (max-width: 900px) {
    .chat-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 80vh; /* Occupa altezza schermo */
        margin: 10px 0;
        border-radius: 0;
    }

    /* Sidebar Chat (Lista Utenti) */
    .chat-sidebar {
        width: 100%;
        height: auto;
        max-height: 250px; /* Scrollabile se lunga */
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    /* Area Chat */
    .chat-main {
        flex: 1;
        height: 500px; /* Altezza fissa per area messaggi */
    }

    /* Nascondi dettagli superflui nella lista */
    .conv-preview, .conv-time { display: none; }
    .conversation-item { padding: 10px; }
}

/* -----------------------------------------------------------------
   8. SUPPORTO & TICKET (Ticket.php / Ticket_thread.php)
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
    .support-container { padding: 10px; margin-top: 20px; }
    .support-header { padding: 20px; }
    .support-header h1 { font-size: 1.5rem; }

    /* Lista Ticket */
    .ticket-list-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    .ticket-meta {
        margin-top: 10px;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 10px;
        width: 100%;
        justify-content: space-between;
    }

    /* Conversazione Ticket (Thread) */
    .main-content.panel-container { padding: 15px; } /* Wrapper esterno */
    
    #conversation-log {
        height: auto;
        max-height: 500px;
        padding: 10px;
    }
    
    .message-bubble {
        max-width: 90% !important; /* Bolle più larghe su mobile */
        min-width: auto;
    }
}

/* -----------------------------------------------------------------
   9. PLAYER (Player.php)
   ----------------------------------------------------------------- */
@media (max-width: 1200px) {
    .player-main { padding-top: 0; }
    
    /* Layout colonna singola */
    .player-flex-container {
        display: flex;
        flex-direction: column;
        padding: 10px 0;
        gap: 15px;
    }

    /* Riordino: Video -> Info -> Correlati -> Commenti */
    .player-column-left { order: 1; width: 100%; }
    .player-sidebar-right { order: 2; width: 100%; margin: 0; }
    .comments-area-center { order: 3; width: 100%; }

    /* Video a tutta larghezza */
    .video-container {
        border-radius: 0; 
        margin-bottom: 10px;
    }

    /* Sidebar Correlati Orizzontale Scrollabile */
    .sidebar-scrollable-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 15px;
        max-height: none;
    }
    .related-card-item {
        min-width: 200px;
        margin-right: 10px;
        flex-direction: row;
    }

    /* Nascondi elementi grafici pesanti */
    #player-guide-img-container { display: none !important; }
}

/* -----------------------------------------------------------------
   10. AUTH (Login/Register)
   ----------------------------------------------------------------- */
@media (max-width: 900px) {
    .auth-split-layout { flex-direction: column; }
    .auth-visual-side { display: none; } /* Via l'immagine laterale */
    .auth-form-side {
        width: 100%;
        padding: 30px 20px;
        box-shadow: none;
        border: none;
    }
}
/* -----------------------------------------------------------------
   11. FOOTER MOBILE (Fix Centratura & Testo Tagliato)
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
    .footer {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;  /* Centra i blocchi orizzontalmente */
        text-align: center !important;   /* Centra il testo dentro i blocchi */
        padding: 30px 15px 90px !important; /* 15px ai lati per evitare bordi attaccati */
        width: 100% !important;
        box-sizing: border-box;          /* Include il padding nella larghezza totale */
        min-height: auto;
    }
    
    .footer-links-col {
        width: 100%;
        text-align: center;
        margin-bottom: 30px;
        padding: 0;
    }
    
    .footer-col-title {
        text-align: center !important;
        border-bottom: none;
        padding-bottom: 5px;
    }
    
    .footer-nav-links {
        display: flex;
        flex-direction: column;
        align-items: center; /* Forza i link al centro */
        width: 100%;
    }

    .footer-link-item {
        text-align: center !important;
        padding: 5px 0;
        width: auto;
    }
    
    .footer-content-center {
        position: static !important; /* FONDAMENTALE: Annulla il posizionamento desktop */
        transform: none !important;  /* FONDAMENTALE: Annulla la traslazione desktop */
        width: 100% !important;
        margin: 0 auto 20px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .copyright-text {
        width: 100%;
        font-size: 0.85rem;
        line-height: 1.5;
        padding: 0 10px;        /* Margine di sicurezza */
        word-wrap: break-word;  /* Spezza le parole lunghe (email) se necessario */
        white-space: normal;    /* Forza l'a capo */
    }
    
    /* Nascondi la mascotte footer su mobile per pulizia */
    .footer-chibi {
        display: none !important;
    }
}