@charset "UTF-8";

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* --- DÉFINITION DES THÈMES DE COULEUR --- */

/* Thème Bleu (Défaut) - Amélioré */
:root,
[data-color-theme="blue"] {
    --primary-color: #0ea5e9;
    --primary-color-light: #38bdf8;
    --primary-color-dark: #0284c7;
    --primary-color-shadow: rgba(14, 165, 233, 0.4);
    --primary-color-shadow-light: rgba(14, 165, 233, 0.2);
    --primary-color-border: rgba(14, 165, 233, 0.15);
    --primary-color-bg: rgba(14, 165, 233, 0.1);
}
[data-theme="dark"][data-color-theme="blue"] {
    --primary-color: #38bdf8;
    --primary-color-light: #7dd3fc;
    --primary-color-dark: #0ea5e9;
    --primary-color-shadow: rgba(56, 189, 248, 0.5);
    --primary-color-shadow-light: rgba(56, 189, 248, 0.3);
    --primary-color-border: rgba(56, 189, 248, 0.2);
    --primary-color-bg: rgba(56, 189, 248, 0.15);
}

/* Thème Violet */
[data-color-theme="purple"] {
    --primary-color: #8b5cf6;
    --primary-color-light: #a78bfa;
    --primary-color-dark: #7c3aed;
    --primary-color-shadow: rgba(139, 92, 246, 0.32);
    --primary-color-shadow-light: rgba(139, 92, 246, 0.16);
    --primary-color-border: rgba(139, 92, 246, 0.1);
    --primary-color-bg: rgba(139, 92, 246, 0.08);
}
[data-theme="dark"][data-color-theme="purple"] {
    --primary-color: #a78bfa;
    --primary-color-light: #c4b5fd;
    --primary-color-dark: #8b5cf6;
    --primary-color-shadow: rgba(139, 92, 246, 0.45);
    --primary-color-shadow-light: rgba(139, 92, 246, 0.24);
    --primary-color-border: rgba(139, 92, 246, 0.12);
    --primary-color-bg: rgba(139, 92, 246, 0.16);
}

/* Thème Vert */
[data-color-theme="green"] {
    --primary-color: #10b981;
    --primary-color-light: #34d399;
    --primary-color-dark: #059669;
    --primary-color-shadow: rgba(16, 185, 129, 0.32);
    --primary-color-shadow-light: rgba(16, 185, 129, 0.16);
    --primary-color-border: rgba(16, 185, 129, 0.1);
    --primary-color-bg: rgba(16, 185, 129, 0.08);
}
[data-theme="dark"][data-color-theme="green"] {
    --primary-color: #34d399;
    --primary-color-light: #6ee7b7;
    --primary-color-dark: #10b981;
    --primary-color-shadow: rgba(16, 185, 129, 0.45);
    --primary-color-shadow-light: rgba(16, 185, 129, 0.24);
    --primary-color-border: rgba(16, 185, 129, 0.12);
    --primary-color-bg: rgba(16, 185, 129, 0.16);
}

/* Thème Rose */
[data-color-theme="pink"] {
    --primary-color: #ec4899;
    --primary-color-light: #f472b6;
    --primary-color-dark: #db2777;
    --primary-color-shadow: rgba(236, 72, 153, 0.32);
    --primary-color-shadow-light: rgba(236, 72, 153, 0.16);
    --primary-color-border: rgba(236, 72, 153, 0.1);
    --primary-color-bg: rgba(236, 72, 153, 0.08);
}
[data-theme="dark"][data-color-theme="pink"] {
    --primary-color: #f472b6;
    --primary-color-light: #f9a8d4;
    --primary-color-dark: #ec4899;
    --primary-color-shadow: rgba(236, 72, 153, 0.45);
    --primary-color-shadow-light: rgba(236, 72, 153, 0.24);
    --primary-color-border: rgba(236, 72, 153, 0.12);
    --primary-color-bg: rgba(236, 72, 153, 0.16);
}


/* --- COULEURS DE BASE (Clair) --- */
:root {
    --bg-main: #f5f7fb;
    --bg-sidebar: #f6f7f8;
    --bg-surface: #ffffff;
    --bg-input: #ffffff;
    --border-subtle: #d1d7db;
    --text-primary: #111827;
    --text-secondary: #55626a;
    --chat-bg: radial-gradient(circle at 18% 18%, var(--primary-color-shadow-light), transparent 32%),
                radial-gradient(circle at 82% 12%, rgba(255, 234, 243, 0.2), transparent 30%),
                linear-gradient(135deg, #fdfcfb 0%, #e8f1ff 45%, #ffeaf3 100%);
    --message-theirs-bg: #ffffff;
    --message-theirs-border: #e0e7ef;
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.08);
}

