/*
 * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
 * See LICENSE in the project root for license information.
 */

:root {
    --gold: #C9A84C;
    --gold-dark: #8B6914;
    --ink: #34395B;
    --cream: #FFFFFF;
    --page-bg: #F2F3F8;
    --ink-soft: #454B72;
    --ink-muted: #767CA0;
    --green: #4CAF50;
    --red: #E24B4A;
    --orange: #E8A020;
    --blue: #2C5F8A;
    --purple: #6B3FA0;
    --halo-rgb: 201, 168, 76;
    --halo-rgb-dark: 139, 105, 20;
    /* Couleur des contours/bordures des conteneurs (dropdowns, cartes, textarea...). Par defaut
       identique a --gold-dark (aucun changement pour les themes Gold/Silver/Navy) ; le theme
       Blanc la redefinit seule pour unifier toutes les lignes sur --gold sans changer la couleur
       des libelles/icones/fonds de bouton, qui restent sur --gold-dark. */
    --line: var(--gold-dark);

    --doctype-modern-native: #4CAF50;
    --doctype-modern-scan: #2196F3;
    --doctype-old-print: #FF9800;
    --doctype-very-old: #9C27B0;
    --doctype-scan-vision: #2196F3;

    --field-muted-bg: #F3F5FA;
}

[data-theme="gold"] {
    --ink: #1A1814;
    --ink-soft: #3D3A34;
    --ink-muted: #7A776E;
    --cream: #FFFEFB;
    --page-bg: #FBF8F0;
    --field-muted-bg: #F7F5F0;
}

[data-theme="silver"] {
    --gold: #AEB4BA;
    --gold-dark: #666D73;
    --ink: #1A1814;
    --ink-soft: #3D3A34;
    --ink-muted: #7A776E;
    --cream: #FAFAF9;
    --page-bg: #EFEFED;
    --halo-rgb: 174, 180, 186;
    --halo-rgb-dark: 102, 109, 115;
    --field-muted-bg: #F5F4F3;
}

/* Theme blanc/moderne : fond blanc quasi-pur. --gold/--gold-dark gardent leurs teintes d'origine
   (les libelles en majuscules comme "SESSION" restent inchanges) ; seule --line -- les contours
   des conteneurs (dropdowns, cartes, separateurs, boutons) -- est alignee sur --gold pour que
   toutes les lignes se lisent comme une seule et meme couleur. Le bleu Praetor reste reserve
   a --ink (titres, texte), repris tel quel du theme Navy par defaut. */
[data-theme="blanc"] {
    --gold: #C9A84C;
    --gold-dark: #8B6914;
    --line: var(--gold);
    --ink: #34395B;
    --ink-soft: #454B72;
    --ink-muted: #767CA0;
    --cream: #FFFFFF;
    --page-bg: #FAFAFA;
    --halo-rgb: 201, 168, 76;
    --halo-rgb-dark: 139, 105, 20;
    --field-muted-bg: #F4F4F5;
}

 html,
 body {
     width: 100%;
     height: 100%;
     margin: 0;
     padding: 0;
 }
 
 ul {
     margin: 0;
     padding: 0;
 }
 
 .ms-welcome__header {
    padding: 8px 16px;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-justify-content: center;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: var(--ink);
    border-top: 3px solid var(--gold);
    border-bottom: 3px solid var(--gold);
 }

 .ms-welcome__header img {
    width: 32px;
    height: 32px;
 }

 body.ms-welcome {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    height: 100%;
    background: var(--page-bg);
    color: var(--ink);
 }

 .ms-welcome__main {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-align-items: stretch;
    align-items: stretch;
    -webkit-flex: 1 0 0;
    flex: 1 0 0;
    padding: 10px 20px;
 }

 .mail-field {
     margin-bottom: 14px;
 }

 .mail-field--tight {
     margin-bottom: 4px;
 }

 .recipient-block {
     display: flex;
     align-items: center;
     gap: 8px;
 }

 .recipient-info {
     -ms-flex: 1 1 auto;
     flex: 1 1 auto;
     min-width: 0;
 }

 .recipient-row {
     display: flex;
     align-items: baseline;
     gap: 6px;
 }

 .recipient-name {
     color: var(--ink);
     font-weight: 600;
 }

 .recipient-email {
     color: var(--ink-muted);
     font-size: 0.9em;
 }

 .mail-field--grow {
     flex: 1 0 auto;
     display: flex;
     flex-direction: column;
     min-height: 0;
 }

 .mail-value {
     margin: 4px 0 0 0;
 }

 .ms-welcome__main > h2 {
     width: 100%;
     text-align: center;
 }

