/* Custom styles supplémentaires (Tailwind est chargé via CDN dans base.html) */

/* ----------------------------------------------------------------------- */
/* Loader Roussette : poule qui avance et picore                            */
/* ----------------------------------------------------------------------- */
.roussette-loader {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(31, 41, 55, 0.04);
}

/* Cadre dans lequel la poule se déplace (le sol) */
.roussette-stage {
    position: relative;
    width: 60px;
    height: 56px;
    flex-shrink: 0;
    overflow: hidden;
}

.roussette-stage::after {
    /* Le « sol » (petit trait pour suggérer que la poule marche) */
    content: '';
    position: absolute;
    bottom: 0;
    left: 6px;
    right: 6px;
    height: 1px;
    background: rgba(194, 105, 31, 0.25);
    border-radius: 1px;
}

.roussette-chick {
    position: absolute;
    bottom: 1px;
    left: 50%;
    width: 48px;
    height: 48px;
    transform-origin: 60% 100%;
    /* On applique deux animations en parallèle :
       - move-and-peck : la poule avance/recule + se penche pour picorer
       - bob          : un léger rebond vertical pendant la marche      */
    animation:
        roussette-walk-peck 2.6s ease-in-out infinite,
        roussette-bob 0.45s ease-in-out infinite;
}

/* Mouvement principal : 4 pas en avant en se balançant, picore, retour.
   Pivot transform-origin = 60% 100% (pied de la poule). Une rotation positive
   fait basculer la tête vers le bas (vers le sol), une rotation négative la
   ferait monter. */
@keyframes roussette-walk-peck {
    0%   { transform: translateX(-50%) rotate(0deg); }
    18%  { transform: translateX(-30%) rotate(0deg); }    /* avance droit */
    27%  { transform: translateX(-30%) rotate(28deg); }   /* picore vers le bas */
    36%  { transform: translateX(-30%) rotate(0deg); }    /* relève */
    50%  { transform: translateX(-50%) rotate(0deg); }    /* retour centre */
    62%  { transform: translateX(-70%) scaleX(-1) rotate(0deg); } /* part à gauche, retournée */
    71%  { transform: translateX(-70%) scaleX(-1) rotate(28deg); } /* picore vers le bas */
    80%  { transform: translateX(-70%) scaleX(-1) rotate(0deg); } /* relève */
    100% { transform: translateX(-50%) rotate(0deg); }
}

/* Léger rebond vertical pour suggérer la marche */
@keyframes roussette-bob {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -2px; }
}

/* On freeze le bobbing quand la poule picore (rotation appliquée par walk-peck) */
.roussette-chick {
    /* hack : pour que le bob s'estompe pendant le pic, on le ralentit
       cycliquement, mais pour rester simple on laisse les deux tourner */
}

/* Petits grains au sol qui apparaissent quand la poule picore */
.roussette-stage .grain {
    position: absolute;
    bottom: 2px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #c2691f;
    opacity: 0;
    animation: grain-appear 2.6s ease-out infinite;
}
.roussette-stage .grain.g1 { left: 26px; animation-delay: 0.3s; }
.roussette-stage .grain.g2 { left: 33px; animation-delay: 0.5s; }
.roussette-stage .grain.g3 { left: 14px; animation-delay: 1.9s; }

@keyframes grain-appear {
    0%, 25%   { opacity: 0; transform: translateY(0) scale(0.4); }
    30%       { opacity: 0.85; transform: translateY(0) scale(1); }
    36%       { opacity: 0; transform: translateY(0) scale(0.6); }
    100%      { opacity: 0; }
}

/* Texte qui défile : 3 messages de chargement qui se relayent */
.roussette-msg {
    position: relative;
    height: 1.2em;
    overflow: hidden;
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.2;
}

.roussette-msg .roussette-msg-track {
    display: flex;
    flex-direction: column;
    animation: roussette-msg-cycle 7.5s ease-in-out infinite;
}

.roussette-msg .roussette-msg-track > span {
    height: 1.2em;
    line-height: 1.2;
    white-space: nowrap;
}

@keyframes roussette-msg-cycle {
    0%, 28%   { transform: translateY(0); }
    33%, 61%  { transform: translateY(-1.2em); }
    66%, 94%  { transform: translateY(-2.4em); }
    100%      { transform: translateY(-3.6em); }
}

.roussette-title {
    color: #1f2937;
    font-weight: 500;
    margin-bottom: 0.1rem;
}