/* --- COULEURS DE BASE (Sombre) --- */
[data-theme="dark"] {
    --bg-main: #0b0f14;
    --bg-sidebar: #0f172a;
    --bg-surface: #0b1220;
    --bg-input: #111827;
    --border-subtle: #1f2937;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --chat-bg: radial-gradient(circle at 18% 18%, var(--primary-color-shadow-light), transparent 32%),
                radial-gradient(circle at 82% 12%, rgba(255, 234, 243, 0.08), transparent 30%),
                linear-gradient(135deg, #0b0f14 0%, #0d1522 45%, #111827 100%);
    --message-theirs-bg: #0f172a;
    --message-theirs-border: #1f2937;
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.28);
}

/* Landing Page */
.landing-page {
    min-height: 100vh;
    background: radial-gradient(circle at 35% 35%, #2a2a2a, #0a0a0a, #000);
    overflow: hidden;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-logo {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #fff;
}

.signup-btn {
    padding: 0.8rem 1.4rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-light));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 30px var(--primary-color-shadow);
    transition: all 0.25s ease;
}

.signup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px var(--primary-color-shadow);
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6rem 3rem 4rem;
    gap: 3rem;
}

.hero-content {
    max-width: 600px;
}

.hero-title {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    font-weight: 900;
}

.hero-subtitle {
    color: #b0b0b0;
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

.hero-features {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
}

.feature {
    text-align: center;
}

.feature-icon {
    position: relative; 
    margin: 0 auto 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
}

.feature-icon svg {
    stroke: var(--primary-color-light);
    width: 40px; 
    height: 40px;
}

.feature p {
    color: #a0a0a0;
    font-size: 0.9rem;
}

.cta-btn {
    padding: 1rem 3rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    border: none;
    border-radius: 30px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px var(--primary-color-shadow);
}

.cta-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px var(--primary-color-shadow);
}

.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- iPhone Mockup - Thème dynamique --- */
.iphone-mockup {
    width: 320px;
    height: 650px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    border-radius: 55px;
    padding: 12px;
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 0 0 1px var(--primary-color-shadow-light),
        inset 0 0 0 2px rgba(255, 255, 255, 0.2);
    position: relative;
    border: 3px solid var(--primary-color-dark);
}

.iphone-mockup::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    border-radius: 45px;
    background: radial-gradient(circle at 30% 30%, #1a1a1a, #000);
    filter: blur(25px);
    opacity: 0.35;
}

.iphone-notch {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 24px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
}

.iphone-camera-module {
    position: absolute;
    top: 40px;
    right: 20px;
    width: 80px;
    height: 80px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: 20px;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.camera-lens {
    width: 24px;
    height: 24px;
    background: radial-gradient(circle at 35% 35%, #2a2a2a, #0a0a0a, #000);
    border-radius: 50%;
    border: 2.5px solid #000;
    position: relative;
    box-shadow: 
        0 2px 5px rgba(0, 0, 0, 0.8),
        inset 0 1px 3px var(--primary-color-shadow-light);
}

.camera-lens::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #1a1a1a, #000);
    border-radius: 50%;
    border: 1px solid #0a0a0a;
}

.camera-lens::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle at 30% 30%, var(--primary-color-shadow-light), transparent);
    border-radius: 50%;
}

.camera-1 { grid-column: 1; grid-row: 1; }
.camera-2 { grid-column: 2; grid-row: 1; }
.camera-3 { grid-column: span 2; grid-row: 2; justify-self: center; width: 26px; height: 26px; }

.flash {
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 30% 30%, var(--primary-color-light), var(--primary-color));
    border-radius: 50%;
    position: absolute;
    bottom: 10px;
    right: 10px;
    border: 2px solid var(--primary-color-dark);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.iphone-screen {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 45px;
    padding: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.screen-content {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, var(--primary-color-shadow-light), transparent);
    border-radius: 35px;
    position: relative;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #0f0f0f;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 420px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    position: relative;
}

/* Confirmation modal (lightweight) */
.confirm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    pointer-events: none;
}
.confirm-modal .confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
}
.confirm-modal .confirm-box {
    position: relative;
    pointer-events: auto;
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    min-width: 260px;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}
.confirm-modal .confirm-message {
    font-size: 1rem;
    color: var(--text-primary);
}
.confirm-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
.confirm-no, .confirm-yes {
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    cursor: pointer;
    font-weight: 700;
}
.confirm-yes {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    color: #fff;
    border-color: transparent;
}
.confirm-no {
    background: transparent;
}
.confirm-modal.hidden { display: none; }

/* --- MODAL AJOUTER DES MEMBRES --- */
.modal-large {
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.add-members-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.member-search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.member-search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 15px var(--primary-color-shadow-light);
}

.member-search-btn {
  padding: 0.75rem 1rem;
  background: var(--primary-color);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-search-btn:hover {
  background: var(--primary-color-dark);
}

.add-members-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex: 1;
  overflow: hidden;
}

