/* ========================================
   THEME VARIABLES - BLEU
   ======================================== */
:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a1a;
    --bg-secondary: #0d1b2a;
    --bg-card: #1a2a3e;
    --bg-card-hover: #1e3a5f;
    --bg-input: #0d1b2a;
    --bg-input-focus: #1a2a4e;
    --bg-hover: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f0f0ff;
    --text-secondary: #a0b4c8;
    --text-muted: #5a7a8a;
    --text-inverse: #ffffff;
    
    --border-color: rgba(255, 255, 255, 0.05);
    --border-color-strong: rgba(255, 255, 255, 0.1);
    
    --accent-primary: #1a6bcc;
    --accent-secondary: #4a9eff;
    --accent-gradient: linear-gradient(135deg, #0a3d7a 0%, #1a6bcc 40%, #4a9eff 100%);
    --accent-gradient-2: linear-gradient(135deg, #0a3d7a 0%, #1a6bcc 100%);
    --accent-gradient-3: linear-gradient(135deg, #1a6bcc 0%, #4a9eff 100%);
    --accent-gradient-hover: linear-gradient(135deg, #0a3d7a 0%, #1a6bcc 30%, #5aaeff 100%);
    
    --status-online: #00b894;
    --status-offline: #636e72;
    --status-idle: #fdcb6e;
    --status-danger: #ff7675;
    --status-success: #00b894;
    --status-warning: #fdcb6e;
    --danger-gradient: linear-gradient(135deg, #ff7675 0%, #e17055 100%);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 40px rgba(26, 107, 204, 0.2);
    --shadow-glow-danger: 0 0 40px rgba(255, 118, 117, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --header-height: 60px;
    --input-height: 64px;
    --sidebar-width: 320px;
    --private-width: 400px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light Theme - Bleu clair */
[data-theme="light"] {
    --bg-primary: #e8f0fe;
    --bg-secondary: #ffffff;
    --bg-card: #d4e4f7;
    --bg-card-hover: #c0d8f0;
    --bg-input: #eef4fa;
    --bg-input-focus: #dce8f5;
    --bg-hover: rgba(0, 0, 0, 0.04);
    
    --text-primary: #0a1a2e;
    --text-secondary: #2a4a6a;
    --text-muted: #6a8aaa;
    --text-inverse: #ffffff;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-strong: rgba(0, 0, 0, 0.15);
    
    --accent-primary: #1a6bcc;
    --accent-secondary: #4a9eff;
    --accent-gradient: linear-gradient(135deg, #0a3d7a 0%, #1a6bcc 40%, #4a9eff 100%);
    --accent-gradient-hover: linear-gradient(135deg, #0a3d7a 0%, #1a6bcc 30%, #5aaeff 100%);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 40px rgba(26, 107, 204, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    transition: background 0.4s ease, color 0.4s ease;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* ========================================
   SPLASH SCREEN
   ======================================== */
#splashScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#splashScreen.fade-out {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.splash-content {
    text-align: center;
    animation: splashPulse 2s ease-in-out infinite;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.splash-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 30px;
}

.splash-icon {
    font-size: 48px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 60px rgba(26, 107, 204, 0.3);
}

.splash-title {
    font-size: 42px;
    font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.splash-loader {
    width: 200px;
    height: 3px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto 16px;
}

.loader-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    animation: loadingBar 1.5s ease-in-out infinite;
}

@keyframes loadingBar {
    0% { width: 0; transform: translateX(-100%); }
    50% { width: 100%; transform: translateX(0); }
    100% { width: 0; transform: translateX(100%); }
}

.splash-sub {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

/* ========================================
   APP LAYOUT
   ======================================== */
#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-primary);
    opacity: 0;
    transition: opacity 0.6s ease, background 0.4s ease;
    overflow: hidden;
}

#app.visible {
    opacity: 1;
}

/* ========================================
   SIDEBAR
   ======================================== */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow: hidden;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-height);
    flex-shrink: 0;
    gap: 8px;
    transition: border-color 0.4s ease;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(26, 107, 204, 0.3);
    flex-shrink: 0;
}

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

.logo-text-wrapper {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-size: 18px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.logo-sub {
    font-size: 8px;
    font-weight: 600;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ========================================
   THEME TOGGLE BUTTON - FIXED BOTTOM LEFT
   ======================================== */
.theme-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 50px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 30px rgba(26, 107, 204, 0.2);
    border-color: var(--accent-primary);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn i {
    font-size: 18px;
    transition: transform 0.6s ease;
}

.theme-toggle-btn:hover i {
    transform: rotate(30deg);
}

.theme-toggle-btn .theme-toggle-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

[data-theme="light"] .theme-toggle-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="light"] .theme-toggle-btn:hover {
    border-color: var(--accent-primary);
}

/* ========================================
   BOUTON DE PROFIL DANS LE HEADER
   ======================================== */
.btn-profile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-profile-header:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(26, 107, 204, 0.15);
}

.btn-profile-header:active {
    transform: scale(0.97);
}

.profile-avatar-header {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name-header {
    font-size: 13px;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-header {
    display: none !important;
}

/* ========================================
   AUTH HEADER BUTTONS
   ======================================== */
.auth-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 8px 16px 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.auth-header-buttons .btn-auth-header {
    padding: 8px 20px;
    border: none;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-header-buttons .btn-auth-header.btn-login {
    background: var(--accent-gradient);
    color: white;
}

.auth-header-buttons .btn-auth-header.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(26, 107, 204, 0.3);
}

.auth-header-buttons .btn-auth-header.btn-register {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.auth-header-buttons .btn-auth-header.btn-register:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.auth-header-buttons .btn-auth-header.btn-logout {
    background: var(--danger-gradient);
    color: white;
    border: none;
}

.auth-header-buttons .btn-auth-header.btn-logout:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 118, 117, 0.3);
}

/* ========================================
   SIDEBAR BODY
   ======================================== */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    min-height: 0;
}

/* ========================================
   SEARCH BAR
   ======================================== */
.search-wrapper {
    margin-bottom: 12px;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    padding: 0 12px;
}

.search-bar:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 107, 204, 0.15);
    background: var(--bg-input-focus);
}

.search-icon {
    color: var(--text-muted);
    font-size: 14px;
}

.search-bar input {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
    font-size: 16px;
}

.search-clear:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

/* ========================================
   SIDEBAR TABS
   ======================================== */
.sidebar-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 4px;
    transition: background 0.4s ease;
}

.tab-btn {
    padding: 8px 4px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 11px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    text-align: center;
    min-height: 44px;
}

.tab-btn i {
    font-size: 16px;
}

.tab-btn span:not(.tab-badge) {
    font-size: 9px;
    line-height: 1.2;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.tab-btn:active {
    transform: scale(0.95);
}

.tab-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(26, 107, 204, 0.3);
}

.tab-btn.active:hover {
    box-shadow: 0 6px 24px rgba(26, 107, 204, 0.4);
    transform: translateY(-1px);
}

.tab-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    min-width: 16px;
    text-align: center;
}

.tab-btn.active .tab-badge {
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn[data-tab="private"] .tab-badge {
    background: var(--status-danger);
    color: white;
}

.tab-btn.active[data-tab="private"] .tab-badge {
    background: rgba(255, 255, 255, 0.4);
    color: white;
}

.tab-content {
    display: none;
    animation: fadeSlide 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   USER ITEMS
   ======================================== */
.user-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
    border: 1px solid transparent;
}

.user-item:hover {
    background: var(--bg-card);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.user-item:active {
    transform: scale(0.98);
}

.user-item .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.user-item .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-item .user-avatar .status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.user-item .user-avatar .status-dot.online {
    background: var(--status-online);
}
.user-item .user-avatar .status-dot.idle {
    background: var(--status-idle);
}
.user-item .user-avatar .status-dot.offline {
    background: var(--status-offline);
}

.user-item .user-info {
    flex: 1;
    min-width: 0;
}

.user-item .user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item .user-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item .user-status-text {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(0, 184, 148, 0.15);
    color: var(--status-online);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========================================
   CONVERSATIONS PRIVÉES - BADGES
   ======================================== */
.unread-badge {
    display: inline-block;
    background: var(--status-danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    animation: badgePulse 2s ease-in-out infinite;
}

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

.private-conversation-item {
    border-left: 2px solid transparent;
    transition: all 0.3s ease;
}

.private-conversation-item.has-unread {
    border-left: 3px solid var(--accent-primary);
    background: rgba(26, 107, 204, 0.05);
}

.private-conversation-item .conversation-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
}

.private-conversation-item .user-name {
    display: flex;
    align-items: center;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.private-conversation-item {
    animation: slideIn 0.3s ease;
}

/* ========================================
   AVATAR LIGHTBOX
   ======================================== */
.avatar-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px);
}

.avatar-lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 16px;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.1);
}

.avatar-lightbox .avatar-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.avatar-lightbox .avatar-lightbox-close:hover {
    transform: rotate(90deg);
    background: rgba(255,255,255,0.1);
}

.avatar-lightbox .avatar-name {
    margin-top: 16px;
    color: rgba(255,255,255,0.8);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
}

.user-info-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 32px;
    color: white;
    border: 3px solid rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}

