/*
=================================================================
FICHIER: assets/css/responsive.css
Styles responsive pour application mobile Fylly
Inspiré des maquettes fournies
=================================================================
*/

/* =================================================================
   RESET ET BASE MOBILE
================================================================= */

/* Masquer les scrollbars sur mobile pour un look d'app */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* Éviter le zoom sur les inputs mobiles */
@media screen and (max-width: 768px) {
    input[type="text"], 
    input[type="email"], 
    input[type="password"], 
    input[type="tel"], 
    input[type="url"], 
    input[type="search"], 
    textarea, 
    select {
        font-size: 16px !important;
        transform: scale(1);
    }
}

/* =================================================================
   LAYOUT MOBILE GENERAL
================================================================= */

@media (max-width: 768px) {
    /* Body mobile */
    body {
        padding-bottom: 90px; /* Espace pour la navbar fixe */
        background: #F8FAFC;
        overflow-x: hidden;
    }
    
    /* Container mobile */
    .container, .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Marges et paddings adaptés mobile */
    .fylly-card {
        border-radius: 0;
        margin-bottom: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        border-bottom: 1px solid var(--border-color);
    }
}

/* =================================================================
   HEADER MOBILE (Style App)
================================================================= */

@media (max-width: 768px) {
    .fylly-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1050;
        padding: 0.5rem 1rem;
        background: var(--gradient-primary);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        height: 60px;
        display: flex;
        align-items: center;
    }
    
    .fylly-header .container {
        padding: 0;
        width: 100%;
    }
    
    .fylly-header .row {
        width: 100%;
        margin: 0;
        align-items: center;
    }
    
    /* Logo mobile */
    .fylly-logo {
        font-size: 1.5rem;
        font-weight: 700;
        color: white;
    }
    
    /* Barre de recherche mobile cachée dans header */
    .fylly-header .d-none.d-md-block {
        display: none !important;
    }
    
    /* Menu utilisateur mobile */
    .fylly-header .dropdown-toggle {
        border: none;
        background: none;
        padding: 0.25rem;
    }
    
    .fylly-header .dropdown-toggle img {
        width: 32px;
        height: 32px;
        border: 2px solid rgba(255, 255, 255, 0.3);
    }
    
    /* Notifications et messages en header */
    .fylly-header .position-relative a {
        color: white;
        font-size: 1.2rem;
        padding: 0.5rem;
    }
    
    .fylly-header .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }
}

/* =================================================================
   NAVIGATION MOBILE FIXE (Bottom Tab Bar)
================================================================= */

@media (max-width: 768px) {
    .fylly-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: white;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        height: 70px;
        padding: 0.5rem 0;
    }
    
    .fylly-nav .container {
        height: 100%;
        padding: 0;
    }
    
    .fylly-nav .row {
        height: 100%;
        margin: 0;
        align-items: center;
    }
    
    /* Items de navigation mobile */
    .fylly-nav .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        text-decoration: none;
        padding: 0.25rem;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
        height: 100%;
        position: relative;
    }
    
    .fylly-nav .nav-link i {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
    
    .fylly-nav .nav-link small {
        font-size: 0.7rem;
        font-weight: 500;
        line-height: 1;
    }
    
    .fylly-nav .nav-link.active {
        color: var(--primary-color);
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    }
    
    .fylly-nav .nav-link.active::before {
        content: '';
        position: absolute;
        top: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 3px;
        background: var(--gradient-primary);
        border-radius: 0 0 3px 3px;
    }
    
    /* Badge sur navigation mobile */
    .fylly-nav .position-relative .badge {
        position: absolute;
        top: 0.2rem;
        right: 0.8rem;
        font-size: 0.6rem;
        min-width: 1rem;
        height: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* =================================================================
   CONTENU PRINCIPAL MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Ajustement pour header fixe */
    .container-fluid.mt-4 {
        margin-top: 70px !important;
        padding: 0;
    }
    
    /* Masquer sidebars sur mobile */
    .col-lg-3.d-none.d-lg-block {
        display: none !important;
    }
    
    /* Contenu principal prend toute la largeur */
    .col-lg-6 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        padding: 0;
    }
    
    /* Espacement des éléments */
    .mb-4 {
        margin-bottom: 0 !important;
    }
}

/* =================================================================
   FEED MOBILE (Style App)
================================================================= */