.members-available,
.members-selected {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  background: var(--bg-surface);
  overflow: hidden;
}

.members-available h3,
.members-selected h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-weight: 600;
}

.users-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-item {
  padding: 0.75rem 0.9rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}

.user-item:hover {
  background: var(--primary-color-bg);
  border-color: var(--primary-color);
}

.user-item-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.user-item-action {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.user-item-action:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.user-item-action.added {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.add-members-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.secondary-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.secondary-btn:hover {
  background: var(--bg-primary);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
  color: white;
  border: none;
}

.primary-btn:hover {
  box-shadow: 0 8px 20px var(--primary-color-shadow);
}

.add-members-message {
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.2em;
  margin-top: 0.5rem;
}

.add-members-message.error {
  color: #ef4444;
}

.add-members-message.success {
  color: #10b981;
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #777;
    cursor: pointer;
}

.modal h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #fff;
    font-size: 1.8rem;
}
.modal h2:hover {
color: var(--primary-color-light);
cursor: pointer;
transition: color 0.2s ease;
}
.form-group {
display: block;
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-size: 0.9rem;
color: #a0a0a0;
}
#authForm input,
#groupForm input {
padding: 1rem;
background: #0a0a0a;
border: 2px solid #333;
border-radius: 10px;
color: #fff;
font-size: 1rem;
transition: all 0.3s ease;
width: 100%;
}
#authForm input:focus,
#groupForm input:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 20px var(--primary-color-shadow-light);
}
.form-group {
display: flex;
flex-direction: column;
}
.auth-message,
.group-message {
text-align: center;
font-size: 0.9rem;
color: var(--primary-color-light);
min-height: 1.2em;
}
.auth-message.error,
.group-message.error {
color: #ef4444;
}
.auth-message.success,
.group-message.success {
color: #10b981;
}
.submit-btn {
padding: 1rem;
background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
border: none;
border-radius: 10px;
color: #fff;
font-size: 1.1rem;
font-weight: 700;
cursor: pointer;
transition: all 0.3s ease;
}
.submit-btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 30px var(--primary-color-shadow);
}
/* Chat App */
.chat-app {
display: flex;
height: 100vh;
background: var(--chat-bg);
color: var(--text-primary);
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.sidebar {
width: 320px;
background: var(--bg-sidebar);
border-right: 1px solid var(--border-subtle);
display: flex;
flex-direction: column;
overflow-y: auto;
}
.sidebar-header {
padding: 1.5rem;
border-bottom: 1px solid var(--primary-color-border);
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.sidebar-switcher {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.switch-btn {
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}
.switch-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-light));
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px var(--primary-color-shadow-light);
}
.sidebar-header h2 {
font-size: 1.6rem;
color: var(--primary-color-dark);
margin-bottom: 0.5rem;
}
.user-info {
font-size: 0.9rem;
color: var(--text-secondary);
}
.logout-btn {
margin-top: 0.4rem;
padding: 0.65rem 0.9rem;
background: linear-gradient(135deg, #ef4444, #dc2626);
border: none;
border-radius: 10px;
color: #fff;
font-weight: 700;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
}
.logout-btn:hover {
transform: translateY(-2px);
box-shadow: 0 12px 28px rgba(239, 68, 68, 0.45);
}
.logout-btn:active {
transform: translateY(0);
}
/* User Search */
.user-search-container {
padding: 1rem;
display: flex;
gap: 0.5rem;
border-bottom: 1px solid var(--border-subtle);
}
#userSearchInput {
flex: 1;
padding: 0.5rem 0.75rem;
background: var(--bg-input);
border: 1px solid var(--border-subtle);
border-radius: 10px;
color: var(--text-primary);
font-size: 0.9rem;
}
#userSearchInput:focus {
outline: none;
border-color: var(--primary-color);
}
#userSearchBtn {
padding: 0.5rem;
width: 38px;
height: 38px;
background: linear-gradient(135deg, var(--primary-color-light), var(--primary-color));
border: none;
border-radius: 10px;
color: #fff;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
/* Sidebar Sections */
.sidebar-section {
display: flex;
flex-direction: column;
border-bottom: 1px solid var(--border-subtle);
padding-bottom: 1rem;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 1rem 0.5rem;
}
.section-header h3 {
font-size: 0.85rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-secondary);
}
.create-group-btn {
width: 24px;
height: 24px;
border-radius: 6px;
background: var(--primary-color);
color: white;
border: none;
font-size: 1.2rem;
font-weight: bold;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.create-group-btn:hover {
background: var(--primary-color-light);
transform: scale(1.1);
}
.channels-list {
padding: 0 1rem 1rem;
display: flex;
flex-direction: column;
}
.dm-channel-btn,
.group-channel-btn {
width: 100%;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: 14px;
padding: 0.75rem 0.9rem;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.65rem;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: var(--shadow-soft);
position: relative;
}
.dm-channel-btn:hover,
.group-channel-btn:hover {
transform: translateY(-2px);
border-color: var(--primary-color-border);
box-shadow: 0 12px 24px var(--primary-color-shadow-light);
}
.dm-channel-btn.active,
.group-channel-btn.active {
background: var(--primary-color-bg);
border-color: var(--primary-color);
box-shadow: 0 8px 24px var(--primary-color-shadow);
}

/* --- BADGE DE NOTIFICATION (Non-lus) --- */
.unread-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  animation: badgePulse 2s infinite;
}

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