.user-info-avatar:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
}

.user-info-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-info-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.user-info-header .user-info-name {
    font-size: 20px;
    font-weight: 700;
}

/* ========================================
   MAIN CHAT
   ======================================== */
#mainChat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
    height: 100%;
    overflow: hidden;
    transition: background 0.4s ease;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    min-height: var(--header-height);
    flex-shrink: 0;
    gap: 8px;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.chat-room-info {
    min-width: 0;
    flex: 1;
}

.chat-room-info h2 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--status-online);
}

.status-dot.pulse {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.chat-header-right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ========================================
   BOUTONS PRINCIPAUX - BLEU
   ======================================== */
.btn-primary {
    padding: 8px 16px;
    border: none;
    border-radius: 50px;
    background: var(--accent-gradient);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26, 107, 204, 0.3);
    background: var(--accent-gradient-hover);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-glow {
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(26, 107, 204, 0.2); }
    50% { box-shadow: 0 0 40px rgba(26, 107, 204, 0.4); }
}

.btn-secondary {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    
}

.btn-secondary:active {
    
}

/* Messages Container */
#messagesContainer {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-height: 0;
    transition: background 0.4s ease;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 14px;
}
.auth-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 8px 16px 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 52px; /* Ajouté pour maintenir la hauteur */
}
/* ========================================
   MESSAGES
   ======================================== */
.message {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    max-width: 80%;
    animation: messageIn 0.3s ease;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: background 0.4s ease, border-color 0.4s ease;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.own {
    align-self: flex-end;
    background: rgba(26, 107, 204, 0.15);
    border: 1px solid rgba(26, 107, 204, 0.2);
}

.message .message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}