@media (max-width: 768px) {
    /* Formulaire de création rapide */
    .fylly-card:first-child {
        border-radius: 0;
        border-top: none;
        padding: 1rem;
        background: white;
        margin-bottom: 0.5rem;
    }
    
    /* Posts mobile */
    .post-card {
        border-radius: 0;
        margin-bottom: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        box-shadow: none;
        background: white;
        border-bottom: 8px solid #F8FAFC;
    }
    
    .post-header {
        padding: 1rem 1rem 0.5rem;
    }
    
    .post-content {
        padding: 0 1rem 0.5rem;
    }
    
    .post-actions {
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--border-color);
        justify-content: space-around;
    }
    
    .post-action {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
    }
    
    .post-action:hover {
        background: rgba(139, 92, 246, 0.1);
    }
    
    /* Avatar dans les posts */
    .post-avatar {
        width: 40px;
        height: 40px;
    }
    
    /* Images dans les posts */
    .post-image {
        width: calc(100% + 2rem);
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        margin-top: 0.5rem;
    }
}

/* =================================================================
   PROFILS MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Profil individuel mobile */
    .profile-card {
        border-radius: 0;
        margin-bottom: 0;
        box-shadow: none;
    }
    
    .profile-header {
        padding: 2rem 1rem 1rem;
        background: var(--gradient-primary);
        position: relative;
    }
    
    /* Bouton retour sur profil */
    .profile-header::before {
        content: '\f104'; /* Flèche gauche Font Awesome */
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        top: 1rem;
        left: 1rem;
        color: white;
        font-size: 1.2rem;
        cursor: pointer;
    }
    
    .profile-avatar {
        width: 100px;
        height: 100px;
        border: 3px solid white;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    
    .profile-actions {
        padding: 1rem;
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .profile-actions .btn {
        flex: 1;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        border-radius: 1rem;
    }
    
    .profile-info {
        padding: 1rem;
    }
    
    .profile-info-item {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .profile-info-item:last-child {
        border-bottom: none;
    }
}

/* =================================================================
   FORMULAIRES MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Pages auth mobile fullscreen */
    .auth-container {
        min-height: 100vh;
        padding: 0;
        align-items: stretch;
    }
    
    .auth-card {
        border-radius: 0;
        width: 100%;
        max-width: none;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin: 0;
    }
    
    .auth-header {
        padding: 2rem 1.5rem 1.5rem;
    }
    
    .auth-body {
        padding: 1rem 1.5rem 2rem;
        flex: 1;
    }
    
    .auth-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 1rem;
    }
    
    .auth-title {
        font-size: 1.75rem;
    }
    
    /* Formulaires responsive */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-control {
        padding: 1rem;
        font-size: 1rem;
        border-radius: 1rem;
    }
    
    .btn-auth {
        padding: 1rem;
        font-size: 1.1rem;
        border-radius: 1rem;
        margin-top: 1rem;
    }
}

/* =================================================================
   MESSAGES MOBILE
================================================================= */