/* Poule regarde vers la droite (miroir horizontal) */
.roussette-face-right {
    transform: scaleX(-1);
}

/* Conteneur GIF (fond blanc = fond du GIF) */
.roussette-anim-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

/* Logo animé (GIF) — accueil chat + loader recherche */
.roussette-welcome-anim {
    display: block;
    width: min(140px, 42vw);
    height: auto;
    max-height: 110px;
    object-fit: contain;
}

.roussette-anim-wrap {
    flex-shrink: 0;
    width: 80px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 0.5rem;
}

.roussette-anim {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* pas d’animation CSS : le GIF gère le mouvement */
}

/* ----------------------------------------------------------------------- */
/* Chat public — mobile & petits écrans                                       */
/* ----------------------------------------------------------------------- */
.chat-page {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.chat-page #messages {
    width: 100%;
}

.chat-page .chat-composer-bar {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

.chat-new-search-btn {
    display: block;
    width: 100%;
    padding: 0.875rem 1.25rem;
    background-color: #1e3a8a;
    color: #ffffff;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.chat-new-search-btn:hover {
    background-color: #152a63;
}

.chat-new-search-btn:focus-visible {
    outline: 2px solid #c2691f;
    outline-offset: 2px;
}

#composer-stash .chat-composer {
    padding-top: 0.25rem;
}

/* Nouvelle recherche : formulaire dans le fil de conversation (mobile + desktop) */
.chat-composer--inline {
    margin-top: 1rem;
    padding-top: 0.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

/* ----------------------------------------------------------------------- */
/* Page d'accueil — hero + carte recherche                                  */
/* ----------------------------------------------------------------------- */
.chat-setup {
    width: 100%;
}

.chat-hero {
    position: relative;
}

.chat-search-card {
    background: #ffffff;
}

.chat-search-card-body {
    min-height: 8rem;
}

.chat-field-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.375rem;
}

.chat-field-hint {
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
    color: #9ca3af;
    margin-left: 0.25rem;
}

.chat-input-wrap {
    position: relative;
}

.chat-input-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: #9ca3af;
    pointer-events: none;
}

.chat-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: #1f2937;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.chat-input--with-icon {
    padding-left: 2.625rem;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input:hover {
    border-color: #d1d5db;
    background: #fff;
}

.chat-input:focus {
    background: #fff;
    border-color: rgba(30, 58, 138, 0.45);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.chat-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8125rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(180deg, #2348a0 0%, #1e3a8a 100%);
    border: none;
    border-radius: 0.875rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.22);
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.chat-submit-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #1e3a8a 0%, #152a63 100%);
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.28);
}

.chat-submit-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.chat-submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-submit-btn:focus-visible {
    outline: 2px solid #c2691f;
    outline-offset: 2px;
}

.chat-coming-soon {
    padding: 1.25rem 1rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px dashed #d1d5db;
    text-align: center;
}

/* Onglets de mode — une seule ligne (segmented control) */
.chat-mode-tabs {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 0.3125rem;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.chat-mode-tab {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.625rem 0.25rem;
    font-size: clamp(0.6875rem, 2.6vw, 0.8125rem);
    font-weight: 600;
    line-height: 1.2;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 0.625rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    text-align: center;
}

.chat-mode-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-mode-tab:hover:not(:disabled):not(.is-active) {
    color: #1e3a8a;
    background: rgba(255, 255, 255, 0.65);
}

.chat-mode-tab.is-active {
    color: #1e3a8a;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(30, 58, 138, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chat-mode-tab--soon {
    opacity: 0.85;
}

.chat-mode-soon {
    flex-shrink: 0;
    display: inline-block;
    padding: 0.05rem 0.3rem;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #9e5418;
    background: rgba(194, 105, 31, 0.14);
    border-radius: 9999px;
    vertical-align: middle;
}

.chat-mode-tab.is-active .chat-mode-soon {
    color: #9e5418;
    background: rgba(194, 105, 31, 0.12);
}

@media (min-width: 640px) {
    .chat-mode-tab {
        padding: 0.6875rem 0.5rem;
        font-size: 0.8125rem;
    }

    .chat-input {
        padding: 0.8125rem 1rem;
        font-size: 1rem;
    }

    .chat-input--with-icon {
        padding-left: 2.75rem;
    }
}

.chat-page #conversation {
    -webkit-overflow-scrolling: touch;
}

.chat-page .roussette-loader {
    width: 100%;
    max-width: 100%;
}