b {
    font-weight: 600;
    color: var(--gold-dark);
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.06em;
}

.is-hidden {
    display: none;
}

[role="button"]:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.is-disabled {
    opacity: 0.6;
    cursor: default;
    animation: none;
}

.generate-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scrollable-fields {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

#settings-page .generate-row,
#user-info-page .generate-row,
#attachments-page .generate-row {
    margin-bottom: 14px;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.attachment-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 4px;
}

.attachment-list-name-wrap {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
}

.attachment-list-source {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
}

.attachment-list-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-list-checkbox {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    accent-color: var(--gold-dark);
    cursor: pointer;
}

.attachment-list-checkbox:disabled {
    cursor: default;
    opacity: 0.6;
}

.attachment-list-actions {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.attachment-scan-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
}

.attachment-scan-status[data-scanned="true"] {
    color: var(--green);
}

.attachment-list-item--unreadable {
    background: transparent;
    border-style: dashed;
    border-color: var(--ink-muted);
    opacity: 0.65;
}

.attachment-list-item--unreadable .attachment-list-name {
    color: var(--ink-muted);
    text-decoration: line-through;
}

.attachment-list-item--excluded {
    opacity: 0.65;
}

.attachment-list-item--excluded .attachment-list-name {
    color: var(--ink-muted);
    text-decoration: line-through;
}

.attachment-list-unreadable {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    color: var(--red);
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.attachment-list-empty {
    color: var(--ink-soft);
}

.attachments-select-all-link {
    align-self: flex-end;
    color: var(--gold-dark);
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    margin: 6px 2px 6px 0;
}

.attachments-select-all-link:hover {
    color: var(--ink);
}

.dropdown {
    position: relative;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--ink);
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.dropdown-trigger .icon-chevron {
    flex: 0 0 auto;
    transition: transform 0.15s ease;
}

.dropdown.is-open .dropdown-trigger .icon-chevron {
    transform: rotate(180deg);
}

.dropdown.is-open .dropdown-trigger {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.dropdown-list {
    position: absolute;
    z-index: 10;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    box-sizing: border-box;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(26, 24, 20, 0.18);
}

.dropdown-list.is-hidden {
    display: none;
}

.dropdown-item {
    padding: 6px 8px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--ink);
    border-radius: 3px;
    cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item.is-active {
    background: var(--gold-dark);
    color: #ffffff;
}

.dropdown-item.is-selected {
    background: rgba(var(--halo-rgb), 0.55);
    color: var(--ink);
}

.dropdown-item.is-selected:hover,
.dropdown-item.is-selected.is-active {
    background: var(--gold-dark);
    color: #ffffff;
}

.reply-text-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#edit-reply.is-active {
    background: var(--gold);
    border-color: var(--gold-dark);
    color: var(--ink);
}

#license-retry,
#identity-retry,
#technical-retry,
#settings-save,
#user-info-save,
#attachments-page-validate,
#settings-logout {
    display: inline-block;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 6px 16px;
    margin: 4px 0;
    cursor: pointer;
}

.generate-row #settings-save,
.generate-row #user-info-save,
.generate-row #attachments-page-validate,
.generate-row #settings-logout {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    text-align: center;
}

#license-error,
#identity-error,
#technical-error,
#service-unavailable {
    align-items: center;
    text-align: center;
    padding-top: 32px;
    gap: 6px;
}

#license-error .icon-error,
#identity-error .icon-error,
#technical-error .icon-error,
#service-unavailable .icon-error {
    color: var(--red);
    margin-bottom: 4px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

#license-error h2,
#identity-error h2,
#technical-error h2,
#service-unavailable h2 {
    font-weight: 700;
}

#license-error p,
#identity-error p,
#technical-error p,
#service-unavailable p {
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 8px 0 20px;
    padding: 0 12px;
}

#license-retry,
#identity-retry,
#technical-retry,
#service-unavailable-retry {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    text-align: center;
    width: 140px;
    height: 20px;
}

.reply-feedback.is-hidden {
    display: none;
}

.reply-feedback-label {
    color: var(--ink-muted);
    font-size: 0.75em;
    font-style: italic;
    margin: 0 0 6px;
}