/* --- NOUVEAU STYLE AVATAR (Générique) --- */
.dm-avatar {
width: 38px;
height: 38px;
border-radius: 10px;
background-color: var(--border-subtle);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355626a' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
flex-shrink: 0;
}
[data-theme="dark"] .dm-avatar {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.dm-avatar-system {
background: linear-gradient(135deg, var(--primary-color-dark), var(--primary-color));
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h.09A1.65 1.65 0 0 0 9 4.09V4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h.09a1.65 1.65 0 0 0 1.82-.33l.06.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v.09a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'%3E%3C/path%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
}
.group-avatar {
background: linear-gradient(135deg, var(--primary-color), var(--primary-color-light));
display: flex;
align-items: center;
justify-content: center;
color: white;
}
.dm-meta {
text-align: left;
flex: 1;
}
.dm-name {
font-weight: 700;
margin-bottom: 0.15rem;
}
.dm-sub {
font-size: 0.85rem;
color: var(--text-secondary);
}
/* Main Chat */
.main-chat {
flex: 1;
display: flex;
flex-direction: column;
background: var(--chat-bg);
}
.chat-header {
padding: 1.5rem;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-sidebar);
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
.chat-body {
    flex: 1;
    display: flex;
    gap: 1.25rem;
    padding: 0 1.5rem;
    overflow: hidden;
}
.messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-header h3 {
font-size: 1.5rem;
color: var(--primary-color-dark);
}
.chat-actions {
position: relative;
display: flex;
align-items: center;
}
.icon-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 0.45rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 14px var(--shadow-soft);
}
.icon-btn .icon-emoji {
    font-size: 1.1rem;
    line-height: 1;
}
.icon-btn .icon-label {
    font-size: 0.95rem;
}
.icon-btn:hover {
transform: translateY(-1px);
border-color: var(--primary-color);
box-shadow: 0 10px 20px var(--primary-color-shadow-light);
}
.messages-container {
flex: 1;
padding: 2rem 2.5rem;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 0.75rem;
background: transparent;
}
.group-contact-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-soft);
}
.group-contact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.group-contact-header h4 {
    font-size: 1rem;
    color: var(--text-primary);
}
.group-contact-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.group-contact-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.add-members-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    background: var(--primary-color-bg);
    color: var(--primary-color-dark);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: grid;
    place-items: center;
}
.add-members-btn:hover {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 8px 16px var(--primary-color-shadow-light);
}
.group-contact-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
}
.group-contact-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    transition: all 0.2s ease;
}

.group-contact-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--primary-color-shadow-light);
}

.group-contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-light));
    color: #fff;
    font-weight: 800;
    display: grid;
    place-items: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

