@font-face {
    font-family: "SanFrancisco";
    src: url("https://cdn.rawgit.com/AllThingsSmitty/fonts/25983b71/SanFrancisco/sanfranciscodisplay-regular-webfont.woff2") format("woff2"),
        url("https://cdn.rawgit.com/AllThingsSmitty/fonts/25983b71/SanFrancisco/sanfranciscodisplay-regular-webfont.woff") format("woff");
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-weight: normal;
    margin: 0;
    background-color: #f7f7f7;
}

.container {
    margin: 0 auto;
    max-width: 600px;
    padding: 1rem;
}

/* Conteneur de la discussion */
.imessage {
    background-color: #fff;
    border: 1px solid #e5e5ea;
    border-radius: 0.25rem;
    display: flex;
    flex-direction: column;
    font-family: "SanFrancisco";
    font-size: 1.25rem;
    margin: 0 auto 1rem;
    max-width: 600px;
    padding: 0.5rem 1.5rem;
}

/* Styles de base des bulles */
.imessage p,
.call-bubble {
    border-radius: 1.15rem;
    line-height: 1.25;
    max-width: 75%;
    padding: 0.5rem 0.875rem;
    position: relative;
    word-wrap: break-word;
    margin: 0.5rem 0;
    width: fit-content;
    /* ALIGNEMENT À DROITE POUR TOUS */
    align-self: flex-end;
    background-color: #248bf5;
    color: #fff;
}

/* Contenu de l'appel téléphonique */
.call-bubble {
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
}

.call-bubble .icon {
    margin-right: 0.5rem;
    font-size: 1.2em;
}

/* Indicateur de lecture audio */
.call-bubble.playing {
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.7), 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Date/Heure pour chaque message */
.message-timestamp {
    display: flex;
    flex-direction: column-reverse;
    align-self: flex-end;
    /* Assure l'alignement à droite */
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.1rem;
    margin-bottom: 0.5rem;
    margin-right: 0.5rem;
    /* Décalage pour aligner sous la bulle */
}

/* Séparateur de date (jour) */
.date-separator {
    text-align: center;
    margin: 1rem 0;
    font-size: 0.8rem;
    color: #666;
}

/* Styles de la queue pour les bulles (message, appel) */
.imessage p::before,
.imessage p::after,
.call-bubble::before,
.call-bubble::after {
    bottom: -0.1rem;
    content: "";
    height: 1rem;
    position: absolute;
}

.imessage p::before,
.call-bubble::before {
    border-bottom-left-radius: 0.8rem 0.7rem;
    border-right: 1rem solid #248bf5;
    right: -0.35rem;
    transform: translate(0, -0.1rem);
}

.message {
    display: flex;
    flex-direction: column;
}

.imessage p::after,
.call-bubble::after {
    background-color: #fff;
    border-bottom-left-radius: 0.5rem;
    right: -40px;
    transform: translate(-30px, -2px);
    width: 10px;
}

/* Styles pour les messages consécutifs (groupement) */
.no-tail::before {
    display: none !important;
}

.imessage> :not(.date-separator) {
    margin-top: 0.25rem;
}

.imessage .message:not(:last-child) p,
.imessage .image-container:not(:last-child) .image-wrapper,
.imessage .call-bubble:not(:last-child) {
    border-bottom-right-radius: 0.25rem !important;
    margin-bottom: 0.05rem;
}

.imessage .message:not(:last-child) p::before,
.imessage .call-bubble:not(:last-child)::before {
    display: none;
}

.imessage .message:not(:last-child) .message-timestamp,
.imessage .image-container:not(:last-child) .image-timestamp,
.imessage .call-bubble:not(:last-child)~.message-timestamp {
    display: none;
}

.repondeur {
    margin: auto;
    background-color: #cfcfcf;
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
}

/* Styles Images */
.image-container {
    align-self: flex-end;
    max-width: 75%;
    margin: 0.5rem 0;
}

.image-container .image-wrapper {
    position: relative;
    background-color: #248bf5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0.75rem;
}

/* Queue pour l'image (doit être sur le wrapper) */
.image-container:last-child .image-wrapper::before {
    bottom: -0.1rem;
    content: "";
    height: 1rem;
    position: absolute;
    border-bottom-left-radius: 0.8rem 0.7rem;
    border-right: 1rem solid #248bf5;
    right: -0.35rem;
    transform: translate(0, -0.1rem);
    z-index: 10;
}

.image-container:last-child .image-wrapper::after {
    background-color: #fff;
    border-bottom-left-radius: 0.5rem;
    right: -40px;
    transform: translate(-30px, -2px);
    width: 10px;
    bottom: -0.1rem;
    content: "";
    height: 1rem;
    position: absolute;
}

.image-container img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 0.1rem;
}

.image-container .caption {
    background-color: rgba(36, 139, 245, 0.9);
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 0.875rem;
    text-align: left;
    line-height: 1.2;
}

.image-timestamp {
    align-self: flex-end;
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.1rem;
    margin-bottom: 0.5rem;
    margin-right: 0.5rem;
}