/**
 * file-context-menu.css
 * Menu Contextuel Universel des Fichiers (Portail www.pugnant-gros.net)
 * Tâche 1.1 : Composant partagé (Popover Desktop & Bottom Sheet tactile Mobile)
 */

/* ==========================================================================
   1. TOILE DE FOND (BACKDROP OVERLAY)
   ========================================================================== */
.file-ctx-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-ctx-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* En mode desktop, le backdrop est invisible mais capte le clic de fermeture */
.file-ctx-backdrop.desktop-transparent {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ==========================================================================
   2. CONTENEUR PRINCIPAL DU MENU
   ========================================================================== */
.file-ctx-menu {
    position: fixed;
    z-index: 99999;
    background: var(--bg-card, #191922);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    font-family: var(--font-family-body, 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    color: var(--text-main, #cbd5e1);
    box-sizing: border-box;
    user-select: none;
    display: none;
    flex-direction: column;
}

.file-ctx-menu.active {
    display: flex;
}

/* ==========================================================================
   3. MODE DESKTOP : POPOVER FLOTTANT
   ========================================================================== */
.file-ctx-menu.mode-desktop {
    width: 270px;
    max-width: 300px;
    border-radius: 10px;
    padding: 4px;
    animation: fileCtxPopoverIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
}

@keyframes fileCtxPopoverIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==========================================================================
   4. MODE MOBILE : BOTTOM SHEET TACTILE
   ========================================================================== */
.file-ctx-menu.mode-mobile {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    max-height: 94vh;
    padding: 3px 10px calc(6px + env(safe-area-inset-bottom, 6px)) 10px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
    animation: fileCtxSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: pan-y;
}

@keyframes fileCtxSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.file-ctx-menu.mode-mobile.closing {
    animation: fileCtxSlideDown 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes fileCtxSlideDown {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(100%);
    }
}

/* Barre de glissement tactile (drag handle) */
.file-ctx-drag-handle {
    display: none;
    width: 32px;
    height: 3px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 9999px;
    margin: 2px auto 2px;
    cursor: grab;
    flex-shrink: 0;
}

.file-ctx-menu.mode-mobile .file-ctx-drag-handle {
    display: block;
}

/* ==========================================================================
   5. EN-TÊTE DU FICHIER (HEADER)
   ========================================================================== */
.file-ctx-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 6px 4px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    margin-bottom: 2px;
    flex-shrink: 0;
}

.file-ctx-file-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.file-ctx-file-icon span.material-symbols-outlined {
    font-size: 17px;
}

.file-ctx-file-meta {
    flex-grow: 1;
    min-width: 0;
}

.file-ctx-filename {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-heading, #ffffff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.file-ctx-subinfo {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--text-muted, #94a3b8);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-ctx-close-btn {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.12s;
    flex-shrink: 0;
}

.file-ctx-close-btn:hover {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.1));
    color: var(--text-heading, #ffffff);
}

/* ==========================================================================
   6. CORPS SCROLLABLE & GROUPES D'ACTIONS
   ========================================================================== */
