/* ============================================================================
   agent-missions-schedule.css
   ----------------------------------------------------------------------------
   Styles dedies au split button "Lancer la mission" + modale "Programmer la mission".
   Palette : violet/indigo (#6366f1) pour tout ce qui touche au scheduling.
   ============================================================================ */

:root {
    --sched-primary: #6366f1;
    --sched-primary-hover: #4f46e5;
    --sched-primary-soft: #eef2ff;
    --sched-primary-soft-border: #c7d2fe;
    --sched-text: #1f2937;
    --sched-muted: #6b7280;
    --sched-border: #e5e7eb;
    --sched-radius: 10px;
    --sched-danger: #ef4444;
    --sched-recommended-bg: #ede9fe;
    --sched-recommended-text: #5b21b6;
}

/* ----------- SPLIT BUTTON SUR LE BOUTON "LANCER LA MISSION" ----------- */
/* margin-left: auto pousse le wrapper a droite du flex container .mission-form-actions
   (l'ancienne règle margin-left: auto sur .mission-submit-btn ne fonctionne plus
   maintenant que le bouton est imbrique dans ce wrapper inline-flex). */
.mission-submit-split,
.mission-followup-split {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    margin-left: auto;
}
.mission-submit-split .mission-submit-btn,
.mission-followup-split .mission-followup-send {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-right: 0;
    margin-left: 0;
}
.mission-submit-split-toggle {
    background: #f1f3f4;
    color: #9aa0a6;
    border: none;
    border-left: 1px solid rgba(154, 160, 166, 0.25);
    border-top-right-radius: 50px;
    border-bottom-right-radius: 50px;
    padding: 0 12px;
    cursor: not-allowed;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}
/* Active : meme bleu que le bouton principal #1a73e8, suit le sync JS */
.mission-submit-split-toggle.active {
    background: #1a73e8;
    color: #fff;
    border-left-color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.2);
}
.mission-submit-split-toggle.active:hover {
    background: #1557b0;
}
/* L'attribut disabled (pose par syncToggleActiveState) garantit que le browser
   bloque les events click au niveau natif, peu importe les handlers JS. */
.mission-submit-split-toggle:disabled {
    cursor: not-allowed;
}
.mission-submit-split-toggle svg {
    width: 14px;
    height: 14px;
}

/* Menu deroulant flottant
   ----------------------------------------------------------------------------
   IMPORTANT — pourquoi `bottom: 100%` (drop-up) plutot que `top: 100%` :
   Le bouton split est dans `.mission-form` qui a `overflow: hidden` (necessaire
   pour respecter le border-radius des inputs et de la barre d'actions). Un menu
   ouvert en `top: 100%` sortirait sous la barre d'actions, hors du conteneur,
   et serait clippe (invisible) — bug rencontre en v1.0.2.
   En ouvrant vers le haut, le menu reste dans le viewport visible du conteneur
   form. C'est aussi le pattern standard ("drop-up") quand le declencheur est
   en bas du conteneur.
   ---------------------------------------------------------------------------- */
.sched-split-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--sched-border);
    border-radius: var(--sched-radius);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.14), 0 12px 24px rgba(0,0,0,0.06);
    min-width: 220px;
    padding: 6px;
    z-index: 4000;
    display: none;
}
.sched-split-menu.open {
    display: block;
}
.sched-split-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--sched-text);
    font-size: 0.95rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}
.sched-split-menu-item:hover {
    background: #f3f4f6;
}
.sched-split-menu-item-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.sched-split-menu-item.run-now .sched-split-menu-item-icon {
    color: #3b82f6;
}
.sched-split-menu-item.schedule .sched-split-menu-item-icon {
    color: var(--sched-primary);
}

