/** Modale renommer facture + bouton crayon fichier */
/* ═══════════════════════════════════════════════════════════════════════════
   Modale "Renommer la facture"
   ───────────────────────────────────────────────────────────────────────────
   Markup dans includes/dashboard/modals/rename-modal.php.
   Pilotée par js/dashboard-rename-modal.js (window.openRenameFactureModal).
   Réutilisée par dashboard.php ET archives/index.php.
   ═══════════════════════════════════════════════════════════════════════════ */

.rename-modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 5000;
    align-items: center; justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}
.rename-modal-overlay.is-open { display: flex; }
.rename-modal-overlay[hidden] { display: none !important; }
/* Protège tous les éléments [hidden] du modal contre les `display:flex` /
   `display:block` des règles ci-dessous (l'attribut HTML hidden a une
   priorité plus faible que les règles CSS auteur). */
.rename-modal-overlay [hidden] { display: none !important; }

.rename-modal-box {
    background: #fff;
    border-radius: var(--radius-lg, 8px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    width: 96vw; max-width: 1400px;
    height: 92vh; max-height: 92vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: renameModalSlide .2s ease;
}
@keyframes renameModalSlide {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rename-modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    background: var(--gray-50, #fafbfc);
}
.rename-modal-title    { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--gray-900, #0f172a); }
.rename-modal-filename { font-size: 0.78rem; color: var(--gray-500, #64748b); margin-top: 2px; font-family: ui-monospace, monospace; }
.rename-modal-close {
    background: none; border: 0; cursor: pointer;
    line-height: 1; color: var(--gray-500, #64748b);
    padding: 6px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
}
.rename-modal-close:hover { background: var(--gray-100, #f1f5f9); color: var(--gray-900, #0f172a); }

.rename-modal-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.rename-modal-pdf  { flex: 1; min-width: 0; background: var(--gray-100, #f1f5f9); border-right: 1px solid var(--gray-200, #e5e7eb); }
.rename-modal-pdf iframe { width: 100%; height: 100%; border: 0; display: block; }
.rename-modal-form {
    flex: 0 0 420px; max-width: 420px;
    padding: 20px 24px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 14px;
}

.rename-modal-callout {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px;
    background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.8rem; color: #92400e; line-height: 1.45;
}
.rename-modal-callout-icon { flex-shrink: 0; line-height: 1; color: #d97706; display: inline-flex; align-items: center; margin-top: 1px; }

.rename-modal-lbl { font-size: 0.75rem; font-weight: 500; color: var(--gray-500, #6b7280); display: block; margin-bottom: 4px; }
.rename-modal-req { color: var(--color-danger-text, #dc2626); }
.rename-modal-input {
    padding: 7px 12px;
    border: 1.5px solid var(--gray-200, #e2e8f0); border-radius: 6px;
    font-size: 0.8125rem;
    transition: border-color .15s, box-shadow .15s;
}
.rename-modal-input:focus { outline: none; border-color: var(--brand-blue, #006EB9); box-shadow: 0 0 0 3px rgba(0, 110, 185, .12); }
.rename-modal-input--full { width: 100%; box-sizing: border-box; }
.rename-modal-input-mono  { font-family: ui-monospace, monospace; }

.rename-modal-siren-row { display: flex; gap: 8px; }
.rename-modal-siren-row .rename-modal-input { flex: 1; }
.rename-modal-siren-btn {
    padding: 7px 14px; background: var(--brand-blue, #006EB9); color: #fff;
    border: none; border-radius: 6px; cursor: pointer;
    font-weight: 600; font-size: 0.85rem;
}
.rename-modal-siren-btn:hover:not(:disabled) { background: var(--brand-blue-hover, #005a9e); }
.rename-modal-siren-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.rename-modal-siren-result {
    margin-top: 6px; padding: 8px 10px; border-radius: 6px; font-size: 0.78rem;
}
.rename-modal-siren-result.is-ok  { background: #ecfdf5; color: #065f46; }
.rename-modal-siren-result.is-err { background: #fef2f2; color: #991b1b; }

.rename-modal-hr { border: none; border-top: 1px solid var(--gray-100, #f1f5f9); margin: 0; }

.rename-modal-fname-pre {
    background: var(--brand-blue-soft, #eff6ff);
    border: 1px solid #bfdbfe; border-radius: 8px;
    padding: 10px 14px; font-size: 0.78rem; color: #1e40af;
}
.rename-modal-fname-pre-label { display: block; margin-bottom: 3px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; }
.rename-modal-fname-text { font-family: ui-monospace, monospace; word-break: break-all; }

.rename-modal-error {
    padding: 10px 14px; background: #fee2e2; color: #b91c1c;
    border-radius: 6px; font-size: 0.84rem;
    display: flex; align-items: center; gap: 8px;
}
.rename-modal-error[hidden] { display: none; }
.rename-modal-error svg { flex-shrink: 0; }

.rename-modal-footer {
    padding: 12px 24px; border-top: 1px solid var(--gray-200, #e5e7eb);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--gray-50, #fafbfc); flex-shrink: 0;
}
.rename-modal-hint { flex: 1; font-size: 0.8rem; color: var(--gray-500, #64748b); text-align: center; }
.rename-modal-cancel-btn {
    padding: 8px 16px; background: #fff; color: var(--gray-700, #374151);
    border: 1px solid var(--gray-200, #e2e8f0); border-radius: 6px;
    font-weight: 500; cursor: pointer; font-size: 0.875rem;
}
.rename-modal-cancel-btn:hover { background: var(--gray-50, #f8fafc); }
.rename-modal-submit-btn {
    padding: 8px 20px; background: var(--brand-blue, #006EB9); color: #fff;
    border: none; border-radius: 6px;
    font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
.rename-modal-submit-btn:hover:not(:disabled) { background: var(--brand-blue-hover, #005a9e); }
.rename-modal-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── Statut de la détection IA (modale protocole d'accord) ─────────────
   L'analyse est déclenchée automatiquement à l'ouverture de la modale
   (même UX que l'OCR des factures). On affiche un bandeau discret pour
   informer l'utilisateur de l'état : loading / succès / échec. */
.protocole-modal-intro { margin-bottom: 14px; }
.protocole-modal-ai-status {
    margin-top: 6px; padding: 8px 10px;
    border-radius: 6px; font-size: 0.82rem;
    display: flex; align-items: center; gap: 8px;
    background: #f8fafc; color: #475569; border: 1px solid #e2e8f0;
}
.protocole-modal-ai-status[hidden] { display: none; }
.protocole-modal-ai-status.is-loading {
    background: linear-gradient(135deg, #eef2ff 0%, #ede9fe 100%);
    color: #4338ca; border-color: #c7d2fe;
}
.protocole-modal-ai-status.is-loading::before {
    content: ''; width: 12px; height: 12px; flex-shrink: 0;
    border: 2px solid #c7d2fe; border-top-color: #4338ca;
    border-radius: 50%; animation: proto-ai-spin .8s linear infinite;
}
.protocole-modal-ai-status.is-ok  {
    background: #f0fdf4; color: #059669; border-color: #a7f3d0;
}
.protocole-modal-ai-status.is-err {
    background: #fef2f2; color: #b91c1c; border-color: #fecaca;
}
@keyframes proto-ai-spin { to { transform: rotate(360deg); } }

/* Icône crayon "Renommer" — affiché à côté du nom de fichier dans le dashboard
   et les archives. Toujours visible mais très discret (gris pâle), se renforce
   au hover de la row entière (pattern Notion/Linear). */
.file-name-row {
    display: inline-flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
}
.file-rename-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    background: transparent; border: 0; padding: 0;
    color: var(--gray-400, #94a3b8);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity .12s, color .12s, background .12s;
}
.file-rename-btn svg { width: 14px; height: 14px; }
tr:hover .file-rename-btn { opacity: 0.85; }
.file-rename-btn:hover {
    opacity: 1;
    color: var(--brand-blue, #006EB9);
    background: var(--brand-blue-soft, #eff6ff);
}
.file-rename-btn:focus-visible {
    outline: none;
    opacity: 1;
    box-shadow: 0 0 0 2px var(--brand-blue, #006EB9);
}

/* Variante archive : la cellule "file-cell" des archives n'a pas la classe
   .file-name-row autour du nom. On force l'alignement inline pour que l'icône
   reste à côté du texte sans casser le wrap. */
.file-cell .file-cell-name { display: inline; }
.file-cell .file-rename-btn { vertical-align: middle; margin-left: 4px; }

/* Rename modal mobile : voir css/responsive/modals.css */