.reply-feedback-row {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reply-feedback-buttons {
    display: -webkit-flex;
    display: flex;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.reply-feedback-comment {
    display: block;
    box-sizing: border-box;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    resize: vertical;
    font-family: inherit;
    font-size: inherit;
    background: #ffffff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 6px 8px;
    margin: 0;
}

.reply-feedback-comment:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.reply-feedback-comment::placeholder {
    color: var(--ink-muted);
}

.reply-feedback-submit {
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    align-items: center;
    align-self: center;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 6px 16px;
    margin: 10px 0 0;
    cursor: pointer;
}

.reply-feedback-submit .ms-Button-label {
    color: var(--ink);
    font-weight: 600;
}

.reply-feedback-submit:hover {
    background: var(--gold);
    border-color: var(--gold-dark);
}

.reply-feedback-submit:hover .ms-Button-label {
    color: #ffffff;
}

.reply-feedback-submit.is-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.round-icon-button.reply-feedback-button--up {
    border-color: var(--green);
    color: var(--green);
}

.round-icon-button.reply-feedback-button--up:hover {
    background: var(--green);
    border-color: var(--green);
    color: #ffffff;
}

.round-icon-button.reply-feedback-button--up.is-selected {
    background: var(--green);
    border-color: var(--green);
    color: #ffffff;
}

.round-icon-button.reply-feedback-button--down {
    border-color: var(--red);
    color: var(--red);
}

.round-icon-button.reply-feedback-button--down:hover {
    background: var(--red);
    border-color: var(--red);
    color: #ffffff;
}

.round-icon-button.reply-feedback-button--down.is-selected {
    background: var(--red);
    border-color: var(--red);
    color: #ffffff;
}

.generate-reply-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.generate-reply-loading.is-hidden {
    display: none;
}

#generate-reply-label {
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#generate-reply-label.is-hidden {
    display: none;
}

#license-retry .ms-Button-label,
#identity-retry .ms-Button-label,
#technical-retry .ms-Button-label,
#settings-save .ms-Button-label,
#user-info-save .ms-Button-label,
#attachments-page-validate .ms-Button-label,
#cgu-required-accept .ms-Button-label {
    color: var(--ink);
    font-weight: 600;
}

#license-retry:hover,
#identity-retry:hover,
#technical-retry:hover,
#settings-save:hover,
#user-info-save:hover,
#attachments-page-validate:hover,
#cgu-required-accept:not(.is-disabled):hover {
    background: var(--gold);
    border-color: var(--gold-dark);
}

#license-retry:hover .ms-Button-label,
#identity-retry:hover .ms-Button-label,
#technical-retry:hover .ms-Button-label,
#settings-save:hover .ms-Button-label,
#user-info-save:hover .ms-Button-label,
#attachments-page-validate:hover .ms-Button-label,
#cgu-required-accept:not(.is-disabled):hover .ms-Button-label {
    color: #ffffff;
}

/* Sélecteurs par id (pas par classe) : le bouton de base hérite déjà de #settings-logout via
   l'allowlist plus haut (background/border), une classe ne peut pas l'emporter sur un id -- même
   règle que pour #settings-save:hover etc. juste au-dessus. */
#settings-logout {
    border-color: var(--line);
}

#settings-logout .ms-Button-label {
    color: var(--ink-muted);
    font-weight: 600;
}

#settings-logout:not(.is-disabled):hover {
    background: var(--red);
    border-color: var(--red);
}

#settings-logout:not(.is-disabled):hover .ms-Button-label {
    color: #ffffff;
}

#cgu-required {
    align-items: center;
    text-align: center;
    padding-top: 32px;
    gap: 6px;
}

#cgu-required .icon-error {
    color: var(--gold-dark);
    margin-bottom: 4px;
    flex-shrink: 0;
}

#cgu-required h2 {
    font-weight: 700;
}

.cgu-required-text {
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 8px 0 4px;
    padding: 0 12px;
}

#cgu-required-read-link {
    color: var(--gold-dark);
    font-weight: 600;
}

#cgu-required-read-link:hover {
    color: var(--ink);
}

.cgu-required-checkbox-row {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    margin: 10px 0 20px;
    text-align: left;
}

.cgu-required-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    accent-color: var(--gold-dark);
    cursor: pointer;
}

.cgu-required-checkbox-row label {
    cursor: pointer;
    color: var(--ink);
}

#cgu-required-accept {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: 4px;
    width: 140px;
    padding: 8px 0;
    margin: 4px 0;
    cursor: pointer;
}

#license-retry:hover .spinner,
#identity-retry:hover .spinner,
#technical-retry:hover .spinner {
    border-color: #ffffff;
    border-top-color: transparent;
}

.toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--gold);
    position: relative;
}

.ai-disclaimer {
    color: var(--ink-muted);
    font-size: 0.75em;
    font-style: italic;
    margin: 4px 0 0;
}

.attachments-processing-notice {
    color: var(--gold-dark);
    font-size: 0.8em;
    margin: 0 0 6px;
}