.message .message-sender {
    font-weight: 600;
    color: var(--accent-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.message .message-sender:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

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

.message .message-content {
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}
/* Ajouter dans style.css */

.btn-profile-centered {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-decoration: none;
}

.btn-profile-centered:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(26, 107, 204, 0.15);
}

.btn-profile-centered:active {
    transform: scale(0.98);
}

.profile-avatar-centered {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar-centered img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-info-centered {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-status {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background: var(--status-online);
}
/* Ajouter dans style.css */
.profile-status .status-indicator.offline {
    background: var(--status-offline);
}

.profile-status .status-indicator.guest {
    background: #fdcb6e;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-secondary);
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

.typing-text {
    color: var(--text-muted);
    font-size: 13px;
}

/* ========================================
   CHAT INPUT
   ======================================== */
.chat-input-wrapper {
    padding: 8px 12px calc(8px + var(--safe-bottom));
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    padding: 4px;
    position: relative;
}

.chat-input:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 107, 204, 0.15);
    background: var(--bg-input-focus);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.9);
}

.btn-icon.active-emoji {
    color: var(--accent-primary);
    background: rgba(26, 107, 204, 0.15);
}

.input-field {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.input-field input {
    width: 100%;
    padding: 8px 4px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    font-family: var(--font);
    min-height: 36px;
}

.input-field input::placeholder {
    color: var(--text-muted);
}

.input-char-counter {
    font-size: 9px;
    color: var(--text-muted);
    text-align: right;
    padding-right: 4px;
    margin-top: 1px;
}

.btn-send {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.btn-send::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-send:hover::before {
    left: 100%;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(26, 107, 204, 0.4);
    background: var(--accent-gradient-hover);
}

.btn-send:active {
    transform: scale(0.9);
}

/* ========================================
   EMOJI PICKER
   ======================================== */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
    animation: emojiPop 0.2s ease;
}

.emoji-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.emoji-picker-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.emoji-picker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    transition: var(--transition);
}

.emoji-picker-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.emoji-picker-grid .emoji-option {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.emoji-picker-grid .emoji-option:hover {
    background: var(--bg-card);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.emoji-picker-grid .emoji-option:active {
    transform: scale(0.9);
}

.emoji-picker-grid .emoji-option-category {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 0 2px 0;
    border-bottom: 1px solid var(--border-color);
    margin-top: 4px;
}

@keyframes emojiPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
/* ========================================
   MESSAGE IMAGE WRAPPER
   ======================================== */
.message-image-wrapper {
    max-width: 100%;
    margin-top: 4px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
}

.message-image {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    transition: transform 0.3s ease;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
}

/* ========================================
   IMAGE LIGHTBOX
   ======================================== */
.image-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.image-lightbox-overlay img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.1);
    user-select: none;
}

.image-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.image-lightbox-close:hover {
    transform: rotate(90deg);
    background: rgba(255,255,255,0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .message-image {
        max-height: 200px;
    }
    .image-lightbox-overlay img {
        max-width: 95vw;
        max-height: 75vh;
    }
    .image-lightbox-close {
        top: -40px;
        font-size: 26px;
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    .message-image {
        max-height: 160px;
    }
    .image-lightbox-overlay img {
        max-width: 98vw;
        max-height: 70vh;
        border-radius: 8px;
    }
}
/* ========================================
   FILE PREVIEW
   ======================================== */
.file-preview {
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.file-preview-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.file-preview-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.file-preview-name {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
    flex-shrink: 0;
}

.file-preview-remove:hover {
    background: rgba(255, 118, 117, 0.2);
    color: var(--status-danger);
}

/* ========================================
   PRIVATE CHAT
   ======================================== */
#privateChat {
    width: var(--private-width);
    min-width: var(--private-width);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    height: 100%;
    overflow: hidden;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.private-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    min-height: var(--header-height);
    flex-shrink: 0;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.btn-back {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.btn-back:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateX(-2px);
}

.btn-back:active {
    transform: translateX(-2px) scale(0.9);
}

.private-user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.private-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.private-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.private-user-details {
    flex: 1;
    min-width: 0;
}

.private-user-details h3 {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.private-status {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.private-status .status-dot.small {
    width: 6px;
    height: 6px;
}

.private-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-call {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: rgba(0, 184, 148, 0.15);
    color: var(--status-online);
}

.btn-call:hover {
    background: rgba(0, 184, 148, 0.3);
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.2);
}

.btn-call:active {
    transform: scale(0.9);
}

.btn-video {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: rgba(26, 107, 204, 0.15);
    color: var(--accent-primary);
}

.btn-video:hover {
    background: rgba(26, 107, 204, 0.3);
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(26, 107, 204, 0.2);
}

.btn-video:active {
    transform: scale(0.9);
}

#privateMessagesContainer {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    min-height: 0;
}

#privateMessages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.private-message {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    max-width: 80%;
    animation: messageIn 0.3s ease;
    transition: background 0.4s ease;
}

.private-message.sent {
    align-self: flex-end;
    background: rgba(26, 107, 204, 0.15);
    border: 1px solid rgba(26, 107, 204, 0.2);
}

.private-message.received {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.private-message .message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* ========================================
   VIDEO CALL OVERLAY
   ======================================== */
#videoCallOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    animation: fadeIn 0.4s ease;
}

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

.video-call-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-remote-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.video-remote {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-remote-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, var(--bg-secondary), var(--bg-primary));
}

.placeholder-content {
    text-align: center;
}

/* Anneau d'appel unique — centré sur l'avatar */
.placeholder-ring {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Un seul cercle qui s'étend depuis le centre de l'avatar */
.ring-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    border: 2px solid rgba(74, 158, 255, 0.55);
    box-shadow:
        0 0 0 0 rgba(26, 107, 204, 0.25),
        inset 0 0 20px rgba(74, 158, 255, 0.08);
    animation: callRingExpand 2.4s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
    pointer-events: none;
    z-index: 0;
}

/* Ancien call-ring désactivé (compat JS) */
.call-ring {
    display: none !important;
}

@keyframes callRingExpand {
    0% {
        transform: translate(-50%, -50%) scale(0.92);
        opacity: 0.9;
        border-color: rgba(74, 158, 255, 0.7);
        box-shadow:
            0 0 0 0 rgba(26, 107, 204, 0.35),
            inset 0 0 16px rgba(74, 158, 255, 0.12);
    }
    70% {
        opacity: 0.25;
        border-color: rgba(74, 158, 255, 0.2);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.85);
        opacity: 0;
        border-color: rgba(74, 158, 255, 0);
        box-shadow:
            0 0 0 24px rgba(26, 107, 204, 0),
            inset 0 0 0 transparent;
    }
}

.placeholder-avatar {
    font-size: 48px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    overflow: hidden;
    border: 3px solid rgba(74, 158, 255, 0.45);
    box-shadow:
        0 0 0 6px rgba(26, 107, 204, 0.12),
        0 12px 40px rgba(26, 107, 204, 0.35),
        0 0 60px rgba(74, 158, 255, 0.15);
    animation: avatarSoftGlow 2.4s ease-in-out infinite;
}

.placeholder-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

@keyframes avatarSoftGlow {
    0%, 100% {
        box-shadow:
            0 0 0 6px rgba(26, 107, 204, 0.12),
            0 12px 40px rgba(26, 107, 204, 0.35),
            0 0 50px rgba(74, 158, 255, 0.12);
        border-color: rgba(74, 158, 255, 0.4);
    }
    50% {
        box-shadow:
            0 0 0 10px rgba(26, 107, 204, 0.18),
            0 16px 48px rgba(26, 107, 204, 0.4),
            0 0 70px rgba(74, 158, 255, 0.22);
        border-color: rgba(74, 158, 255, 0.65);
    }
}

.placeholder-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.placeholder-status {
    font-size: 14px;
    color: var(--text-secondary);
    animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.video-local-wrapper {
    position: absolute;
    bottom: 100px;
    right: 16px;
    width: 180px;
    height: 130px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 10;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}

.video-local-wrapper:hover {
    transform: scale(1.04);
    border-color: var(--accent-primary);
}

.video-local {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* miroir pour vue naturelle */
}

.video-local-overlay {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.video-call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 20;
    width: 90%;
    max-width: 500px;
}

.call-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 50px;
    width: 100%;
}

.call-info-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.call-duration {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.call-divider {
    color: var(--text-muted);
}

.call-partner {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-quality {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--status-online);
}

.call-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-call-control {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-call-control::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.6s ease;
}

.btn-call-control:hover::before {
    left: 100%;
}

.btn-call-control:hover {
    transform: scale(1.08);
}

.btn-call-control:active {
    transform: scale(0.92);
}

.btn-call-control.active {
    background: rgba(0, 184, 148, 0.3);
    color: var(--status-online);
}

.btn-call-control.active:hover {
    background: rgba(0, 184, 148, 0.4);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.2);
}

.btn-call-control.inactive {
    background: rgba(255, 118, 117, 0.3);
    color: var(--status-danger);
}

.btn-call-control.inactive:hover {
    background: rgba(255, 118, 117, 0.4);
    box-shadow: 0 4px 20px rgba(255, 118, 117, 0.2);
}

.btn-call-control.danger {
    background: var(--status-danger);
    color: white;
    animation: danger-pulse 2s ease-in-out infinite;
}

@keyframes danger-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 118, 117, 0.2); }
    50% { box-shadow: 0 0 40px rgba(255, 118, 117, 0.4); }
}