.group-contact-name {
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.group-contact-remove {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.group-contact-remove:hover {
    background: #ef4444;
    color: white;
    border-radius: 4px;
    transform: scale(1.1);
}
.group-contact-empty {
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 0.4rem 0.2rem;
}
.message {
display: flex;
gap: 1rem;
padding: 0.75rem 1rem;
border-radius: 12px;
background: var(--message-theirs-bg);
border: 1px solid var(--message-theirs-border);
animation: messageSlide 0.3s ease-out;
max-width: min(75%, 720px);
}
@keyframes messageSlide {
from { opacity: 0; transform: translateX(-20px); }
to { opacity: 1; transform: translateX(0); }
}

/* Message header + delete button styles (avoid overlap with time) */
.message-header { position: relative; padding-right: 40px; display: flex; align-items: center; gap: 0.5rem; }
.message-time { display: inline-block; margin-left: 6px; color: var(--text-secondary); font-size: 0.85rem; }
.message-delete-btn { position: absolute; right: 6px; top: 4px; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 0.95rem; padding: 4px 6px; border-radius: 6px; opacity: 0; transition: opacity 0.15s ease; }
.message-delete-btn:hover { background: rgba(0,0,0,0.06); color: var(--primary-color-dark); }
.message.active-delete .message-delete-btn { opacity: 1; }

/* --- NOUVEAU STYLE AVATAR (Message) --- */
.message-avatar {
width: 40px;
height: 40px;
border-radius: 50%;
flex-shrink: 0;
background-color: var(--border-subtle);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355626a' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
[data-theme="dark"] .message-avatar {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.message-content {
flex: 1;
}
.message-header {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.5rem;
}
.message-username {
font-weight: 700;
color: var(--primary-color);
}
.message-time {
font-size: 0.75rem;
color: var(--text-secondary);
}
.message-text {
color: var(--text-primary);
line-height: 1.5;
}
.message--mine {
align-self: flex-end;
flex-direction: row-reverse;
background: linear-gradient(135deg, var(--primary-color), var(--primary-color-light));
border-color: transparent;
box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .message--mine {
background: linear-gradient(135deg, var(--primary-color-dark), var(--primary-color));
}
.message--mine .message-username {
color: #f8fafc;
}
.message--mine .message-time {
color: #e0f2fe;
}
.message--mine .message-text {
color: #f8fafc;
}
.message--theirs {
align-self: flex-start;
background: var(--message-theirs-bg);
border-color: var(--message-theirs-border);
}
.message-input-container {
padding: 1.25rem 1.5rem;
background: var(--bg-sidebar);
border-top: 1px solid var(--border-subtle);
display: flex;
gap: 0.75rem;
align-items: center;
}
#messageInput {
flex: 1;
padding: 0.9rem 1rem;
background: var(--bg-input);
border: 1px solid var(--border-subtle);
border-radius: 24px;
color: var(--text-primary);
font-size: 1rem;
transition: all 0.3s ease;
}
#messageInput:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 16px var(--primary-color-shadow-light);
}
#messageInput:disabled {
background: var(--bg-sidebar);
cursor: not-allowed;
}
.send-btn {
width: 48px;
height: 48px;
border-radius: 50%;
background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
border: none;
color: #fff;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
box-shadow: 0 4px 14px var(--primary-color-shadow);
flex-shrink: 0;
}
.send-btn:hover {
transform: scale(1.05);
box-shadow: 0 6px 18px var(--primary-color-shadow);
}
.send-btn:active {
transform: scale(0.97);
}
.send-btn:disabled {
background: var(--border-subtle);
cursor: not-allowed;
box-shadow: none;
transform: none;
}

/* Emoji button & picker */
.emoji-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    margin-right: 0.5rem;
}
.emoji-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.06);
}