@media (max-width: 768px) {
    .messages-container {
        border-radius: 0;
        height: calc(100vh - 140px); /* Header + navbar */
        margin-bottom: 0;
    }
    
    .messages-header {
        padding: 1rem;
        border-radius: 0;
        position: relative;
    }
    
    .messages-header::before {
        content: '\f104';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-color);
        font-size: 1.2rem;
        cursor: pointer;
    }
    
    .messages-list {
        padding: 0.5rem;
    }
    
    .message-item {
        margin-bottom: 1rem;
    }
    
    .message-content {
        max-width: 85%;
        padding: 0.75rem 1rem;
        border-radius: 1.2rem;
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    .message-input {
        padding: 1rem;
        background: white;
        border-top: 1px solid var(--border-color);
    }
    
    .message-input .form-control {
        border-radius: 2rem;
        padding: 0.75rem 1rem;
        border: 1px solid var(--border-color);
    }
    
    .message-input .btn {
        border-radius: 50%;
        width: 45px;
        height: 45px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* =================================================================
   NOTIFICATIONS MOBILE
================================================================= */

@media (max-width: 768px) {
    .notification-item {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        margin-bottom: 0;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        background: white;
    }
    
    .notification-item:hover {
        transform: none;
        background: #F8FAFC;
    }
    
    .notification-item.unread {
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(236, 72, 153, 0.05) 100%);
    }
}

/* =================================================================
   MODAL ET OVERLAY MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Modals en fullscreen */
    .modal-dialog {
        margin: 0;
        height: 100vh;
        max-width: none;
        width: 100%;
    }
    
    .modal-content {
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-body {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 1rem;
        border-top: 1px solid var(--border-color);
    }
}

/* =================================================================
   ANIMATIONS MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Animation de navigation */
    .fylly-nav .nav-link {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .fylly-nav .nav-link:active {
        transform: scale(0.95);
    }
    
    /* Animation des posts */
    .post-card {
        transition: all 0.3s ease;
    }
    
    /* Pull to refresh animation */
    @keyframes pullToRefresh {
        0% { transform: translateY(-50px); opacity: 0; }
        50% { transform: translateY(-25px); opacity: 0.5; }
        100% { transform: translateY(0); opacity: 1; }
    }
    
    .pull-to-refresh {
        animation: pullToRefresh 0.5s ease-out;
    }
    
    /* Haptic feedback simulation */
    .btn:active, .post-action:active, .nav-link:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* =================================================================
   CARTE INTERACTIVE MOBILE (Vue Globale)
================================================================= */

@media (max-width: 768px) {
    .map-container {
        position: relative;
        height: calc(100vh - 200px);
        width: 100%;
        border-radius: 0;
        overflow: hidden;
    }
    
    .map-toggle {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000;
        display: flex;
        background: white;
        border-radius: 2rem;
        padding: 0.25rem;
        box-shadow: var(--shadow-lg);
    }
    
    .map-toggle .btn {
        flex: 1;
        border-radius: 1.5rem;
        padding: 0.75rem 1.5rem;
        font-weight: 600;
        border: none;
        transition: all 0.3s ease;
    }
    
    .map-toggle .btn.active {
        background: var(--gradient-primary);
        color: white;
        transform: scale(1.05);
    }
    
    /* Profils sur la carte */
    .map-profile {
        position: absolute;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 3px solid white;
        box-shadow: var(--shadow-md);
        cursor: pointer;
        transition: all 0.3s ease;
        z-index: 100;
    }
    
    .map-profile:hover {
        transform: scale(1.2);
        z-index: 200;
        box-shadow: var(--shadow-xl);
    }
    
    .map-profile.parrain {
        border-color: var(--primary-color);
    }
    
    .map-profile.filleul {
        border-color: var(--secondary-color);
    }
}

/* =================================================================
   SAFE AREA (iPhone X+)
================================================================= */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        body {
            padding-bottom: calc(90px + env(safe-area-inset-bottom));
        }
        
        .fylly-nav {
            padding-bottom: env(safe-area-inset-bottom);
            height: calc(70px + env(safe-area-inset-bottom));
        }
        
        .fylly-header {
            padding-top: env(safe-area-inset-top);
            height: calc(60px + env(safe-area-inset-top));
        }
    }
}

/* =================================================================
   DARK MODE SUPPORT (Bonus)
================================================================= */

@media (prefers-color-scheme: dark) and (max-width: 768px) {
    body {
        background: #1a1a1a;
        color: white;
    }
    
    .fylly-card, .post-card {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .fylly-nav {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .form-control {
        background: #3a3a3a;
        border-color: #4a4a4a;
        color: white;
    }
}

/* =================================================================
   PERFORMANCE MOBILE
================================================================= */

@media (max-width: 768px) {
    /* Optimisations performance */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .fylly-card, .post-card {
        will-change: transform;
        backface-visibility: hidden;
    }
    
    /* Scroll smooth */
    html {
        scroll-behavior: smooth;
    }
    
    /* Optimisation des images */
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    .post-image, .profile-avatar {
        will-change: transform;
        backface-visibility: hidden;
    }
}

@media (max-width: 768px) {
    /* OVERRIDE de la règle qui cache les dropdowns des commentaires */
    .comment-item .dropdown {
        opacity: 1 !important; /* Force toujours visible sur mobile */
        display: flex !important;
        margin-left: auto !important;
        margin-right: 8px !important;
    }
    
    .comment-item .dropdown .btn {
        color: #6c757d !important;
        background: rgba(108, 117, 125, 0.15) !important;
        border: 1px solid rgba(108, 117, 125, 0.2) !important;
        border-radius: 50% !important;
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        visibility: visible !important;
    }
    
    .comment-item .dropdown .btn i {
        font-size: 14px !important;
        opacity: 1 !important;
        color: #6c757d !important;
        display: block !important;
    }
}