.btn-call-control.danger:hover {
    background: #ff6b6b;
    box-shadow: 0 8px 30px rgba(255, 118, 117, 0.4);
    transform: scale(1.08);
}

/* ========================================
   AVATAR SELECTOR
   ======================================== */
.avatar-selector {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    transition: background 0.4s ease, border-color 0.4s ease;
}

.avatar-selector h4 {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.avatar-option {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-option:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
    background: var(--bg-card-hover);
}

.avatar-option.selected {
    border-color: var(--accent-primary);
    background: rgba(26, 107, 204, 0.2);
    box-shadow: 0 0 20px rgba(26, 107, 204, 0.2);
}

.avatar-option:active {
    transform: scale(0.9);
}

/* ========================================
   DANGER ZONE
   ======================================== */
.danger-zone {
    margin: 20px 0;
    padding: 16px;
    border: 1px solid rgba(255, 118, 117, 0.2);
    border-radius: var(--radius-md);
    background: rgba(255, 118, 117, 0.05);
}

.danger-zone h4 {
    color: var(--status-danger);
    font-size: 13px;
    margin-bottom: 12px;
    font-weight: 600;
}

.danger-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-danger {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--danger-gradient);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 150px;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 118, 117, 0.3);
}

.btn-danger:active {
    transform: scale(0.95);
}

/* ========================================
   CONFIRM MODAL
   ======================================== */
.confirm-modal {
    text-align: center;
    max-width: 420px !important;
}

.confirm-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.confirm-modal h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.confirm-modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions .btn-secondary {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
}

.confirm-actions .btn-danger {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    margin: 5% auto;
    padding: 24px;
    width: 90%;
    max-width: 520px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.9);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-avatar-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.modal-avatar-large {
    font-size: 40px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(26, 107, 204, 0.3);
    overflow: hidden;
}