/* Variante pour le follow-up : aligner avec mission-followup-send */
.mission-followup-split {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

/* ----------- MODALE "PROGRAMMER LA MISSION" ----------- */
.sched-modal-overlay {
    --sched-modal-primary: #3b82f6;
    --sched-modal-primary-hover: #2563eb;
    --sched-modal-primary-soft: #eff6ff;
    --sched-modal-primary-soft-border: #bfdbfe;
    --sched-modal-primary-selected-bg: #f8fbff;
    --sched-modal-primary-focus: rgba(59, 130, 246, 0.12);
    --sched-modal-recommended-bg: #dbeafe;
    --sched-modal-recommended-text: #1d4ed8;
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}
.sched-modal-overlay.open {
    display: flex;
}
.sched-modal {
    background: #fff;
    border-radius: 14px;
    padding: 0;
    width: 90%;
    max-width: 640px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 32px 64px rgba(0,0,0,0.18);
}
.sched-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--sched-border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.sched-modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--sched-text);
}
.sched-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sched-muted);
    padding: 4px;
    font-size: 1.25rem;
    line-height: 1;
}
.sched-modal-body {
    padding: 18px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Zone nom + description mission (fond neutre, sans bandeau bleu) */
.sched-recap {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.sched-recap:focus-within {
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.35);
}
.sched-recap-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 6px;
}
.sched-recap-edit {
    font-size: 11px;
    font-weight: 700;
    color: var(--sched-modal-primary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.sched-recap-edit:hover { text-decoration: underline; }
.sched-recap-name-input {
    font-weight: 600;
    color: var(--sched-text);
    font-size: 1rem;
    line-height: 1.4;
    border: none;
    background: transparent;
    width: 100%;
    padding: 0;
    margin: 0;
    outline: none;
    box-shadow: none;
    font-family: inherit;
}
.sched-recap-desc-input {
    color: var(--sched-muted);
    font-size: 0.9rem;
    line-height: 1.4;
    border: none;
    background: transparent;
    resize: vertical;
    width: 100%;
    min-height: 74px;
    padding: 0;
    margin: 0;
    outline: none;
    box-shadow: none;
    font-family: inherit;
}
.sched-recap-name-input::placeholder {
    color: #64748b;
}
.sched-recap-desc-input::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Sections de la modale */
.sched-section-label {
    font-size: 11px;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
}

/* Grille frequences 2x3 */
.sched-frequency-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.sched-frequency-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--sched-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    color: var(--sched-text);
    font-size: 0.95rem;
}
.sched-frequency-option:hover {
    border-color: var(--sched-modal-primary-soft-border);
}
.sched-frequency-option.selected {
    border-color: var(--sched-modal-primary);
    background: var(--sched-modal-primary-selected-bg);
}
.sched-frequency-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--sched-border);
    flex-shrink: 0;
    position: relative;
    transition: all 0.15s;
}
.sched-frequency-option.selected .sched-frequency-radio,
.sched-overlap-option.selected .sched-frequency-radio {
    border-color: var(--sched-modal-primary);
}
.sched-frequency-option.selected .sched-frequency-radio::after,
.sched-overlap-option.selected .sched-frequency-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sched-modal-primary);
}

/* Selecteur jours de la semaine */
.sched-days-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.sched-day-btn {
    padding: 10px 0;
    border: 1.5px solid var(--sched-border);
    border-radius: 8px;
    background: #fff;
    color: var(--sched-text);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: all 0.15s;
}
.sched-day-btn[data-day="dim"] {
    color: var(--sched-danger);
}
.sched-day-btn.selected {
    background: var(--sched-modal-primary);
    color: #fff;
    border-color: var(--sched-modal-primary);
}
.sched-day-btn[data-day="dim"].selected {
    background: var(--sched-modal-primary);
    color: #fff;
}

/* Inputs */
.sched-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.sched-field {
    display: flex;
    flex-direction: column;
}
.sched-input,
.sched-select {
    padding: 10px 12px;
    border: 1.5px solid var(--sched-border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--sched-text);
    outline: none;
    background: #fff;
    transition: border-color 0.15s;
    box-sizing: border-box;
    width: 100%;
}
.sched-input:focus,
.sched-select:focus {
    border-color: var(--sched-modal-primary);
    box-shadow: 0 0 0 3px var(--sched-modal-primary-focus);
}
.sched-input.error {
    border-color: var(--sched-danger);
    background: #fef2f2;
}
.sched-input-help {
    font-size: 11px;
    font-weight: 700;
    color: var(--sched-modal-primary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    align-self: flex-end;
    margin-bottom: 4px;
}
.sched-input-help:hover { text-decoration: underline; }

.sched-field-flex-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

/* Apercu next */
.sched-preview {
    background: var(--sched-modal-primary-soft);
    border: 1px solid var(--sched-modal-primary-soft-border);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.sched-preview-icon {
    color: var(--sched-modal-primary);
    flex-shrink: 0;
    margin-top: 2px;
}
.sched-preview-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--sched-text);
    font-size: 0.9rem;
}
.sched-preview-main {
    font-weight: 600;
}
.sched-preview-sub {
    color: var(--sched-muted);
    font-size: 0.85rem;
}

