/* =========================================================
   LUMESYS MESSAGERIE
   Design : ciel clair + coucher de soleil + nature (conservé)
========================================================= */

:root {
    --sky: #8ecae6;
    --sky-light: #dff6ff;
    --cloud: #ffffff;
    --sun: #ffd166;
    --sunset: #ffb4a2;
    --peach: #ffd6c9;
    --nature: #b7e4c7;
    --green: #74c69d;
    --deep-sky: #277da1;
    --text: #243746;
    --text-soft: #718096;
    --white-glass: rgba(255, 255, 255, 0.78);
    --border: rgba(255, 255, 255, 0.7);
    --shadow: 0 20px 60px rgba(49, 91, 116, 0.15);
    --error: #b42318;
    --error-bg: rgba(180, 35, 24, 0.08);
    --success: #1d6b45;
}

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

body {
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Fond ciel */
.sky-background {
    position: fixed;
    inset: 0;
    z-index: -10;
    overflow: hidden;
    background: linear-gradient(135deg, #dff6ff 0%, #bde0fe 35%, #ffd6c9 72%, #ffe5b4 100%);
}
.sun-glow {
    position: absolute;
    width: 480px;
    height: 480px;
    right: 5%;
    top: -220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 209, 102, 0.65), rgba(255, 180, 162, 0.2) 45%, transparent 70%);
}
.cloud { position: absolute; width: 230px; height: 70px; border-radius: 100px; background: rgba(255,255,255,0.34); filter: blur(1px); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 100px; height: 100px; left: 30px; bottom: 0; }
.cloud::after { width: 130px; height: 130px; right: 25px; bottom: 0; }
.cloud-one { top: 10%; left: 5%; transform: scale(0.8); }
.cloud-two { top: 70%; right: -40px; transform: scale(1.2); }
.cloud-three { top: 38%; left: 48%; transform: scale(0.6); }

/* Application */
.lumina-messenger {
    width: min(1500px, 96vw);
    height: 94vh;
    margin: 3vh auto;
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: var(--shadow);
}

/* Sidebar */
.sidebar {
    width: 380px;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.68);
    border-right: 1px solid rgba(255, 255, 255, 0.8);
}
.brand-header { display: flex; align-items: center; gap: 13px; padding: 24px; }
.brand-logo {
    width: 48px; height: 48px; display: flex; justify-content: center; align-items: center;
    border-radius: 16px; background: linear-gradient(135deg, var(--deep-sky), var(--sky));
    box-shadow: 0 8px 20px rgba(39, 125, 161, 0.25); text-decoration: none;
}
.brand-logo img { width: 34px; height: 34px; object-fit: contain; }
.brand-header h1 { font-size: 24px; letter-spacing: -0.5px; }
.brand-header span { display: block; margin-top: 2px; color: var(--text-soft); font-size: 12px; }

.current-user-card {
    display: flex; align-items: center; gap: 12px; margin: 0 16px 16px; padding: 14px;
    border-radius: 18px; background: rgba(255, 255, 255, 0.72); box-shadow: 0 8px 25px rgba(72, 128, 153, 0.08);
}
.current-user-avatar, .chat-user-avatar {
    width: 48px; height: 48px; flex-shrink: 0; display: flex; justify-content: center; align-items: center;
    border-radius: 50%; color: white; font-weight: 700; font-size: 19px;
    background: linear-gradient(135deg, var(--deep-sky), var(--green)); overflow: hidden;
}
.chat-user-avatar { width: 52px; height: 52px; }
.current-user-avatar img, .chat-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.current-user-info { min-width: 0; flex: 1; }
.current-user-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current-user-info small { display: block; margin-top: 3px; color: var(--text-soft); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messenger-navigation { display: flex; gap: 7px; padding: 0 16px 14px; }
.navigation-button {
    flex: 1; border: none; padding: 10px 8px; border-radius: 12px; cursor: pointer;
    color: var(--text-soft); background: transparent; font-size: 11px; transition: 0.25s ease;
}
.navigation-button span { margin-right: 4px; }
.navigation-button:hover { background: rgba(255, 255, 255, 0.6); }
.navigation-button.active { color: var(--deep-sky); background: rgba(142, 202, 230, 0.22); font-weight: 600; }

.search-box { position: relative; margin: 0 16px 14px; }
.search-box input {
    width: 100%; border: 1px solid rgba(255,255,255,0.8); outline: none; padding: 13px 16px 13px 42px;
    border-radius: 15px; color: var(--text); background: rgba(255,255,255,0.65); transition: 0.25s ease;
}
.search-box input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(142, 202, 230, 0.16); }
.search-icon { position: absolute; left: 16px; top: 10px; color: var(--text-soft); font-size: 21px; pointer-events: none; }