.modal-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(26, 107, 204, 0.3);
}

.avatar-edit-btn:active {
    transform: scale(0.9);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.modal-sub {
    color: var(--text-muted);
    font-size: 13px;
}

/* Form */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group label i {
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: var(--font);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 107, 204, 0.15);
    background: var(--bg-input-focus);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-submit:hover::before {
    left: 100%;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26, 107, 204, 0.3);
    background: var(--accent-gradient-hover);
}

.btn-submit:active {
    transform: scale(0.98);
}

/* User Info Modal */
.user-info-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.user-info-avatar {
    font-size: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.user-info-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-info-details {
    margin: 12px 0;
}

.detail-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
}

.detail-icon {
    width: 20px;
    color: var(--text-muted);
    font-size: 13px;
    flex-shrink: 0;
}

.detail-label {
    width: 80px;
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.detail-value {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
}

.user-info-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.user-info-actions button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 12px;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action-primary {
    background: var(--accent-gradient);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-action-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-action-primary:hover::before {
    left: 100%;
}

.btn-action-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26, 107, 204, 0.3);
    background: var(--accent-gradient-hover);
}

.btn-action-primary:active {
    transform: scale(0.95);
}

.btn-action-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-action-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.btn-action-secondary:active {
    transform: scale(0.95);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 13px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
#toastContainer {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.4s ease;
    border: 1px solid var(--border-color);
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--status-online);
}

.toast.error {
    border-left-color: var(--status-danger);
}

.toast.info {
    border-left-color: var(--accent-primary);
}

.toast-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.toast-message {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   MESSAGE WITH FILE
   ======================================== */
.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    margin-top: 4px;
}

.message-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.message-file-info {
    flex: 1;
    min-width: 0;
}

.message-file-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}

.message-file-size {
    font-size: 10px;
    color: var(--text-muted);
}

.message-file-download {
    background: none;
    border: none;
    color: var(--accent-secondary);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.message-file-download:hover {
    color: var(--accent-primary);
    transform: scale(1.1);
}

/* ========================================
   IMAGE IN MESSAGE
   ======================================== */
.message-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.message-image:hover {
    transform: scale(1.02);
}

/* ========================================
   AUDIO PLAYER IN MESSAGE
   ======================================== */
.message-audio {
    width: 100%;
    max-width: 280px;
    margin-top: 4px;
    border-radius: var(--radius-sm);
}

.message-audio::-webkit-media-controls-panel {
    background: var(--bg-card);
}

/* ========================================
   VIDEO PLAYER IN MESSAGE
   ======================================== */
.message-video {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
}

/* ========================================
   LIGHTBOX FOR IMAGES
   ======================================== */
#lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99998;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

#lightbox.active {
    display: flex;
}

#lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

#lightbox .lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 32px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

#lightbox .lightbox-close:hover {
    transform: rotate(90deg);
}

/* ========================================
   MOBILE MENU
   ======================================== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    color: var(--accent-secondary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
}

.sidebar-overlay.active {
    display: block;
}

/* ========================================
   FRIEND REQUEST NOTIFICATIONS
   ======================================== */
.friend-request-notification {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid var(--accent-primary);
    animation: fadeSlide 0.3s ease;
    transition: var(--transition);
}

.friend-request-notification:hover {
    background: var(--bg-card-hover);
}

/* ========================================
   THEME TRANSITION OVERRIDES
   ======================================== */