.emoji-picker {
    position: absolute;
    bottom: 76px; /* sits above input area */
    right: 20px;
    width: 360px;
    max-width: calc(100% - 40px);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.6rem;
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    z-index: 6000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 50vh;
    overflow: hidden;
}
.emoji-picker .emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.35rem;
    overflow-y: auto;
    padding: 0.25rem;
}
.emoji-picker .emoji-grid button {
    background: transparent;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 8px;
}
.emoji-picker .emoji-grid button:hover {
    background: var(--bg-input);
}
.emoji-picker .emoji-controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.emoji-picker .emoji-search {
    flex: 1;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
}
.emoji-picker .emoji-cats {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.emoji-picker .emoji-cat-btn {
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.85rem;
}
.emoji-picker .emoji-cat-btn.active {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}
.emoji-recent {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.emoji-picker.hidden { display: none; }
/* Scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-sidebar);
}
::-webkit-scrollbar-thumb {
background: var(--primary-color);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary-color-light);
}
/* --- NOUVELLE PAGE PARAMÈTRES --- */
.settings-page {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: var(--bg-main);
z-index: 5000;
display: flex;
flex-direction: column;
animation: fadeIn 0.3s ease-out;
}
.settings-container {
width: 100%;
max-width: 1040px;
margin: 0 auto 4rem;
padding: 0 2rem 4rem;
display: flex;
flex-direction: column;
}

/* Allow scrolling when settings content exceeds viewport height */
.settings-page {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure the central container doesn't grow beyond the viewport and can scroll internally */
.settings-container {
    max-height: calc(100vh - 72px);
    overflow-y: auto;
}
.settings-header {
display: flex;
align-items: center;
padding: 1.5rem;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-sidebar);
gap: 1rem;
}
.settings-header h1 {
color: var(--text-primary);
}
.back-btn {
display: flex;
align-items: center;
gap: 0.5rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
color: var(--text-primary);
padding: 0.6rem 1rem;
border-radius: 10px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
}
.back-btn:hover {
border-color: var(--primary-color);
color: var(--primary-color);
}
.settings-content {
padding: 2.5rem 2rem 3rem;
display: flex;
flex-direction: column;
gap: 2.5rem;
}
.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
}
.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.settings-card h3 {
    margin: 0;
    color: var(--text-primary);
}
.danger-card {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.08), var(--bg-surface));
}
.settings-section {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.settings-section h2 {
font-size: 1.5rem;
color: var(--text-primary);
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border-subtle);
}
.settings-item {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 0.75rem;
}
.settings-item label {
font-size: 1.1rem;
font-weight: 500;
color: var(--text-secondary);
/* allow label to shrink/wrap instead of forcing overflow */
flex: 1 1 auto;
min-width: 0;
}
#themeToggleBtn,
.settings-btn {
padding: 0.6rem 1.2rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
color: var(--text-primary);
font-weight: 600;
border-radius: 10px;
cursor: pointer;
transition: all 0.2s ease;
}
#themeToggleBtn:hover,
.settings-btn:hover {
border-color: var(--primary-color);
color: var(--primary-color);
}
.color-swatch-container {
display: flex;
gap: 1rem;
}
.color-swatch {
width: 40px;
height: 40px;
border-radius: 50%;
border: 3px solid var(--bg-surface);
cursor: pointer;
box-shadow: 0 0 0 2px var(--border-subtle);
transition: all 0.2s ease;
}
.color-swatch:hover {
transform: scale(1.1);
}
.color-swatch.active {
box-shadow: 0 0 0 3px var(--primary-color);
}
.avatar-upload-container {
display: flex;
align-items: center;
gap: 1.5rem;
}
.avatar-preview {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: var(--border-subtle);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355626a' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border: 2px solid var(--border-subtle);
}
[data-theme="dark"] .avatar-preview {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'%3E%3C/path%3E%3Ccircle cx='12' cy='7' r='4'%3E%3C/circle%3E%3C/svg%3E");
background-size: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.avatar-upload-actions {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.avatar-upload-label {
padding: 0.6rem 1.2rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
color: var(--text-primary);
font-weight: 600;
border-radius: 10px;
cursor: pointer;
text-align: center;
}
.avatar-upload-label:hover {
border-color: var(--primary-color);
}
.save-avatar-btn {
padding: 0.6rem 1.2rem;
background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
border: none;
color: #fff;
font-weight: 600;
border-radius: 10px;
cursor: pointer;
}
.preset-avatar-section {
margin-top: 0.75rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.preset-avatar-title {
font-weight: 700;
color: var(--text-secondary);
}
.preset-avatar-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
gap: 0.8rem;
}
.preset-avatar-card {
position: relative;
padding: 0.6rem;
border: 1px solid var(--border-subtle);
border-radius: 12px;
background: var(--bg-surface);
cursor: pointer;
transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.preset-avatar-card:hover {
transform: translateY(-2px);
border-color: var(--primary-color);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.preset-avatar-card.selected {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}
.preset-avatar {
width: 100%;
aspect-ratio: 1 / 1;
border-radius: 10px;
background-size: cover;
background-position: center;
border: 1px solid var(--border-subtle);
}
.preset-avatar-number {
position: absolute;
top: 6px;
left: 8px;
font-size: 0.85rem;
font-weight: 800;
background: var(--bg-surface);
padding: 2px 7px;
border-radius: 999px;
border: 1px solid var(--border-subtle);
color: var(--text-primary);
}
.preset-avatar-hint {
color: var(--text-secondary);
font-size: 0.9rem;
}
.settings-item-column {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.account-fields {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.account-fields input {
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-primary);
}
.account-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}
.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    color: #fff;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-weight: 700;
}
.danger-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-weight: 700;
}
.full-width { width: 100%; }
.account-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 1.1rem;
}
.account-message.success { color: #10b981; }
.account-message.error { color: #ef4444; }
.settings-section .settings-item-column {
    margin-top: 0.5rem;
}

/* ========================================
   MOBILE RESPONSIVE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
  /* LAYOUT - Mobile first */
  .chat-app {
    flex-direction: column;
  }

  /* SIDEBAR - More compact and sticky */
  .sidebar {
    width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 2px solid var(--primary-color-border);
    overflow-y: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-sidebar);
  }

  .sidebar-header {
    padding: 0.85rem 1rem;
    gap: 0.25rem;
  }

  .sidebar-header h2 {
    font-size: 1.3rem;
  }

  .user-info {
    font-size: 0.8rem;
  }

  .sidebar-switcher {
    gap: 0.3rem;
    margin-top: 0.3rem;
  }

  .switch-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }

  /* USER SEARCH */
  .user-search-container {
    padding: 0.6rem 0.75rem;
    gap: 0.3rem;
    margin: 0.5rem 0.75rem;
  }

  #userSearchInput {
    font-size: 16px;
    padding: 0.5rem 0.65rem;
  }

  #userSearchBtn {
    min-width: 38px;
    padding: 0.5rem;
  }

  /* SIDEBAR SECTIONS */
  .section-header {
    padding: 0.75rem 1rem 0.4rem;
  }

  .section-header h3 {
    font-size: 0.75rem;
  }

  .create-group-btn {
    width: 22px;
    height: 22px;
    font-size: 1rem;
  }

  .channels-list {
    padding: 0 0.75rem 0.75rem;
  }

  .dm-channel-btn,
  .group-channel-btn {
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  .dm-avatar {
    width: 35px;
    height: 35px;
    border-radius: 8px;
  }

  /* MAIN CHAT AREA */
  .main-chat {
    height: 65vh;
    flex-direction: column;
  }

  .chat-header {
    padding: 0.85rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-surface);
  }

  .chat-header h3 {
    font-size: 1.1rem;
    margin: 0;
  }

  .chat-actions {
    gap: 0.3rem;
  }

  .icon-btn {
    min-width: 38px;
    min-height: 38px;
    padding: 0.4rem;
  }

  /* MESSAGES CONTAINER */
  .chat-body {
    padding: 1rem 0.75rem;
    flex: 1;
    overflow-y: auto;
  }

  .messages-container {
    padding: 0;
    gap: 0.6rem;
  }

  .message {
    max-width: 88%;
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  .message-username {
    font-size: 0.8rem;
  }

  .message-time {
    font-size: 0.7rem;
  }

  .message-delete-btn {
    font-size: 0.85rem;
    padding: 2px 4px;
  }

  /* MESSAGE INPUT */
  .message-input-container {
    padding: 0.65rem;
    gap: 0.4rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
  }

  #messageInput {
    padding: 0.55rem 0.65rem;
    font-size: 16px;
    border-radius: 8px;
  }

  .send-btn, .emoji-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 0.4rem;
    border-radius: 6px;
  }

  .emoji-picker {
    max-height: 180px;
    max-width: 90vw;
    bottom: 50px;
  }

  /* GROUP CONTACTS SIDEBAR */
  .group-contact-sidebar {
    display: none !important;
  }

  /* SETTINGS PAGE */
  .settings-page {
    padding: 0;
  }

  .settings-header {
    padding: 0.85rem 1rem;
    background: var(--bg-surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .back-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.9rem;
  }

  .settings-container {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .settings-content {
    padding: 0.75rem;
  }

  .settings-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  .settings-section h2 {
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }

  .settings-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .settings-item label {
    min-width: 100%;
    font-size: 0.85rem;
  }

  .settings-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
  }

  /* MODALS ON MOBILE */
  .modal-content {
    width: 95%;
    max-width: 95vw;
    max-height: 85vh;
    margin: auto;
    padding: 1.2rem 1rem;
    border-radius: 12px;
  }

  .modal h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }

  .form-group {
    margin-bottom: 0.8rem;
  }

  .form-group label {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
  }

  .form-group input,
  .form-group textarea {
    padding: 0.6rem 0.75rem;
    font-size: 16px;
  }

  /* TOUCH TARGETS - Minimum 44x44 */
  button {
    min-height: 44px;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
  }

  .submit-btn {
    width: 100%;
    padding: 0.7rem;
  }

  /* COLOR SWATCHES */
  .color-swatch-container {
    gap: 0.6rem;
  }

  .color-swatch {
    width: 50px;
    height: 50px;
  }

  /* AVATAR UPLOAD */
  .avatar-preview {
    width: 80px;
    height: 80px;
  }

  .avatar-upload-actions {
    gap: 0.5rem;
  }

  /* IMPROVED SPACING & TYPOGRAPHY */
  .settings-cards {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 0.9rem;
  }

  .settings-card h3 {
    font-size: 1rem;
  }

  .account-fields {
    margin-bottom: 0.6rem;
  }

  .account-fields input {
    padding: 0.55rem;
    font-size: 16px;
  }

  /* ICON BUTTONS */
  .icon-btn {
    min-width: 42px;
    min-height: 42px;
  }

  .create-group-btn {
    min-width: 38px;
    min-height: 38px;
  }

  /* CONFIRMATION MODAL */
  .confirm-box {
    min-width: 260px;
    max-width: 90vw;
    padding: 1rem;
  }

  .confirm-actions {
    gap: 0.4rem;
  }

  .confirm-no, .confirm-yes {
    flex: 1;
    min-height: 42px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  /* Extra small screens - aggressive optimization */
  
  /* Layout */
  .sidebar {
    max-height: 32vh;
  }

  .main-chat {
    height: 68vh;
  }

  /* Typography */
  .sidebar-header h2 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
  }

  .chat-header h3 {
    font-size: 1rem;
  }

  /* Compact sidebar */
  .sidebar-header {
    padding: 0.7rem 0.85rem;
  }

  .user-info {
    font-size: 0.75rem;
    line-height: 1.2;
  }

  .switch-btn {
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
  }

  /* Search and input */
  .user-search-container {
    padding: 0.5rem 0.65rem;
    margin: 0.4rem 0.65rem;
  }

  #userSearchInput {
    padding: 0.45rem 0.55rem;
    font-size: 15px;
  }

  /* Channels */
  .section-header {
    padding: 0.6rem 0.85rem 0.3rem;
  }

  .channels-list {
    padding: 0 0.65rem 0.65rem;
  }

  .dm-channel-btn,
  .group-channel-btn {
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
  }

  .dm-avatar {
    width: 32px;
    height: 32px;
  }

  .dm-sub {
    font-size: 0.75rem;
  }

  /* Messages */
  .chat-body {
    padding: 0.75rem 0.5rem;
  }

  .messages-container {
    gap: 0.5rem;
  }

  .message {
    max-width: 85%;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  .message-header {
    padding-right: 28px;
  }

  .message-username {
    font-size: 0.75rem;
  }

  .message-time {
    font-size: 0.65rem;
  }

  .message-delete-btn {
    font-size: 0.8rem;
    padding: 1px 3px;
  }

  /* Input area */
  .message-input-container {
    padding: 0.55rem;
    gap: 0.3rem;
  }

  #messageInput {
    padding: 0.5rem 0.6rem;
    font-size: 15px;
    border-radius: 6px;
  }

  .send-btn, .emoji-btn {
    min-width: 34px;
    min-height: 34px;
    padding: 0.35rem;
    font-size: 0.9rem;
  }

  /* Settings */
  .settings-header {
    padding: 0.7rem 0.85rem;
  }

  .back-btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .settings-section h2 {
    font-size: 0.95rem;
  }

  /* Modals */
  .modal-content {
    padding: 1rem 0.85rem;
  }

  .modal h2 {
    font-size: 1.2rem;
  }

  .form-group label {
    font-size: 0.8rem;
  }

  .form-group input {
    padding: 0.5rem 0.6rem;
    font-size: 15px;
  }

  button {
    min-height: 42px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
  }

  .submit-btn {
    padding: 0.65rem;
  }

  /* Avatar */
  .avatar-preview {
    width: 70px;
    height: 70px;
  }

  /* Colors */
  .color-swatch {
    width: 45px;
    height: 45px;
  }

  /* Icon buttons */
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 0.35rem;
  }

  .icon-label {
    display: none;
  }

  /* Badges */
  .unread-badge {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }

  /* Modals */
  .modal-large {
    max-height: 80vh;
  }

  .add-members-container {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .members-available,
  .members-selected {
    max-height: 250px;
  }

  .members-available h3,
  .members-selected h3 {
    font-size: 0.85rem;
  }

  .user-item {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
  }

  .user-item-action {
    width: 24px;
    height: 24px;
  }

  .confirm-box {
    min-width: 240px;
    padding: 0.85rem;
  }

  .confirm-message {
    font-size: 0.95rem;
  }

  .confirm-no, .confirm-yes {
    min-height: 40px;
    font-size: 0.85rem;
  }
}