.attachments-import-button {
    margin-bottom: 6px;
    cursor: pointer;
}

.attachments-import-icon {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
}

.attachments-import-icon svg {
    width: 14px;
    height: 14px;
}

.attachments-import-label {
    color: var(--ink-soft);
    font-size: 0.95em;
}

.attachments-import-button:hover {
    border-color: var(--gold);
}

.attachments-import-button:hover .attachments-import-icon,
.attachments-import-button:hover .attachments-import-label {
    color: var(--gold-dark);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.round-icon-button {
    display: inline-flex;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    margin: 4px 0;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink-soft);
    cursor: pointer;
}

.round-icon-button--small {
    width: 18px;
    height: 18px;
}

.round-icon-button:hover {
    background: var(--cream);
    border-color: var(--gold);
    color: var(--gold-dark);
}

.round-icon-button.is-hidden {
    display: none;
}

.round-icon-button.is-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-width: 0;
    background: var(--cream);
    border: 1px solid var(--gold-dark);
    border-radius: 22px;
    padding: 5px 5px 5px 10px;
}

.chat-input-insert {
    width: 32px;
    height: 32px;
}

.chat-input-bar:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.chat-input-bar .round-icon-button {
    margin: 0;
}

.chat-input-attach {
    position: relative;
}

.attachments-used-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--gold-dark);
    color: var(--cream);
    font-size: 9px;
    line-height: 1;
    font-weight: 700;
    pointer-events: none;
}

.attachments-used-badge.is-hidden {
    display: none;
}

.chat-input-textarea-wrap {
    position: relative;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-width: 0;
}

.chat-input-textarea {
    width: 100%;
    box-sizing: border-box;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: var(--ink);
    padding: 7px 0;
    height: 30px;
    max-height: 120px;
    /* Trident/EdgeHTML dessine les fleches grises de la scrollbar des qu'overflow-y vaut auto,
       meme sans debordement : on reste a hidden et autoResizeInstruction() ne repasse a auto
       qu'une fois max-height atteinte. */
    overflow-y: hidden;
    line-height: 16px;
}

.chat-input-textarea::-webkit-scrollbar {
    width: 6px;
}

.chat-input-textarea::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 3px;
}

.chat-input-textarea::placeholder {
    /* Le texte visible du placeholder est rendu par #reply-instruction-placeholder
       (calque superposé, voir bindInstructionPlaceholderMarquee dans outlook.ts) : un
       ::placeholder natif ne peut pas défiler au survol pour rester lisible même tronqué. */
    color: transparent;
}

.chat-input-placeholder-overlay {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    box-sizing: border-box;
    padding: 7px 0;
    overflow: hidden;
    line-height: 16px;
    pointer-events: none;
    visibility: hidden;
}

#reply-instruction:placeholder-shown ~ .chat-input-placeholder-overlay {
    visibility: visible;
}

.chat-input-placeholder-overlay-text {
    display: inline-block;
    color: var(--ink-muted);
    white-space: nowrap;
}

.chat-input-placeholder-overlay-text.is-scrolling {
    animation: chat-placeholder-scroll 4s ease-in-out infinite;
}

@keyframes chat-placeholder-scroll {
    0%, 10% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(var(--placeholder-overflow, 0));
    }
    90%, 100% {
        transform: translateX(0);
    }
}

.chat-input-send {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gold);
    border: 1px solid var(--gold-dark);
    color: #ffffff;
    cursor: pointer;
}

.chat-input-send:hover {
    background: var(--gold-dark);
    color: #ffffff;
}

.chat-input-send .spinner {
    border-color: #ffffff;
    border-top-color: transparent;
}

.chat-input-send.is-disabled {
    opacity: 0.5;
    cursor: default;
    animation: none;
}

.chat-input-send-icon {
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-input-send-icon.is-hidden {
    display: none;
}

#generate-reply-loading,
#generate-reply-cancel {
    display: none;
}

.chat-input-send.is-loading #generate-reply-label {
    display: none;
}

.chat-input-send.is-loading #generate-reply-loading {
    display: inline-flex;
}

.chat-input-send.is-loading:hover #generate-reply-loading {
    display: none;
}

.chat-input-send.is-loading:hover #generate-reply-cancel {
    display: inline-flex;
}

.chat-input-send.is-loading:hover {
    background: var(--ink);
    border-color: var(--ink);
}

#dictate-instruction.is-recording {
    border-color: var(--red);
    color: var(--red);
    animation: praetor-recording-pulse 1.2s ease-in-out infinite;
}

@keyframes praetor-recording-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(226, 75, 74, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(226, 75, 74, 0.15);
    }
}