* {
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ========================================
   RESPONSIVE - MOBILE OPTIMISÉ
   ======================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
        --private-width: 360px;
    }
    .avatar-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --private-width: 100%;
        --header-height: 54px;
        --input-height: 56px;
    }
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        border-right: none;
    }
    #sidebar.open {
        transform: translateX(0);
    }
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .btn-profile-mobile {
        display: flex !important;
    }
    #mainChat {
        width: 100%;
        flex: 1;
    }
    .chat-header {
        padding: 8px 12px;
        min-height: var(--header-height);
    }
    .chat-header-left .chat-room-info h2 {
        font-size: 14px;
    }
    .chat-header-right .btn-primary span {
        display: none;
    }
    .chat-header-right .btn-primary {
        padding: 6px 12px;
        font-size: 12px;
    }
    .chat-header-right .btn-secondary {
        padding: 6px 10px;
        font-size: 12px;
    }
    #messagesContainer {
        padding: 8px 12px;
    }
    .message {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 13px;
    }
    .message .message-content {
        font-size: 13px;
    }
    .chat-input-wrapper {
        padding: 6px 10px calc(6px + var(--safe-bottom));
    }
    .chat-input {
        gap: 6px;
        padding: 3px;
        border-radius: var(--radius-md);
    }
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }
    .btn-send {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    .input-field input {
        font-size: 13px;
        padding: 6px 2px;
        min-height: 32px;
    }
    .input-char-counter {
        font-size: 8px;
    }
    #privateChat {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        border-left: none;
        animation: slideIn 0.3s ease;
        width: 100%;
        min-width: unset;
    }
    @keyframes slideIn {
        from { transform: translateX(100%); }
        to { transform: translateX(0); }
    }
    .private-header {
        padding: 8px 12px;
        min-height: var(--header-height);
    }
    .private-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .private-user-details h3 {
        font-size: 13px;
    }
    .private-status {
        font-size: 10px;
    }
    .btn-call, .btn-video {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    #privateMessagesContainer {
        padding: 8px 10px;
    }
    .private-message {
        max-width: 85%;
        padding: 6px 12px;
        font-size: 13px;
    }
    .video-local-wrapper {
        width: 120px;
        height: 85px;
        bottom: 90px;
        right: 12px;
    }
    .placeholder-avatar {
        width: 90px;
        height: 90px;
        font-size: 36px;
    }
    .placeholder-name {
        font-size: 18px;
    }
    .placeholder-status {
        font-size: 12px;
    }
    .call-info-bar {
        padding: 6px 12px;
        font-size: 11px;
    }
    .call-duration {
        font-size: 13px;
    }
    .call-partner {
        font-size: 11px;
    }
    .btn-call-control {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    .call-actions {
        gap: 10px;
    }
    .modal-content {
        margin: 8% auto;
        padding: 20px;
        max-width: 95%;
    }
    .modal-header h2 {
        font-size: 20px;
    }
    .modal-avatar-large {
        width: 60px;
        height: 60px;
        font-size: 32px;
    }
    .avatar-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }
    .avatar-option {
        font-size: 18px;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .form-group input, .form-group select, .form-group textarea {
        font-size: 13px;
        padding: 8px 10px;
    }
    .btn-submit {
        font-size: 14px;
        padding: 10px;
    }
    .btn-danger {
        font-size: 12px;
        padding: 8px 12px;
        min-width: unset;
    }
    .danger-actions {
        flex-direction: column;
    }
    .user-info-actions {
        flex-direction: column;
    }
    .user-info-actions button {
        width: 100%;
    }
    .user-info-header {
        flex-direction: column;
        text-align: center;
    }
    .user-info-avatar {
        width: 64px;
        height: 64px;
        font-size: 32px;
    }
    .detail-item {
        flex-wrap: wrap;
        gap: 4px;
    }
    .detail-label {
        width: 70px;
        font-size: 11px;
    }
    .detail-value {
        font-size: 12px;
    }
    .sidebar-header {
        padding: 10px 14px;
        min-height: var(--header-height);
        flex-shrink: 0;
    }
    .sidebar-header-actions {
        gap: 6px;
    }
    .sidebar-body {
        padding-top: 8px;
    }
    .logo-text {
        font-size: 18px;
    }
    .logo-icon-wrapper {
        width: 34px;
        height: 34px;
    }
    .logo-icon {
        font-size: 17px;
    }
    .search-bar input {
        font-size: 13px;
        padding: 8px 10px;
    }
    .sidebar-tabs {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 3px;
        padding: 3px;
    }
    .tab-btn {
        padding: 6px 2px;
        font-size: 10px;
        min-height: 38px;
        gap: 2px;
    }
    .tab-btn i {
        font-size: 14px;
    }
    .tab-btn span:not(.tab-badge) {
        font-size: 8px;
    }
    .tab-badge {
        font-size: 8px;
        line-height: 14px;
        min-width: 14px;
        padding: 0 4px;
    }
    .user-item {
        padding: 8px 10px;
        gap: 10px;
    }
    .user-item .user-avatar {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    .user-item .user-name {
        font-size: 13px;
    }
    .user-item .user-sub {
        font-size: 11px;
    }
    .user-item .user-status-text {
        font-size: 10px;
        padding: 1px 8px;
    }
    #toastContainer {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
    .toast {
        padding: 10px 14px;
        font-size: 12px;
    }
    .toast-title {
        font-size: 12px;
    }
    .toast-message {
        font-size: 11px;
    }
    .file-preview {
        padding: 4px 8px;
        font-size: 11px;
    }
    .file-preview-icon {
        font-size: 16px;
    }
    .file-preview-name {
        font-size: 11px;
    }
    .message-image {
        max-height: 180px;
    }
    .message-video {
        max-height: 180px;
    }
    .message-audio {
        max-width: 100%;
    }
    .message-file {
        padding: 4px 8px;
        gap: 8px;
    }
    .message-file-icon {
        font-size: 18px;
    }
    .message-file-name {
        font-size: 11px;
    }
    .welcome-message {
        padding: 30px 16px;
    }
    .welcome-icon {
        font-size: 36px;
    }
    .welcome-message h3 {
        font-size: 17px;
    }
    .welcome-message p {
        font-size: 13px;
    }
    .confirm-modal {
        max-width: 95% !important;
    }
    .confirm-modal .confirm-actions {
        flex-direction: column;
    }
    .confirm-modal .confirm-actions button {
        width: 100%;
    }
    .confirm-icon {
        font-size: 36px;
    }
    .confirm-modal h2 {
        font-size: 18px;
    }
    .confirm-modal p {
        font-size: 13px;
    }

    .emoji-picker {
        width: 240px;
        bottom: 54px;
        left: -20px;
        padding: 10px;
        max-height: 250px;
    }
    .emoji-picker-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
    }
    .emoji-picker-grid .emoji-option {
        font-size: 18px;
        padding: 2px;
    }
    #privateChat .emoji-picker {
        left: -20px;
        width: 240px;
    }

   /* Remplacer la section du theme-toggle-btn dans style.css */