.contacts-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.contacts-list::-webkit-scrollbar, .messages-area::-webkit-scrollbar { width: 5px; }
.contacts-list::-webkit-scrollbar-thumb, .messages-area::-webkit-scrollbar-thumb { background: rgba(39, 125, 161, 0.25); border-radius: 20px; }

.contact-item {
    display: flex; align-items: center; gap: 12px; padding: 13px; margin-bottom: 5px; border-radius: 17px;
    cursor: pointer; transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.contact-item:hover { transform: translateX(3px); background: rgba(255,255,255,0.72); }
.contact-item.active { background: rgba(255,255,255,0.88); box-shadow: 0 8px 25px rgba(39,125,161,0.10); }
.contact-avatar {
    width: 50px; height: 50px; flex-shrink: 0; display: flex; justify-content: center; align-items: center;
    border-radius: 17px; color: white; font-size: 18px; font-weight: 700; overflow: hidden;
    background: linear-gradient(135deg, #8ecae6, #74c69d);
}
.contact-avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-information { min-width: 0; flex: 1; }
.contact-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-location { margin-top: 4px; color: var(--text-soft); font-size: 12px; }
.contact-last-message { max-width: 100%; margin-top: 5px; color: #8a98a5; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { display: flex; gap: 7px; align-items: center; padding: 14px 20px; color: var(--text-soft); font-size: 10px; }

/* Zone chat */
.chat-section { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.empty-conversation {
    height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px; text-align: center;
}
.empty-illustration { position: relative; width: 190px; height: 190px; margin-bottom: 25px; }
.chat-orbit {
    position: absolute; inset: 20px; display: flex; justify-content: center; align-items: center;
    border: 2px dashed rgba(39,125,161,0.25); border-radius: 50%; animation: rotateOrbit 18s linear infinite;
}
.center-chat-icon {
    width: 80px; height: 80px; display: flex; justify-content: center; align-items: center; border-radius: 50%;
    color: white; font-size: 38px; background: linear-gradient(135deg, #277da1, #74c69d); box-shadow: 0 15px 35px rgba(39,125,161,0.25);
}
.orbit-dot { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--sun); }
.orbit-dot:nth-child(1) { top: -6px; left: 50%; }
.orbit-dot:nth-child(2) { right: 0; bottom: 25%; }
.orbit-dot:nth-child(3) { left: 0; bottom: 25%; }
.floating-bubble {
    position: absolute; display: flex; justify-content: center; align-items: center; width: 40px; height: 40px;
    border-radius: 14px; background: rgba(255,255,255,0.75); box-shadow: 0 8px 20px rgba(50,80,100,0.1);
}
.bubble-one { top: 0; right: 0; color: #f4a261; }
.bubble-two { bottom: 5px; left: 0; color: #74c69d; }
.empty-conversation h2 { line-height: 1.35; font-size: 26px; }
.empty-conversation p { max-width: 400px; margin-top: 12px; color: var(--text-soft); line-height: 1.6; }
@keyframes rotateOrbit { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.active-chat { height: 100%; display: none; flex-direction: column; min-height: 0; }
.active-chat.visible { display: flex; }

.chat-header {
    min-height: 82px; flex-shrink: 0; display: flex; align-items: center; gap: 13px; padding: 15px 25px;
    background: rgba(255,255,255,0.7); border-bottom: 1px solid rgba(255,255,255,0.8);
}
.chat-user-details { flex: 1; min-width: 0; }
.chat-user-details h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-user-details span { display: block; margin-top: 4px; color: var(--text-soft); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages-area {
    flex: 1; min-height: 0; overflow-y: auto; padding: 28px 7%; display: flex; flex-direction: column; gap: 10px;
}
.message-row { display: flex; width: 100%; }
.message-row.mine { justify-content: flex-end; }
.message-bubble {
    max-width: min(600px, 75%); padding: 12px 16px; border-radius: 20px; line-height: 1.5; font-size: 14px;
    white-space: pre-wrap; word-break: break-word; box-shadow: 0 5px 15px rgba(60,100,120,0.07);
}
.message-row.mine .message-bubble { border-bottom-right-radius: 5px; color: #234; background: linear-gradient(135deg, #d8f3dc, #b7e4c7); }
.message-row.other .message-bubble { border-bottom-left-radius: 5px; background: rgba(255,255,255,0.88); }
.message-time { margin-top: 5px; text-align: right; color: rgba(70,80,90,0.55); font-size: 10px; }

.composer-status {
    min-height: 22px; padding: 4px 25px 0; font-size: 12px; color: var(--text-soft); background: rgba(255,255,255,0.7);
}
.composer-status.error { color: var(--error); }
.composer-status.success { color: var(--success); }

.message-composer {
    display: flex; align-items: flex-end; gap: 10px; padding: 12px 25px 16px;
    background: rgba(255,255,255,0.7); border-top: 1px solid rgba(255,255,255,0.8);
}
.message-composer textarea {
    flex: 1; resize: none; max-height: 130px; min-height: 44px; padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.9); border-radius: 18px; outline: none; color: var(--text);
    background: rgba(255,255,255,0.8); font-family: inherit; font-size: 14px;
}
.message-composer textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(142,202,230,0.15); }
.message-composer textarea:disabled { opacity: 0.65; cursor: not-allowed; }
.send-button {
    width: 48px; height: 48px; flex-shrink: 0; border: none; border-radius: 16px; color: white; cursor: pointer;
    background: linear-gradient(135deg, #277da1, #74c69d); box-shadow: 0 8px 20px rgba(39,125,161,0.22);
    font-size: 20px; transition: 0.25s ease;
}
.send-button:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 12px 25px rgba(39,125,161,0.3); }
.send-button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.mobile-back-button {
    display: none; border: none; background: transparent; color: var(--deep-sky); font-size: 25px; cursor: pointer; padding: 4px 8px;
}

.loading-state {
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px;
    padding: 40px 20px; color: var(--text-soft); font-size: 13px; text-align: center;
}
.loader {
    width: 28px; height: 28px; border: 3px solid rgba(39,125,161,0.15); border-top-color: var(--deep-sky);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.no-results, .error-state {
    padding: 30px 20px; text-align: center; color: var(--text-soft); font-size: 13px; line-height: 1.5;
}
.error-state { color: var(--error); background: var(--error-bg); margin: 10px; border-radius: 14px; }

@media (max-width: 850px) {
    .lumina-messenger { width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
    .sidebar { width: 100%; min-width: 100%; }
    .chat-section { display: none; }
    .lumina-messenger.chat-open .sidebar { display: none; }
    .lumina-messenger.chat-open .chat-section { display: flex; width: 100%; }
    .mobile-back-button { display: block; }
    .messages-area { padding: 20px 15px; }
    .message-bubble { max-width: 85%; }
    .message-composer, .composer-status, .chat-header { padding-left: 15px; padding-right: 15px; }
}