.reply-instruction {
    -ms-flex: none;
    flex: none;
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    resize: vertical;
    font-family: inherit;
    font-size: inherit;
    background: var(--cream);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0 0 0;
}

.reply-instruction:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

/* Aligne la hauteur de ces champs texte sur celle des dropdowns Fonction/Genre (.dropdown-trigger). */
.user-info-field-input {
    min-height: 0;
    padding: 6px 10px;
    font-size: 0.85em;
}

#settings-consigne {
    min-height: 240px;
}

#user-info-office {
    min-height: 70px;
    font-size: 1.05em;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--gold);
    border-top-color: transparent;
    border-radius: 50%;
    animation: praetor-spin 0.7s linear infinite;
}

@keyframes praetor-spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner.is-hidden {
    display: none;
}

.reply-status {
    font-size: 0.9em;
    color: var(--ink-muted);
    margin: 6px 0;
    white-space: normal;
    overflow-wrap: break-word;
}

.reply-status:empty {
    margin: 0;
    line-height: 0;
}

.reply-status--error {
    color: var(--red);
}

.reply-status--pending {
    font-style: italic;
}

.attachments-status {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: normal;
}

.attachments-status.is-hidden {
    display: none;
}

#attachments-status-text {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
}

.reply-text-wrap {
    position: relative;
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
    min-height: 130px;
    margin: 4px 0 0 0;
    resize: vertical;
    overflow: hidden;
}

.reply-text-highlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    box-sizing: border-box;
    margin: 0;
    padding: 8px;
    overflow: hidden;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    /* Ce calque est en pointer-events:none : sa position de defilement est entierement pilotee par
       JS (highlightElement.scrollTop = textElement.scrollTop, voir renderReplyHighlight/
       bindReplyTextHighlight dans ui/replyHighlight.ts), donc pas besoin de sa propre scrollbar --
       overflow: hidden (herite du raccourci ci-dessus) suffit et evite une deuxieme scrollbar native
       superposee a celle du vrai textarea, qui grignotait les coins arrondis sur ce moteur. */
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 4px;
    pointer-events: none;
}

.reply-text-wrap.is-readonly .reply-text-highlight {
    background: var(--field-muted-bg);
    color: var(--ink-soft);
}

.reply-text-wrap.is-focused .reply-text-highlight {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.reply-text-highlight mark {
    background: rgba(var(--halo-rgb), 0.35);
    color: var(--gold-dark);
    font-weight: 600;
    border-radius: 2px;
}

.reply-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    resize: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    background: transparent;
    color: transparent;
    caret-color: var(--ink);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 8px;
    margin: 0;
}

/* Scrollbar fine plutot que celle par defaut du navigateur : plus discrete, elle grignote beaucoup
   moins le coin arrondi que la scrollbar large par defaut -- meme traitement que sur
   .chat-input-textarea. */
.reply-text::-webkit-scrollbar {
    width: 6px;
}

.reply-text::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 3px;
}

.reply-text:focus {
    outline: none;
}

.reply-text::placeholder {
    color: var(--ink-muted);
    opacity: 1;
}

.bracket-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    background: rgba(26, 24, 20, 0.45);
    padding: 20px;
    box-sizing: border-box;
}

.bracket-warning-overlay.is-hidden {
    display: none;
}

.bracket-warning-box {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: 6px;
    padding: 20px;
    max-width: 100%;
    box-shadow: 0 6px 20px rgba(26, 24, 20, 0.3);
}

.bracket-warning-box .icon-error {
    color: var(--red);
    margin-bottom: 4px;
}

.bracket-warning-box h2 {
    margin: 0;
    font-weight: 700;
    color: var(--ink);
}

.bracket-warning-box p {
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 8px 0 16px;
    white-space: pre-line;
}

.bracket-warning-actions {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bracket-warning-actions .ms-Button {
    display: inline-block;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
}

.bracket-warning-actions .ms-Button:hover {
    background: var(--gold);
    border-color: var(--gold-dark);
}

.bracket-warning-actions .ms-Button:hover .ms-Button-label {
    color: #ffffff;
}

#bracket-warning-confirm {
    background: var(--ink);
    border-color: var(--ink);
}

#bracket-warning-confirm .ms-Button-label {
    color: #ffffff;
    font-weight: 600;
}

#bracket-warning-confirm:hover {
    background: var(--red);
    border-color: var(--red);
}

#info-popup-ok {
    background: var(--ink);
    border-color: var(--ink);
}

#info-popup-ok .ms-Button-label {
    color: #ffffff;
    font-weight: 600;
}

#info-popup-ok:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
}