/* Bulles : pleine largeur utile sur mobile */
.chat-bubble-user {
    max-width: min(92vw, 20rem);
    word-break: break-word;
}

@media (max-width: 639px) {
    .chat-bubble-user {
        max-width: 100%;
    }
}

.chat-bubble-assistant {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    word-break: break-word;
}

/* Cartes offres */
.chat-offer-card {
    display: block;
    overflow: hidden;
}

.chat-offer-body {
    padding: 0.75rem;
}

@media (min-width: 640px) {
    .chat-offer-body {
        padding: 1rem;
    }
}

.chat-offer-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .chat-offer-row {
        gap: 1rem;
    }
}

.chat-offer-thumb {
    width: 5.25rem;
    height: 5.25rem;
    margin: 0;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .chat-offer-thumb {
        width: 7rem;
        height: 7rem;
    }
}

.chat-offer-content {
    min-width: 0;
    flex: 1;
}

.chat-offer-title {
    font-weight: 500;
    color: #1f2937;
    line-height: 1.35;
    word-break: break-word;
}

.chat-offer-identifiers {
    display: none;
}

.chat-offer-desc {
    display: none;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.45;
    word-break: break-word;
}

@media (min-width: 640px) {
    .chat-offer-identifiers {
        display: block;
    }

    .chat-offer-desc {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

.chat-offer-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.chat-offer-avail {
    line-height: 1.2;
}

.chat-offer-price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-offer-price {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.375rem;
    font-weight: 600;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .chat-offer-price {
        font-size: 1.5rem;
    }
}

/* Loader : messages multilignes sur mobile */
@media (max-width: 639px) {
    .chat-offer-title {
        font-size: 0.875rem;
        line-height: 1.3;
    }

    .chat-offer-price {
        font-size: 1.125rem;
    }

    .chat-shipping {
        font-size: 0.6875rem;
    }

    .roussette-loader {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.875rem 1rem;
    }

    .roussette-anim-wrap {
        width: 72px;
        height: 68px;
        margin: 0 auto;
    }

    .roussette-msg {
        height: auto;
        min-height: 1.2em;
        overflow: visible;
    }

    .roussette-msg .roussette-msg-track > span {
        white-space: normal;
        height: auto;
        min-height: 1.2em;
        line-height: 1.35;
        padding: 0.1em 0;
    }

    .roussette-msg .roussette-msg-track {
        animation: none;
        transform: none !important;
    }

    .roussette-msg .roussette-msg-track > span:not(:first-child) {
        display: none;
    }
}

.chat-summary {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #4b5563;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

/* Note étoiles (offres Premium) */
.chat-rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin: 0.35rem 0 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.2;
}

.chat-star {
    font-size: 0.95rem;
    line-height: 1;
}

.chat-star--full,
.chat-star--half {
    color: #f59e0b;
}

.chat-star--half {
    opacity: 0.55;
}

.chat-star--empty {
    color: #d1d5db;
}

.chat-rating-value {
    font-weight: 600;
    color: #374151;
}

.chat-star-count {
    color: #6b7280;
    font-size: 0.75rem;
}

.chat-shipping {
    margin-top: 0.2rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    line-height: 1.3;
}

/* Affichage progressif : squelettes (shimmer) pendant la recherche web */
.chat-premium-live-heading {
    margin-bottom: 0.5rem;
}

.chat-search-pending {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #e5e7eb;
}

.chat-search-pending-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-search-pending-label::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #9ca3af;
    animation: chat-pending-pulse 1.2s ease-in-out infinite;
}

@keyframes chat-pending-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.chat-skeleton-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 1rem;
    border: 1px solid #f3f4f6;
    background: #fafafa;
    overflow: hidden;
}

.chat-skeleton-thumb,
.chat-skeleton-line {
    background: linear-gradient(
        90deg,
        #e5e7eb 0%,
        #f3f4f6 45%,
        #e5e7eb 90%
    );
    background-size: 200% 100%;
    animation: chat-skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: 0.5rem;
}

.chat-skeleton-thumb {
    width: 5rem;
    height: 5rem;
    flex-shrink: 0;
}

.chat-skeleton-lines {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.chat-skeleton-line {
    height: 0.75rem;
    width: 100%;
}

.chat-skeleton-line--short {
    width: 35%;
    height: 0.625rem;
}

.chat-skeleton-line--medium {
    width: 70%;
}

@keyframes chat-skeleton-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