.file-ctx-body {
    display: flex;
    flex-direction: column;
    gap: 0px;
    overflow-y: auto;
    max-height: calc(94vh - 45px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.file-ctx-body::-webkit-scrollbar {
    width: 4px;
}

.file-ctx-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.file-ctx-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-ctx-group-label {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
    padding: 2px 8px 0px;
    line-height: 1.1;
}

.file-ctx-divider {
    height: 1px;
    background: var(--border-color, rgba(255, 255, 255, 0.08));
    margin: 4px 6px;
    flex-shrink: 0;
}

/* ==========================================================================
   7. ÉLÉMENTS D'ACTION (ITEMS)
   ========================================================================== */
.file-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main, #cbd5e1);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
    text-decoration: none;
    outline: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    min-height: 26px;
}

/* En mode tactile mobile : compact pour éviter le scroll vertical */
.file-ctx-menu.mode-mobile .file-ctx-item {
    padding: 3.5px 8px;
    font-size: 12px;
    min-height: 25px;
    border-radius: 5px;
}

.file-ctx-item:hover,
.file-ctx-item:focus-visible {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
    color: var(--text-heading, #ffffff);
}

.file-ctx-item:active {
    transform: scale(0.985);
}

.file-ctx-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.file-ctx-item-icon span.material-symbols-outlined {
    font-size: 17px;
}

.file-ctx-item-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.file-ctx-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.file-ctx-item-desc {
    display: none; /* Masqué pour compacité maximale sans scroll vertical */
    font-size: 9.5px;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0px;
}

.file-ctx-item-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted, #94a3b8);
    flex-shrink: 0;
}

/* Couleurs spécifiques d'icônes d'action */
.file-ctx-icon-indigo { color: #818cf8; }
.file-ctx-icon-sky { color: #38bdf8; }
.file-ctx-icon-emerald { color: #34d399; }
.file-ctx-icon-amber { color: #fbbf24; }
.file-ctx-icon-purple { color: #c084fc; }
.file-ctx-icon-cyan { color: #22d3ee; }
.file-ctx-icon-rose { color: #fb7185; }
.file-ctx-icon-blue { color: #60a5fa; }
.file-ctx-icon-slate { color: #94a3b8; }

/* ==========================================================================
   8. MODALE DE PRÉVISUALISATION UNIVERSELLE (TÂCHE 1.3)
   ========================================================================== */
.file-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-preview-modal.active {
    display: flex;
    opacity: 1;
}

.file-preview-dialog {
    width: 100%;
    max-width: 1200px;
    height: 88vh;
    max-height: 950px;
    background: var(--bg-card, #16161f);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 16px;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.97);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-preview-modal.active .file-preview-dialog {
    transform: scale(1);
}

/* En-tête de la modale */
.file-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    gap: 12px;
}

.file-preview-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-grow: 1;
}

.file-preview-badge-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-preview-title-area {
    min-width: 0;
    flex-grow: 1;
}

.file-preview-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-heading, #ffffff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.file-preview-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.file-preview-chip {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.file-preview-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.file-preview-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main, #e2e8f0);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.file-preview-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.file-preview-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.12s;
    margin-left: 4px;
}

.file-preview-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Corps de la modale */
.file-preview-body {
    flex-grow: 1;
    overflow: auto;
    position: relative;
    background: #09090e;
    display: flex;
    flex-direction: column;
}

.file-preview-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(9, 9, 14, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    gap: 12px;
}

.file-preview-spinner .spinner-ring {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: filePreviewSpin 0.8s linear infinite;
}

@keyframes filePreviewSpin {
    to { transform: rotate(360deg); }
}

.file-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

.file-preview-media-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow: auto;
}

.file-preview-img {
    max-height: 75vh;
    max-width: 100%;
    object-contain: fit;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.file-preview-video {
    max-height: 75vh;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.file-preview-audio-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.file-preview-audio-disc {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
}

.file-preview-audio-player {
    width: 100%;
    max-width: 480px;
}

.file-preview-code-container {
    padding: 20px;
    margin: 0;
    overflow: auto;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    background: #0d0d14 !important;
    color: #e2e8f0;
    border: none;
    height: 100%;
    box-sizing: border-box;
}

.file-preview-markdown-container {
    padding: 28px;
    overflow: auto;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    color: var(--text-main, #cbd5e1);
    line-height: 1.7;
    box-sizing: border-box;
}

.file-preview-table-container {
    padding: 16px;
    overflow: auto;
    width: 100%;
    box-sizing: border-box;
}

.file-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.file-preview-table th {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    font-weight: 700;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
}

.file-preview-table td {
    padding: 7px 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.file-preview-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

/* Pied de la modale */
.file-preview-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

/* Responsive mobile pour la modale */
@media (max-width: 767px) {
    .file-preview-modal {
        padding: 0;
    }
    .file-preview-dialog {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    .file-preview-header {
        padding: 10px 14px;
    }
    .file-preview-action-btn span:not(.material-symbols-outlined) {
        display: none;
    }
}

/* ==========================================================================
   9. MODALE UNIVERSELLE D'ANALYSE GED & OCR (TÂCHE 3.1)
   ========================================================================== */
.universal-ged-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.universal-ged-modal.active {
    display: flex;
    opacity: 1;
}

.universal-ged-dialog {
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    background: var(--bg-card, #161622);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 16px;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.97);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.universal-ged-modal.active .universal-ged-dialog {
    transform: scale(1);
}

.universal-ged-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    gap: 12px;
}

.universal-ged-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-grow: 1;
}

.universal-ged-badge-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    border: 1px solid rgba(34, 211, 238, 0.3);
    flex-shrink: 0;
}

.universal-ged-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-heading, #ffffff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.universal-ged-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0d0d14;
}

.universal-ged-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.universal-ged-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.universal-ged-card-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #94a3b8);
}

.universal-ged-card-value {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.universal-ged-ocr-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.universal-ged-ocr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.universal-ged-ocr-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.universal-ged-ocr-content {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.6;
    color: #cbd5e1;
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.universal-ged-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}
