* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 35%),
        radial-gradient(circle at bottom right, #dcfce7 0, transparent 30%),
        #f1f5f9;
    color: #0f172a;
}

body > h1,
body > h2,
body > p,
#accesHub,
#interfaceHub {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

h1 {
    margin-top: 10px;
    margin-bottom: 8px;
    font-size: 32px;
    letter-spacing: -0.04em;
    color: #0f172a;
}

h2 {
    margin-top: 0;
    color: #334155;
}

#accesHub,
#interfaceHub {
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 28px;
    padding: 22px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

#interfaceHub {
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#enteteHub {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-shrink: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

#enteteHub h1 {
    margin-top: 0;
}

#enteteHub p {
    margin-top: 0;
    margin-bottom: 10px;
    color: #64748b;
}

#boutonDeconnexion {
    flex-shrink: 0;
    background: linear-gradient(135deg, #64748b, #475569);
    box-shadow: 0 10px 24px rgba(71, 85, 105, 0.22);
}

#zoneConversation {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px 0 10px;
}

#zoneConversation #messages {
    flex: 1;
    min-height: 0;
    height: auto;
    margin-bottom: 8px;
}

#zoneEnvoi {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
}

#zoneEnvoi textarea {
    flex: 1;
    width: auto;
}

#zoneEnvoi button {
    width: auto;
    min-width: 105px;
}

#identiteLocale {
    display: inline-block;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: normal;
}

#identiteLocale strong {
    font-weight: 700;
}

#messages {
    height: 460px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid #e2e8f0;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.95));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
    width: 10px;
}

#messages::-webkit-scrollbar-track {
    background: transparent;
}

#messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.message {
    position: relative;
    max-width: 72%;
    padding: 10px 13px;
    margin: 8px 0;
    border-radius: 20px;
    white-space: pre-wrap;
    line-height: 1.35;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    animation: messageApparition 0.18s ease-out;

    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: start;
}

.message > div:nth-child(2) {
    grid-column: 1 / 3;
    grid-row: 2;
}

@keyframes messageApparition {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.moi {
    margin-left: auto;
    text-align: left;
    color: #052e16;
    background: linear-gradient(135deg, #bbf7d0, #86efac);
    border-bottom-right-radius: 6px;
}

.autre {
    margin-right: auto;
    text-align: left;
    color: #172554;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-bottom-left-radius: 6px;
}

.auteur {
    grid-column: 1;
    grid-row: 1;
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 0;
    opacity: 0.72;
}

.heure {
    grid-column: 2;
    grid-row: 1;
    font-size: 11px;
    color: rgba(15, 23, 42, 0.55);
    margin-top: 0;
    text-align: right;
    white-space: nowrap;
    align-self: center;
}

.heure.lu {
    color: #2563eb;
    font-weight: 700;
}

.message-systeme {
    text-align: center;
    color: #64748b;
    font-style: italic;
    margin: 12px auto;
    font-size: 13px;
}

#indicateurEcriture {
    min-height: 22px;
    margin: 4px 0 10px;
    color: #64748b;
    font-style: italic;
    font-size: 13px;
}

textarea {
    width: calc(100% - 125px);
    min-height: 48px;
    max-height: 130px;
    padding: 13px 15px;
    resize: vertical;
    font-family: Arial, sans-serif;
    vertical-align: middle;
    border: 1px solid #cbd5e1;
    border-radius: 18px;
    outline: none;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

textarea:focus,
input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.22);
}

button {
    min-height: 44px;
    padding: 11px 18px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.34);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
}

input,
select {
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    outline: none;
    background: white;
    color: #0f172a;
}

#accesHub input {
    width: 100%;
    max-width: 320px;
    margin: 6px 8px 8px 0;
}

.connecte {
    color: #16a34a;
    font-weight: bold;
}

.deconnecte {
    color: #dc2626;
    font-weight: bold;
}

.separateur-nouveaux-messages {
    width: fit-content;
    max-width: 80%;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    margin: 18px auto;
    padding: 7px 14px;
    border-radius: 999px;
    background: #ffffff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

#zoneTestMicro {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#boutonTestMicro {
    width: auto;
    min-height: auto;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: #f8fafc;
    color: #334155;
    border: 1px solid #cbd5e1;
    box-shadow: none;
}

#resultatTestMicro {
    font-size: 13px;
    color: #475569;
}

#boutonChargerAnciens {
    width: fit-content;
    max-width: 90%;
    margin: 0 auto 10px;
    padding: 7px 13px;
    min-height: auto;
    display: none;
    border-radius: 999px;
    background: #ffffff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