/* Landscape orientation optimization */
@media (max-height: 500px) {
  .sidebar {
    max-height: 30vh;
  }

  .main-chat {
    height: 70vh;
  }

  .messages-container {
    padding: 0.75rem;
  }

  .message {
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
  }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }

  .message {
    max-width: 85%;
  }

  .settings-cards {
    grid-template-columns: 1fr;
  }

  .group-contact-sidebar {
    width: 220px;
  }
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
  /* Increase button sizes for touch */
  button {
    min-height: 48px;
  }

  /* Remove hover effects that don't work on touch */
  .dm-channel-btn:hover,
  .group-channel-btn:hover {
    transform: none;
  }

  /* Add tap feedback */
  button {
    -webkit-tap-highlight-color: transparent;
  }

  .dm-channel-btn,
  .group-channel-btn {
    -webkit-tap-highlight-color: transparent;
  }
}

/* Mobile styles for add members modal */
@media (max-width: 768px) {
  .modal-large {
    max-height: 90vh;
    width: 95%;
  }

  .add-members-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .members-available,
  .members-selected {
    max-height: 300px;
  }

  .add-members-search {
    flex-direction: column;
  }

  .member-search-input,
  .member-search-btn {
    width: 100%;
  }

  .add-members-actions {
    flex-direction: column-reverse;
  }

  .add-members-actions button {
    width: 100%;
  }

  .user-item {
    padding: 0.65rem 0.8rem;
    font-size: 0.9rem;
  }

  .user-item-action {
    width: 28px;
    height: 28px;
  }

  /* Group contact item with remove button */
  .group-contact-item {
    padding: 0.5rem 0.6rem;
    gap: 0.5rem;
  }

  .group-contact-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }

  .group-contact-name {
    font-size: 0.9rem;
  }

  .group-contact-remove {
    width: 26px;
    height: 26px;
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .group-contact-item {
    padding: 0.45rem 0.55rem;
  }

  .group-contact-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .group-contact-name {
    font-size: 0.85rem;
  }

  .group-contact-remove {
    width: 24px;
    height: 24px;
    font-size: 1.2rem;
  }
}