.theme-toggle-btn {
    position: fixed;
    bottom: 80px; /* Augmenté pour éviter la superposition avec la zone de saisie */
    left: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 50px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 30px rgba(26, 107, 204, 0.2);
    border-color: var(--accent-primary);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn i {
    font-size: 18px;
    transition: transform 0.6s ease;
}

.theme-toggle-btn:hover i {
    transform: rotate(30deg);
}

.theme-toggle-btn .theme-toggle-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

/* Styles spécifiques pour le responsive mobile */
@media (max-width: 768px) {
    .theme-toggle-btn {
        bottom: 90px; /* Au-dessus de la zone de saisie */
        left: 16px;
        padding: 8px 14px;
        font-size: 12px;
        z-index: 100; /* S'assurer qu'il reste au-dessus */
    }
    .theme-toggle-btn i {
        font-size: 15px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .theme-toggle-btn {
        bottom: 80px;
        left: 12px;
        padding: 6px 12px;
        font-size: 10px;
        gap: 4px;
        border-radius: 40px;
    }
    .theme-toggle-btn i {
        font-size: 13px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 9px;
    }
}

@media (max-width: 375px) {
    .theme-toggle-btn {
        bottom: 72px;
        left: 10px;
        padding: 5px 10px;
        font-size: 9px;
        gap: 3px;
    }
    .theme-toggle-btn i {
        font-size: 11px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 8px;
    }
}

/* Ajouter des styles pour réduire la taille du bouton sur très petit écran */
@media (max-width: 420px) {
    .theme-toggle-btn {
        padding: 4px 10px;
        border-radius: 30px;
        gap: 4px;
    }
    .theme-toggle-btn i {
        font-size: 12px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 8px;
        display: none; /* Cacher le texte sur très petit écran pour gagner de la place */
    }
    .theme-toggle-btn .theme-toggle-label.short {
        display: inline; /* Afficher une version courte */
        font-size: 8px;
    }
}

/* Version courte pour mobile */
@media (max-width: 420px) {
    .theme-toggle-btn .theme-toggle-label {
        display: none;
    }
    .theme-toggle-btn .theme-toggle-label-short {
        display: inline;
        font-size: 8px;
    }
}
@media (min-width: 421px) {
    .theme-toggle-btn .theme-toggle-label-short {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 48px;
        --input-height: 48px;
        --sidebar-width: 260px;
    }
    .chat-header-left .chat-room-info h2 {
        font-size: 12px;
    }
    .chat-status {
        font-size: 9px;
    }
    .chat-header-right .btn-primary {
        padding: 4px 10px;
        font-size: 10px;
    }
    .chat-header-right .btn-secondary {
        padding: 4px 8px;
        font-size: 10px;
    }
    .message {
        font-size: 12px;
        padding: 6px 10px;
        max-width: 90%;
    }
    .message .message-content {
        font-size: 12px;
    }
    .message .message-header {
        font-size: 10px;
    }
    .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    .btn-send {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    .input-field input {
        font-size: 12px;
        padding: 4px 2px;
        min-height: 28px;
    }
    .input-char-counter {
        font-size: 7px;
    }
    .chat-input-wrapper {
        padding: 4px 8px calc(4px + var(--safe-bottom));
    }
    .chat-input {
        gap: 4px;
        padding: 2px;
        border-radius: var(--radius-sm);
    }
    .avatar-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }
    .avatar-option {
        font-size: 16px;
    }
    .video-local-wrapper {
        width: 90px;
        height: 64px;
        bottom: 80px;
        right: 8px;
    }
    .placeholder-avatar {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }
    .placeholder-name {
        font-size: 16px;
    }
    .placeholder-status {
        font-size: 11px;
    }
    .call-info-bar {
        padding: 4px 10px;
        font-size: 10px;
        flex-wrap: wrap;
        gap: 4px;
    }
    .call-duration {
        font-size: 12px;
    }
    .call-partner {
        font-size: 10px;
    }
    .call-quality {
        font-size: 9px;
    }
    .btn-call-control {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .call-actions {
        gap: 8px;
    }
    .modal-content {
        padding: 16px;
        margin: 4% auto;
    }
    .modal-header h2 {
        font-size: 18px;
    }
    .modal-avatar-large {
        width: 52px;
        height: 52px;
        font-size: 28px;
    }
    .avatar-edit-btn {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
    .form-group input, .form-group select, .form-group textarea {
        font-size: 12px;
        padding: 6px 10px;
    }
    .btn-submit {
        font-size: 13px;
        padding: 8px;
    }
    .btn-danger {
        font-size: 11px;
        padding: 6px 10px;
    }
    .sidebar-header {
        padding: 8px 12px;
    }
    .logo-text {
        font-size: 16px;
    }
    .logo-icon-wrapper {
        width: 30px;
        height: 30px;
    }
    .logo-icon {
        font-size: 15px;
    }
    .logo-sub {
        font-size: 7px;
    }
    .sidebar-body {
        padding: 8px 10px;
    }
    .search-bar input {
        font-size: 12px;
        padding: 6px 8px;
    }
    .sidebar-tabs {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 2px;
        padding: 2px;
    }
    .tab-btn {
        padding: 4px 2px;
        font-size: 8px;
        min-height: 32px;
        gap: 1px;
        border-radius: 4px;
    }
    .tab-btn i {
        font-size: 12px;
    }
    .tab-btn span:not(.tab-badge) {
        font-size: 7px;
    }
    .tab-badge {
        font-size: 7px;
        line-height: 12px;
        min-width: 12px;
        padding: 0 3px;
    }
    .user-item {
        padding: 6px 8px;
        gap: 8px;
    }
    .user-item .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .user-item .user-avatar .status-dot {
        width: 8px;
        height: 8px;
    }
    .user-item .user-name {
        font-size: 12px;
    }
    .user-item .user-sub {
        font-size: 10px;
    }
    .user-item .user-status-text {
        font-size: 9px;
        padding: 1px 6px;
    }
    .private-header {
        padding: 6px 10px;
        gap: 6px;
    }
    .private-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .private-user-details h3 {
        font-size: 12px;
    }
    .private-status {
        font-size: 9px;
    }
    .btn-call, .btn-video {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .btn-back {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    #privateMessagesContainer {
        padding: 6px 8px;
    }
    .private-message {
        font-size: 12px;
        padding: 5px 10px;
        max-width: 90%;
    }
    .message-image {
        max-height: 150px;
    }
    .message-video {
        max-height: 150px;
    }
    .welcome-icon {
        font-size: 28px;
    }
    .welcome-message h3 {
        font-size: 15px;
    }
    .welcome-message p {
        font-size: 12px;
    }
    .confirm-icon {
        font-size: 30px;
    }
    .confirm-modal h2 {
        font-size: 16px;
    }
    .confirm-modal p {
        font-size: 12px;
    }
    #lightbox .lightbox-close {
        font-size: 28px;
        top: 12px;
        right: 16px;
    }
    .btn-profile-mobile {
        width: 32px;
        height: 32px;
    }
    .profile-avatar-mobile {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .emoji-picker {
        width: 200px;
        left: -40px;
        padding: 8px;
        max-height: 200px;
    }
    .emoji-picker-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .emoji-picker-grid .emoji-option {
        font-size: 16px;
    }
    #privateChat .emoji-picker {
        left: -40px;
        width: 200px;
    }

    .theme-toggle-btn {
        bottom: 12px;
        left: 12px;
        padding: 6px 10px;
        font-size: 10px;
        gap: 4px;
    }
    .theme-toggle-btn i {
        font-size: 13px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 10px;
    }
}

@media (max-width: 375px) {
    :root {
        --sidebar-width: 240px;
    }
    .chat-header-left .chat-room-info h2 {
        font-size: 11px;
    }
    .chat-header-right .btn-primary {
        padding: 3px 8px;
        font-size: 9px;
    }
    .chat-header-right .btn-secondary {
        padding: 3px 6px;
        font-size: 9px;
    }
    .message {
        font-size: 11px;
        padding: 5px 8px;
    }
    .message .message-content {
        font-size: 11px;
    }
    .btn-icon {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    .btn-send {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
    .input-field input {
        font-size: 11px;
        padding: 4px 2px;
        min-height: 24px;
    }
    .avatar-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .avatar-option {
        font-size: 14px;
    }
    .user-item .user-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    .user-item .user-avatar .status-dot {
        width: 8px;
        height: 8px;
    }
    .user-item .user-name {
        font-size: 11px;
    }
    .user-item .user-sub {
        font-size: 9px;
    }
    .video-local-wrapper {
        width: 72px;
        height: 52px;
        bottom: 70px;
        right: 6px;
    }
    .btn-call-control {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .call-actions {
        gap: 6px;
    }
    .call-info-bar {
        padding: 3px 8px;
        font-size: 9px;
    }
    .call-duration {
        font-size: 11px;
    }
    .call-partner {
        font-size: 9px;
    }
    .modal-content {
        padding: 12px;
    }
    .sidebar-tabs {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 2px;
        padding: 2px;
    }
    .tab-btn {
        padding: 3px 1px;
        font-size: 7px;
        min-height: 28px;
    }
    .tab-btn i {
        font-size: 10px;
    }
    .tab-btn span:not(.tab-badge) {
        font-size: 6px;
    }
    .tab-badge {
        font-size: 6px;
        line-height: 10px;
        min-width: 10px;
        padding: 0 2px;
    }

    .emoji-picker {
        width: 180px;
        left: -50px;
        padding: 6px;
        max-height: 180px;
    }
    .emoji-picker-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 2px;
    }
    .emoji-picker-grid .emoji-option {
        font-size: 14px;
        padding: 2px;
    }
    #privateChat .emoji-picker {
        left: -50px;
        width: 180px;
    }

    .theme-toggle-btn {
        bottom: 10px;
        left: 10px;
        padding: 5px 8px;
        font-size: 9px;
        gap: 3px;
    }
    .theme-toggle-btn i {
        font-size: 11px;
    }
    .theme-toggle-btn .theme-toggle-label {
        font-size: 8px;
    }
}

@supports (padding: max(0px)) {
    .chat-input-wrapper {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    #videoCallOverlay {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .theme-toggle-btn {
        bottom: max(20px, env(safe-area-inset-bottom) + 10px);
        left: max(20px, env(safe-area-inset-left) + 10px);
    }
    @media (max-width: 768px) {
        .theme-toggle-btn {
            bottom: max(16px, env(safe-area-inset-bottom) + 8px);
            left: max(16px, env(safe-area-inset-left) + 8px);
        }
    }
    @media (max-width: 480px) {
        .theme-toggle-btn {
            bottom: max(12px, env(safe-area-inset-bottom) + 6px);
            left: max(12px, env(safe-area-inset-left) + 6px);
        }
    }
}

/* ========================================
   MODULES UX — qualité, accessibilité, perf
   ======================================== */
.call-quality[data-quality="excellent"] { color: var(--status-online); }
.call-quality[data-quality="good"] { color: #55efc4; }
.call-quality[data-quality="fair"] { color: var(--status-warning); }
.call-quality[data-quality="poor"] { color: var(--status-danger); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.toast, .user-item, .message, .btn-call-control {
    contain: layout style;
}

.video-remote, .video-local {
    will-change: transform;
    background: #000;
}

/* Focus visible pour accessibilité clavier */
:focus-visible {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* Indicateur hors-ligne subtil */
body.socket-offline .chat-status::after {
    content: ' · hors ligne';
    color: var(--status-danger);
}