@media (max-width: 700px) {
    body {
        padding: 12px;
    }

    #accesHub,
    #interfaceHub {
        border-radius: 22px;
        padding: 16px;
    }

    #messages {
        height: 65vh;
        padding: 12px;
    }

    .message {
        max-width: 86%;
    }

    textarea {
        width: 100%;
        margin-bottom: 8px;
    }

    button {
        width: 100%;
    }

    #interfaceHub {
        height: calc(100vh - 24px);
    }

    #boutonDeconnexion {
        width: 100%;
    }

    #zoneEnvoi {
        flex-direction: column;
    }

    #zoneEnvoi textarea,
    #zoneEnvoi button {
        width: 100%;
    }

    #accesHub {
        width: 100%;
        max-width: 420px;
        min-height: calc(100vh - 24px);
        margin: 0 auto;
        padding: 34px 24px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-radius: 34px;
    }

    #accesHub::before {
        content: "💬";
        width: 64px;
        height: 64px;
        margin: 0 auto 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 22px;
        background: linear-gradient(135deg, #2563eb, #22c55e);
        color: white;
        font-size: 30px;
        box-shadow: 0 14px 30px rgba(37, 99, 235, 0.28);
    }

    #accesHub h1 {
        font-size: 36px;
        text-align: center;
        margin-bottom: 10px;
    }

    #accesHub p {
        max-width: 280px;
        margin: 0 auto 22px;
        text-align: center;
        color: #64748b;
        line-height: 1.45;
        font-size: 15px;
    }

    #accesHub input {
        width: 100%;
        max-width: none;
        margin: 9px 0;
        font-size: 16px;
        padding: 17px 18px;
        border-radius: 18px;
        background: #f8fafc;
        border: 1px solid #dbe3ef;
    }

    #accesHub button {
        width: 100%;
        margin-top: 14px;
        font-size: 16px;
        padding: 16px 18px;
        border-radius: 18px;
    }

    #erreurAcces {
        min-height: 22px;
        text-align: center;
        color: #dc2626;
        font-weight: 700;

    }

    #enteteHub {
        flex-direction: column;
        gap: 8px;
        padding-bottom: 10px;
    }

    #enteteHub h1 {
    font-size: 34px;
    margin-bottom: 2px;
    }

    #enteteHub p {
        font-size: 15px;
        margin-bottom: 8px;
    }

    #identiteLocale {
        font-size: 14px;
        padding: 8px 12px;
        margin-bottom: 4px;
    }
    
    #zoneTestMicro {
        justify-content: center;
        gap: 6px;
    }

    #boutonTestMicro {
        width: auto;
        font-size: 12px;
        padding: 6px 10px;
    }

    #resultatTestMicro {
        font-size: 12px;
    }

    #boutonDeconnexion {
        width: auto;
        min-height: 38px;
        padding: 9px 14px;
        font-size: 14px;
        border-radius: 14px;
        align-self: flex-start;
    }

    #boutonChargerAnciens {
        width: fit-content;
        max-width: 88%;
        font-size: 12px;
        padding: 6px 11px;
        margin-bottom: 8px;
    }

    #zoneEnvoi {
        gap: 8px;
        padding-top: 10px;
    }

    #zoneEnvoi textarea {
        min-height: 50px;
        max-height: 95px;
        resize: none;
        font-size: 15px;
        border-radius: 18px;
    }

    #zoneEnvoi button {
        min-height: 46px;
        border-radius: 18px;
    }

    #zoneConversation {
    padding: 10px 0 8px;
    }

    #zoneConversation #messages {
        padding: 10px;
        border-radius: 22px;
    }

    .message {
        width: 94%;
        max-width: 94%;
        padding: 9px 12px;
        margin: 7px 0;
        border-radius: 18px;
        font-size: 15px;

        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 10px;
        row-gap: 4px;
        align-items: start;
    }

    .message > div:nth-child(2) {
        grid-column: 1 / 3;
        grid-row: 2;
    }

    .auteur {
        grid-column: 1;
        grid-row: 1;
        font-size: 12px;
        margin-bottom: 0;
    }

    .heure {
        grid-column: 2;
        grid-row: 1;
        font-size: 12px;
        margin-top: 0;
        text-align: right;
        white-space: nowrap;
        align-self: center;
    }

    .moi {
        margin-left: auto;
        margin-right: 0;
    }

    .autre {
        margin-left: 0;
        margin-right: auto;
    }

    .message-systeme {
        font-size: 12px;
        margin: 10px auto;
    }

    .separateur-nouveaux-messages {
        font-size: 12px;
        margin: 14px auto;
        padding: 6px 12px;
    }

}