/* Politique de chevauchement */
.sched-overlap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sched-overlap-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--sched-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    font-size: 0.95rem;
    color: var(--sched-text);
}
.sched-overlap-option.selected {
    border-color: var(--sched-modal-primary);
    background: var(--sched-modal-primary-selected-bg);
}
.sched-overlap-option .sched-frequency-radio {
    width: 18px;
    height: 18px;
}
.sched-overlap-badge {
    margin-left: auto;
    background: var(--sched-modal-recommended-bg);
    color: var(--sched-modal-recommended-text);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Erreur inline */
.sched-error-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: var(--sched-danger);
    font-size: 0.9rem;
}
.sched-error-banner.show { display: flex; }
.sched-error-banner svg { flex-shrink: 0; }

/* Footer */
.sched-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--sched-border);
    background: #fff;
    position: sticky;
    bottom: 0;
}
.sched-cancel-btn {
    background: none;
    border: none;
    color: var(--sched-muted);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    border-radius: 8px;
}
.sched-cancel-btn:hover { background: #f3f4f6; color: var(--sched-text); }
.sched-submit-btn {
    background: var(--sched-modal-primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}
.sched-submit-btn:hover { background: var(--sched-modal-primary-hover); }
.sched-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast pour confirmation */
.sched-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #ffffff;
    border: 1px solid var(--sched-primary-soft-border);
    border-left: 4px solid var(--sched-primary);
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
    z-index: 9999;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.3s, transform 0.3s;
}
.sched-toast.hidden { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.sched-toast-title { font-weight: 600; color: var(--sched-text); font-size: 0.95rem; }
.sched-toast-msg { font-size: 0.85rem; color: var(--sched-muted); }
.sched-toast-link {
    margin-top: 4px;
    color: var(--sched-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
}
.sched-toast-link:hover { text-decoration: underline; }

/* ============================================================================
   PACK K14 (2026-05-16) — Section "CAPACITES" : toggle Web (bleu Google)
   ----------------------------------------------------------------------------
   Reproduit le mockup fourni : un toggle switch iOS-like "Web" sous une
   section "CAPACITES" intercalee entre le recap et le bloc Frequence.
   La couleur du switch actif est le bleu Google (#1a73e8) pour faire echo
   au bouton WEB de la barre prompt (PACK K13). Le toggle est entierement
   pilote par <input type="checkbox" id="sched-web-toggle">.
   ============================================================================ */

.sched-capacities-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sched-capacity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sched-capacity-row:hover {
    border-color: #d1d5db;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sched-capacity-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--sched-text, #1f2937);
    user-select: none;
}

.sched-capacity-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.sched-capacity-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

.sched-capacity-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e0;
    border-radius: 24px;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sched-capacity-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sched-capacity-switch input[type="checkbox"]:checked + .sched-capacity-slider {
    background: #1a73e8;
}

.sched-capacity-switch input[type="checkbox"]:checked + .sched-capacity-slider::before {
    transform: translateX(20px);
}

.sched-capacity-switch input[type="checkbox"]:focus-visible + .sched-capacity-slider {
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.25);
}

.sched-capacity-switch input[type="checkbox"]:disabled + .sched-capacity-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   PACK K28 (2026-05-17) - Tooltip explicatif sur le label "Memoire".
   ----------------------------------------------------------------------------
   Permet a l'utilisateur de comprendre la portee de l'option avant de
   l'activer. Affichage au hover ET au focus clavier (accessibilite).
   ============================================================================ */

.sched-capacity-label-with-tooltip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sched-capacity-tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    outline: none;
}

.sched-capacity-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.sched-capacity-tooltip-wrapper:hover .sched-capacity-tooltip-icon,
.sched-capacity-tooltip-wrapper:focus .sched-capacity-tooltip-icon {
    background: #1a73e8;
    color: #ffffff;
}

.sched-capacity-tooltip-content {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    padding: 10px 12px;
    background: #1f2937;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 100;
    white-space: normal;
    text-align: left;
}

.sched-capacity-tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.sched-capacity-tooltip-wrapper:hover .sched-capacity-tooltip-content,
.sched-capacity-tooltip-wrapper:focus .sched-capacity-tooltip-content,
.sched-capacity-tooltip-wrapper:focus-visible .sched-capacity-tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   PACK K27 (2026-05-17) — Capacites etendues : ligne LLM Provider/Modele
   ----------------------------------------------------------------------------
   Grille 2-cols pour les dropdowns Provider/Modele dans la section Capacites.
   Sous-label discret en majuscules (style coherent avec .sched-section-label).
   ============================================================================ */

.sched-capacity-llm-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px 18px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
}

.sched-capacity-sublabel {
    font-size: 11px;
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

.sched-capacity-warning {
    margin: -2px 0 0;
    padding: 10px 14px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    color: #92400e;
    font-size: 0.85rem;
    line-height: 1.4;
}
