/**
 * responsive.css - Feuille de style responsive UNIVERSELLE
 * Fonctionne pour TOUT le site Nexus Connect :
 * - Social Connect
 * - Rencontres
 * - Forum
 * - Salons
 * - Boîte à outils
 * - Administration
 * 
 * Version 2.0.0 - Universelle
 */

/* ============================================
   RESET ET FONDATIONS
   ============================================ */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    min-width: 320px;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

input, textarea, select, button {
    font-size: 16px; /* Évite le zoom sur iOS */
    font-family: inherit;
    max-width: 100%;
}

/* ============================================
   NAVBAR RESPONSIVE (générique)
   ============================================ */
@media (max-width: 768px) {
    .navbar,
    .social-navbar {
        padding: 12px 15px !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .logo {
        font-size: 1.3rem !important;
    }
    
    .nav-actions,
    .user-menu {
        width: 100%;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .user-info {
        text-align: center !important;
        width: 100%;
        order: -1;
    }
    
    .nav-btn,
    .back-btn,
    .logout-btn,
    .admin-link,
    .forum-link,
    .rencontres-link,
    .pm-link {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Menu déroulant sur mobile : bottom sheet */
    .dropdown-menu,
    .dropdown-content {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        animation: slideUpMobile 0.3s ease-out !important;
    }
    
    @keyframes slideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

/* ============================================
   CONTAINERS (générique)
   ============================================ */
@media (max-width: 1024px) {
    .container,
    .social-container {
        padding: 20px 15px !important;
        max-width: 100% !important;
    }
}

@media (max-width: 640px) {
    .container,
    .social-container {
        padding: 15px 10px !important;
    }
}

/* Layout à grille : repasse en 1 colonne */
@media (max-width: 1024px) {
    .forum-layout,
    .messages-layout,
    .main-container {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar,
    .forum-sidebar,
    .conversations-sidebar {
        display: none !important;
    }
}

/* ============================================
   CARTES GÉNÉRIQUES
   ============================================ */
@media (max-width: 640px) {
    .card,
    .section,
    .post-card,
    .social-post,
    .tool-card,
    .user-card,
    .match-card,
    .category-card,
    .sidebar-card,
    .stat-card {
        padding: 15px !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }
    
    h1, .page-title { font-size: 1.5rem !important; }
    h2, .section-title { font-size: 1.2rem !important; }
    h3 { font-size: 1.05rem !important; }
    p { font-size: 0.95rem !important; }
}

/* ============================================
   GRILLES ADAPTATIVES
   ============================================ */
@media (max-width: 1024px) {
    .profiles-grid,
    .photos-grid,
    .communities-grid,
    .posts-grid,
    .users-grid,
    .tools-grid,
    .matches-list,
    .categories-grid,
    .ads-grid,
    .stats-grid,
    .stats-summary,
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}

@media (max-width: 640px) {
    .profiles-grid,
    .photos-grid,
    .communities-grid,
    .posts-grid,
    .users-grid,
    .tools-grid,
    .matches-list,
    .categories-grid,
    .ads-grid,
    .stats-grid,
    .stats-summary,
    .dashboard-grid,
    .forum-layout,
    .salons-grid,
    .featured-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* Grille 2 colonnes pour les petits éléments */
    .stats-grid.mini,
    .featured-grid.mini {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 400px) {
    .stats-grid,
    .featured-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   FORMULAIRES (générique)
   ============================================ */
@media (max-width: 640px) {
    .form-group,
    .social-form-group {
        margin-bottom: 15px !important;
    }
    
    .form-group label,
    .social-form-group label {
        font-size: 0.9rem !important;
        margin-bottom: 6px !important;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select,
    .social-input,
    .social-textarea,
    .social-select {
        padding: 14px 16px !important;
        font-size: 16px !important; /* Évite zoom iOS */
        border-radius: 12px !important;
        width: 100% !important;
    }
    
    .form-row,
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .form-actions,
    .actions {
        flex-direction: column-reverse !important;
        gap: 10px !important;
    }
    
    .form-actions .btn,
    .actions .btn {
        width: 100% !important;
        min-height: 48px;
        justify-content: center;
    }
    
    .btn {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
        min-height: 44px;
        border-radius: 10px !important;
    }
}

/* ============================================
   TABLES (Forum, Administration, etc.)
   ============================================ */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }
    
    table {
        min-width: 600px;
        font-size: 0.8rem !important;
    }
    
    th, td {
        padding: 10px 8px !important;
        white-space: nowrap;
    }
}

/* ============================================
   MESSAGES PRIVÉS (Social + Private_messages.php)
   ============================================ */
@media (max-width: 768px) {
    .messages-layout {
        grid-template-columns: 1fr !important;
        position: relative;
    }
    
    .conversations-sidebar {
        height: 100% !important;
        width: 100% !important;
    }
    
    .chat-area {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 999 !important;
        border-radius: 0 !important;
    }
    
    .chat-header {
        padding: 12px 15px !important;
    }
    
    .chat-avatar {
        width: 40px !important;
        height: 40px !important;
    }
    
    .messages-area {
        padding: 15px !important;
    }
    
    .message-bubble {
        max-width: 85% !important;
        font-size: 0.9rem !important;
    }
    
    .chat-input-area {
        padding: 12px 15px !important;
    }
    
    .chat-input {
        font-size: 16px !important;
        padding: 12px 15px !important;
    }
    
    .send-btn {
        width: 44px !important;
        height: 44px !important;
    }
}

/* ============================================
   CHAT SALONS (chat.php)
   ============================================ */
@media (max-width: 1024px) {
    .chat-section {
        width: 100% !important;
    }
    
    .users-section {
        width: 100% !important;
        height: 250px !important;
    }
}

@media (max-width: 640px) {
    .input-container {
        flex-direction: column !important;
        padding: 10px !important;
        gap: 8px !important;
    }
    
    .message-input {
        font-size: 16px !important;
        min-height: 44px;
    }
    
    .send-btn {
        width: 100% !important;
        justify-content: center;
    }
    
    .sticker-btn,
    .audio-record-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   MODALES (générique)
   ============================================ */
@media (max-width: 640px) {
    .modal-content,
    .edit-modal-content,
    .sticker-gift-menu,
    .user-context-menu {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px !important;
        border-radius: 16px !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-actions {
        flex-direction: column-reverse !important;
    }
    
    .modal-actions .btn {
        width: 100% !important;
    }
    
    /* Bottom sheet sur mobile */
    .modal.show {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    
    .modal.show .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
    }
}

/* ============================================
   IMAGES DANS LES POSTS (Social Connect)
   ============================================ */
@media (max-width: 640px) {
    .post-media img,
    .social-post-media img {
        max-height: 400px !important;
    }
    
    .post-media-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 3px !important;
    }
    
    .post-media-grid img {
        height: 150px !important;
    }
}

/* ============================================
   PROFIL (Social + Rencontres)
   ============================================ */
@media (max-width: 768px) {
    .profile-cover,
    .profile-cover-img {
        height: 150px !important;
    }
    
    .profile-header {
        padding: 20px 15px !important;
        margin-top: -60px !important;
        border-radius: 16px !important;
    }
    
    .profile-top {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 15px !important;
    }
    
    .profile-avatar {
        width: 100px !important;
        height: 100px !important;
        font-size: 2.5rem !important;
        margin-top: -60px !important;
    }
    
    .profile-username {
        font-size: 1.4rem !important;
    }
    
    .profile-name-row {
        justify-content: center !important;
    }
    
    .profile-stats {
        justify-content: center !important;
        gap: 15px !important;
        flex-wrap: wrap;
    }
    
    .profile-actions {
        justify-content: center !important;
        flex-direction: column;
    }
    
    .profile-actions .btn {
        width: 100%;
    }
    
    .profile-tabs {
        overflow-x: auto !important;
        scrollbar-width: none;
        padding: 5px !important;
    }
    
    .profile-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .profile-tab {
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
        white-space: nowrap;
    }
}

/* ============================================
   BOÎTE À OUTILS (bao.php)
   ============================================ */
@media (max-width: 768px) {
    .search-input {
        font-size: 16px !important;
    }
    
    .category-nav {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 5px;
        scrollbar-width: none;
    }
    
    .category-nav::-webkit-scrollbar {
        display: none;
    }
    
    .category-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ============================================
   FORUM
   ============================================ */
@media (max-width: 768px) {
    .topic-header {
        flex-direction: column !important;
        text-align: center;
        gap: 10px;
    }
    
    .topic-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .topic-meta {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .reply-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .editor-toolbar {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .editor-toolbar button {
        padding: 6px 8px !important;
    }
    
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination a, .pagination span {
        padding: 8px 12px !important;
        font-size: 0.85rem;
    }
}

/* ============================================
   RENCONTRES
   ============================================ */
@media (max-width: 768px) {
    .profile-photo {
        height: 250px !important;
    }
    
    .profile-name {
        font-size: 1.1rem !important;
    }
    
    .hero-title {
        font-size: 1.8rem !important;
    }
    
    .hero-icon {
        font-size: 3rem !important;
    }
    
    .chat-header {
        padding: 10px 12px !important;
    }
    
    .chat-user-name {
        font-size: 0.95rem;
    }
    
    .match-item {
        flex-direction: column;
        text-align: center;
    }
    
    .match-header {
        justify-content: center;
    }
}

/* ============================================
   MENU DÉROULANT
   ============================================ */
@media (max-width: 768px) {
    .dropdown-toggle {
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================
   TABLES - ALTERNATIVE CARDS
   ============================================ */
@media (max-width: 640px) {
    /* Transformer les tables en cards */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive th,
    .table-responsive td {
        display: block;
        width: 100%;
    }
    
    .table-responsive thead {
        display: none;
    }
    
    .table-responsive tr {
        background: #1e293b;
        margin-bottom: 12px;
        border-radius: 12px;
        padding: 15px;
        border: 1px solid #334155;
    }
    
    .table-responsive td {
        padding: 8px 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }
    
    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #60a5fa;
        text-align: left;
        margin-right: 15px;
    }
}

/* ============================================
   UTILITAIRES
   ============================================ */
@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .text-center-mobile { text-align: center !important; }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   IMPRESSION
   ============================================ */
@media print {
    .navbar, .dropdown, .chat-input-area, 
    .post-actions, .create-post, .sidebar {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}