/* FileManager Module Styles */

/* ============================================
   FIX: Override Dolibarr input styles
   Dolibarr sets border-bottom-*-radius: 0 !important on :focus
   We need to override this with more specific selectors
   ============================================ */
.filemanager-container input[type="text"],
.filemanager-container input[type="search"],
.filemanager-container input[type="number"],
.fm-search input,
.fm-mobile-search-input-wrapper input,
#search-input,
#mobile-search-input {
    border-radius: 4px !important;
    border-top-left-radius: 4px !important;
    border-top-right-radius: 4px !important;
    border-bottom-left-radius: 4px !important;
    border-bottom-right-radius: 4px !important;
}

/* Override Dolibarr :focus style that removes bottom border-radius */
.filemanager-container input[type="text"]:focus,
.filemanager-container input[type="search"]:focus,
.filemanager-container input[type="number"]:focus,
.fm-search input:focus,
.fm-mobile-search-input-wrapper input:focus,
#search-input:focus,
#mobile-search-input:focus {
    border-radius: 4px !important;
    border-top-left-radius: 4px !important;
    border-top-right-radius: 4px !important;
    border-bottom-left-radius: 4px !important;
    border-bottom-right-radius: 4px !important;
    border-bottom: 1px solid #0066cc !important;
}

/* FontAwesome Spin Animation Fallback */
@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.fa-spin {
    animation: fa-spin 1s infinite linear !important;
}

/* Loading States */
.fm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
}
.fm-loading .fa-spinner,
.fm-loading .fa-globe {
    color: #0066cc;
    margin-bottom: 15px;
}
.fm-loading p {
    margin: 0;
    font-size: 14px;
}

/* Main App Layout */
.filemanager-app {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    min-height: 600px;
}

/* Sidebar - Directory Tree */
.filemanager-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header .btn {
    width: 100%;
    font-size: 13px;
}

/* Directory Tree */
.directory-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.tree-root,
.tree-children {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tree-children {
    padding-left: 20px;
    display: none;
}

.tree-item {
    margin: 2px 0;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tree-toggle {
    width: 20px;
    cursor: pointer;
    flex-shrink: 0;
    color: #6c757d;
}

.tree-toggle:hover {
    color: #007bff;
}

.tree-spacer {
    width: 20px;
    flex-shrink: 0;
}

.tree-link {
    flex: 1;
    padding: 6px 10px;
    border-radius: 4px;
    text-decoration: none !important;
    color: #495057 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.tree-link:hover {
    background: #e9ecef;
    color: #007bff !important;
}

.tree-item.active > .tree-node > .tree-link,
.tree-item.active > .tree-link {
    background: #007bff;
    color: #fff !important;
    font-weight: 600;
}

.tree-link i {
    font-size: 14px;
}

/* Main Content Area */
.filemanager-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Breadcrumb */
.filemanager-breadcrumb {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 15px;
}

.filemanager-breadcrumb nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 14px;
}

.breadcrumb-item {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item:hover {
    color: #0056b3;
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #495057;
    font-weight: 600;
}

.filemanager-breadcrumb i.fa-chevron-right {
    font-size: 10px;
    color: #6c757d;
}

/* ERP breadcrumb indicator */
.fm-breadcrumb-erp {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 11px;
    color: #666;
}

.fm-breadcrumb-erp strong {
    color: #000;
    font-weight: 500;
}

/* Toolbar */
.filemanager-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    flex-wrap: wrap;
    min-height: 44px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.toolbar-left {
    flex: 1;
}

/* Boutons toolbar compacts avec marges verticales */
.filemanager-toolbar .btn {
    padding: 5px 10px;
    font-size: 12px;
    height: 28px;
    line-height: 1;
}

.filemanager-toolbar .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
    height: 24px;
}

.toolbar-left .alert {
    margin: 0;
    padding: 6px 10px;
    font-size: 12px;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #007bff;
    color: #fff !important;
    border-color: #007bff;
}

.btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: #fff !important;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background: #545b62;
    border-color: #545b62;
}

.btn-danger {
    background: #dc3545;
    color: #fff !important;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* View Switcher */
.view-switcher {
    display: flex;
    gap: 3px;
}

.btn-view {
    padding: 5px 8px;
    border: 1px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.3s;
    font-size: 12px;
    height: 28px;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-view:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.btn-view.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* Search Box */
.search-box {
    min-width: 150px;
    max-width: 200px;
}

.search-input {
    width: 100%;
    padding: 5px 10px;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    font-size: 12px;
    height: 28px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* Upload Form */
.upload-form {
    background: #fff;
    border: 2px dashed #007bff;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    text-align: center;
}

.upload-area {
    margin-bottom: 20px;
}

.upload-label {
    display: block;
    color: #007bff;
    font-size: 16px;
    margin-bottom: 15px;
    cursor: pointer;
}

.upload-label i {
    display: block;
    margin-bottom: 10px;
    color: #007bff;
}

.upload-form input[type="file"] {
    display: block;
    margin: 0 auto;
    max-width: 400px;
}

.upload-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* Files Container */
.files-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    min-height: 400px;
}

/* File Card */
.file-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #007bff;
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 150px;
    margin-bottom: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
}

.file-thumbnail {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 4px;
    cursor: zoom-in;
}

.file-icon {
    color: #6c757d;
}

.file-image .file-icon {
    color: #28a745;
}

.file-pdf .file-icon {
    color: #dc3545;
}

.file-doc .file-icon {
    color: #2c5aa0;
}

.file-xls .file-icon {
    color: #217346;
}

.file-archive .file-icon {
    color: #ffc107;
}

.file-video .file-icon {
    color: #6f42c1;
}

/* File Details */
.file-details {
    flex: 1;
    margin-bottom: 10px;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    word-wrap: break-word;
    line-height: 1.4;
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #6c757d;
}

.file-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* File Actions */
.file-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.file-card:hover .file-actions {
    opacity: 1;
}

.btn-action {
    flex: 1;
    padding: 6px 10px;
    background: #007bff;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 13px;
}

.btn-action:hover {
    background: #0056b3;
}

.btn-delete {
    background: #dc3545 !important;
}

.btn-delete:hover {
    background: #c82333 !important;
}

/* List View */
.files-container.list-view {
    grid-template-columns: 1fr;
}

.files-container.list-view .file-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
}

.files-container.list-view .file-preview {
    height: 60px;
    width: 60px;
    margin-bottom: 0;
}

.files-container.list-view .file-details {
    margin-bottom: 0;
}

.files-container.list-view .file-meta {
    flex-direction: row;
    gap: 15px;
}

.files-container.list-view .file-actions {
    opacity: 1;
    border: none;
    padding: 0;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #6c757d;
}

.empty-state i {
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 16px;
    margin: 0 0 20px 0;
}

/* Hidden class for filtering */
.file-card.hidden {
    display: none !important;
}

/* Responsive Design */

/* Mobile Sidebar Toggle Button */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s;
}

.mobile-sidebar-toggle:active {
    transform: scale(0.95);
}

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

@media (max-width: 992px) {
    .filemanager-app {
        flex-direction: column;
    }

    /* Sidebar devient un panneau coulissant sur tablette */
    .filemanager-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 320px;
        max-width: 85vw;
        z-index: 999;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .filemanager-sidebar.open {
        left: 0;
    }

    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 768px) {
    /* COMPACT Mobile - Toolbar compact, priorité à l'espace fichiers */

    /* Toolbar compacte - une seule ligne */
    .fm-toolbar {
        padding: 6px 8px;
        gap: 4px;
        flex-wrap: nowrap;
        min-height: auto;
    }

    .fm-toolbar-left,
    .fm-toolbar-right {
        gap: 2px;
        flex-wrap: nowrap;
    }

    /* Boutons compacts - icônes uniquement */
    .fm-btn {
        padding: 5px 7px;
        font-size: 11px;
        min-height: 28px;
        min-width: 28px;
    }

    .fm-btn .fas,
    .fm-btn .fa {
        font-size: 12px;
    }

    /* Cacher le texte des boutons sur mobile */
    .fm-toolbar-left .fm-btn span:not(.fas):not(.fa):not(.badge),
    .fm-toolbar-right .fm-btn span:not(.fas):not(.fa):not(.badge) {
        display: none;
    }

    .fm-btn-sm {
        padding: 4px 6px;
        font-size: 11px;
        min-height: 26px;
        min-width: 26px;
    }

    /* Bulk/Contextual actions compacts */
    .fm-bulk-actions,
    .fm-contextual-actions {
        gap: 3px;
        padding: 2px 4px;
        margin-left: 4px;
    }

    .fm-bulk-actions .bulk-count,
    .fm-contextual-actions .contextual-label {
        font-size: 10px;
        max-width: 80px;
    }

    /* Séparateur plus petit */
    .fm-toolbar-separator {
        margin: 0 4px;
        height: 20px;
    }

    /* Search bar compacte */
    .fm-search-container {
        max-width: 120px;
        flex: 0 1 auto;
    }

    .fm-search-bar input {
        padding: 5px 8px;
        font-size: 13px;
        min-height: 28px;
    }

    /* Breadcrumb compact */
    .fm-breadcrumb {
        padding: 4px 8px;
        font-size: 11px;
    }

    .fm-breadcrumb-item {
        max-width: 80px;
        padding: 2px 4px;
    }

    /* Zone fichiers - 2 colonnes minimum */
    .fm-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 6px;
        padding: 6px;
    }

    /* Items compacts */
    .fm-item {
        padding: 6px;
    }

    .fm-item-icon {
        font-size: 32px;
        margin-bottom: 4px;
    }

    img.fm-item-thumb,
    div.fm-item-thumb {
        width: 50px;
        height: 50px;
    }

    .fm-item-name {
        font-size: 11px;
        max-height: 2.6em;
    }

    /* Preview panel compacte ou cachée */
    .fm-preview-panel {
        display: none;
    }

    .fm-preview-panel.visible {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
    }

    /* Liste compacte */
    .fm-list-item {
        padding: 6px 8px;
        font-size: 12px;
    }

    .fm-list-header {
        display: none;
    }

    /* Modales adaptées */
    .fm-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    /* Legacy classes (for backward compatibility) */
    .btn {
        padding: 6px 10px;
        font-size: 12px;
        min-height: 32px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 11px;
        min-height: 28px;
    }

    .filemanager-toolbar {
        padding: 6px 8px;
        gap: 4px;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 2px;
    }

    .toolbar-left .btn,
    .toolbar-right .btn {
        flex: 0 0 auto;
        min-width: 32px;
    }

    .search-box {
        max-width: 100px;
    }

    .search-input {
        padding: 5px 8px;
        font-size: 13px;
        min-height: 28px;
    }

    .btn-view {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 36px;
        min-height: 32px;
    }

    .filemanager-breadcrumb {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* Grid - 2+ colonnes */
    .files-container {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 6px;
        padding: 6px;
    }

    .file-card {
        padding: 6px;
    }

    .file-preview {
        height: 60px;
    }

    .file-name {
        font-size: 11px;
    }

    .file-actions {
        display: none;
    }

    .file-card:active .file-actions,
    .file-card:focus .file-actions {
        display: flex;
    }

    .btn-action {
        padding: 5px 8px;
        font-size: 11px;
        min-height: 28px;
    }

    .files-container.list-view {
        gap: 4px;
    }

    .files-container.list-view .file-card {
        grid-template-columns: 50px 1fr;
        gap: 8px;
        padding: 6px;
    }

    .files-container.list-view .file-preview {
        height: 50px;
        width: 50px;
    }

    .files-container.list-view .file-actions {
        display: none;
    }

    .files-container.list-view .file-meta {
        flex-direction: column;
        gap: 6px;
    }

    /* Upload form mobile-friendly */
    .upload-form {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    .upload-actions {
        flex-direction: column;
        gap: 10px;
    }

    .upload-actions .btn {
        width: 100%;
    }

    /* Sidebar mobile */
    .filemanager-sidebar {
        width: 85vw;
        max-width: 320px;
    }

    .sidebar-header {
        padding: 12px;
    }

    .sidebar-header h3 {
        font-size: 15px;
    }

    /* Tree navigation avec zones tactiles plus grandes */
    .tree-link {
        padding: 10px 12px;
        font-size: 14px;
        min-height: 44px;
    }

    .tree-toggle {
        width: 30px;
        font-size: 16px;
        padding: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tree-spacer {
        width: 30px;
    }

    .tree-children {
        padding-left: 30px;
    }

    /* Alerts plus compactes */
    .alert {
        padding: 10px 15px;
        font-size: 14px;
    }

    /* Empty state */
    .empty-state {
        padding: 40px 20px;
    }

    .empty-state i {
        font-size: 48px;
    }

    .empty-state p {
        font-size: 15px;
    }
}

/* Extra small devices (phones in portrait, less than 480px) */
@media (max-width: 480px) {
    .filemanager-app {
        margin: 0;
        gap: 4px;
    }

    /* Ultra compact toolbar */
    .fm-toolbar,
    .filemanager-toolbar {
        padding: 4px 6px;
        gap: 2px;
    }

    .fm-toolbar-left,
    .fm-toolbar-right,
    .toolbar-left,
    .toolbar-right {
        gap: 1px;
    }

    /* Boutons ultra compacts - icônes seulement */
    .fm-btn,
    .btn {
        padding: 4px 6px;
        min-height: 28px;
        min-width: 28px;
        font-size: 11px;
    }

    .fm-btn .fas,
    .fm-btn .fa {
        font-size: 12px;
    }

    /* Cacher TOUT le texte sur très petit écran */
    .fm-toolbar .fm-btn span:not(.fas):not(.fa):not(.badge),
    .toolbar-left .btn span:not(.fas):not(.fa),
    .toolbar-right .btn span:not(.fas):not(.fa) {
        display: none !important;
    }

    /* Search keeps a full row on very small screens */
    .fm-search-container,
    .search-box {
        max-width: none;
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .fm-search-bar input,
    .search-input {
        padding: 4px 6px;
        font-size: 12px;
        min-height: 24px;
    }

    /* Breadcrumb minimaliste */
    .fm-breadcrumb,
    .filemanager-breadcrumb {
        padding: 2px 6px;
        font-size: 10px;
    }

    .fm-breadcrumb-item {
        max-width: 60px;
        padding: 1px 3px;
    }

    /* Files grid - 3 colonnes */
    .fm-grid,
    .files-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 4px;
    }

    .fm-item,
    .file-card {
        padding: 4px;
    }

    .fm-item-icon {
        font-size: 24px;
    }

    img.fm-item-thumb,
    div.fm-item-thumb {
        width: 40px;
        height: 40px;
    }

    .fm-item-name,
    .file-name {
        font-size: 9px;
        max-height: 2.2em;
    }

    .file-preview {
        height: 40px;
    }

    /* Tree compact */
    .tree-link {
        font-size: 12px;
        padding: 6px 8px;
        min-height: 32px;
    }

    .directory-tree {
        padding: 4px;
    }

    .file-meta {
        font-size: 10px;
    }

    /* Mobile toggle compact */
    .mobile-sidebar-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* Landscape mode sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .files-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .file-preview {
        height: 80px;
    }

    .filemanager-sidebar {
        max-width: 60vw;
    }
}

/* Touch improvements pour écrans tactiles - SANS agrandir excessivement */
@media (hover: none) and (pointer: coarse) {
    /* Zones tactiles minimales mais pas excessives */
    .btn,
    .tree-link,
    .breadcrumb-item,
    .btn-action,
    .btn-view {
        min-height: 32px; /* Réduit de 44px à 32px pour économiser l'espace */
    }

    /* Retirer les effets hover qui ne fonctionnent pas bien sur tactile */
    .file-card:hover {
        transform: none;
    }

    /* Actions toujours visibles sur tactile */
    .file-actions {
        opacity: 1;
    }

    /* Meilleur feedback visuel au tap */
    .btn:active,
    .btn-action:active,
    .tree-link:active,
    .btn-view:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
}

/* Image Preview Modal */
.image-preview-overlay {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Alerts */
.alert {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* ============================================
 * Sidebar Toggle
 * ============================================ */
#side-nav {
    transition: all 0.3s ease-in-out;
}

#id-container {
    transition: margin-left 0.3s ease-in-out;
}

/* Active state for toggle button */
#btn-toggle-sidebar.active {
    background-color: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

/* ============================================
 * Modal Responsive Improvements - Fullscreen on Mobile
 * ============================================ */
@media (max-width: 768px) {
    /* Modal Dialog - Fullscreen */
    .fm-modal-dialog {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .fm-modal-lg {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
    }

    .fm-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .fm-modal-header {
        border-radius: 0 !important;
        padding: 14px 16px !important;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .fm-modal-header h3 {
        font-size: 16px !important;
    }

    .fm-modal-close {
        width: 36px;
        height: 36px;
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .fm-modal-footer {
        border-radius: 0 !important;
        position: sticky;
        bottom: 0;
        z-index: 10;
        background: #f8f9fa;
    }

    .fm-modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
    }

    .fm-modal-files {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    }

    .fm-modal-file {
        padding: 10px 5px !important;
    }

    .fm-modal-file-icon {
        font-size: 28px !important;
    }

    .fm-modal-file-name {
        font-size: 11px !important;
    }

    .fm-modal-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .fm-modal-path {
        font-size: 12px !important;
        word-break: break-all !important;
    }

    .fm-modal-actions {
        width: 100% !important;
        justify-content: center !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .fm-btn {
        min-height: 44px !important;
        font-size: 15px !important;
        padding: 10px 16px !important;
    }

    .fm-btn-sm {
        min-height: 40px !important;
        min-width: 40px !important;
    }

    /* Version items responsive */
    .version-item {
        padding: 12px !important;
    }

    .version-item > div {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .version-item .badge {
        font-size: 12px !important;
    }
}

/* Smooth scrolling for better mobile experience */
.fm-modal-body,
.directory-tree,
.files-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Fix mobile scroll disappearing bug - force GPU rendering */
@media (max-width: 768px) {
    .filemanager-app,
    .filemanager-content,
    .files-container,
    .fm-grid,
    .fm-list {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    /* Ensure content doesn't disappear on scroll */
    .filemanager-content {
        overflow-y: visible;
        overflow-x: hidden;
    }

    .files-container {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevent text selection on mobile when interacting */
@media (max-width: 768px) {
    .file-card,
    .tree-node,
    .btn,
    .fm-modal-file {
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.1);
        -webkit-touch-callout: none;
    }

    /* Make sure text in file names can still be selected */
    .file-name,
    .fm-modal-file-name {
        -webkit-touch-callout: text;
        user-select: text;
    }
}

/* ============================================================
 * FMComponents - Reusable Modal Styles (fm_components.js.php)
 * ============================================================ */

/* Generic Modal */
.fm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
}

.fm-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.fm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.fm-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fm-modal-lg {
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    max-height: 90vh;
}

.fm-modal-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fm-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fm-modal-actions {
    display: flex;
    gap: 8px;
}

.fm-modal-close {
    border: none;
    background: transparent;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
}

.fm-modal-close:hover {
    color: #333;
}

.fm-modal-body {
    flex: 1;
    overflow: auto;
    padding: 0;
    min-height: 0; /* Important for flex children to allow shrinking */
}

/* Preview Modal */
.fm-preview-loading,
.fm-preview-nopreview,
.fm-preview-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 300px;
    color: #666;
    gap: 10px;
}

.fm-preview-loading i {
    font-size: 32px;
    color: #0d6efd;
}

.fm-preview-nopreview i {
    color: #aaa;
}

.fm-preview-error {
    color: #dc3545;
}

.fm-preview-video {
    width: 100%;
    height: 100%;
    background: #000;
}

.fm-preview-audio-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 30px;
    color: #666;
}

.fm-preview-audio-wrapper audio {
    width: 80%;
    max-width: 500px;
}

.fm-preview-text {
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    font-size: 13px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    height: 100%;
    box-sizing: border-box;
}

.fm-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

.fm-btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Bulk Actions (multi-selection) */
.fm-bulk-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #e3f2fd;
    border-radius: 4px;
    margin-left: 8px;
}

.fm-bulk-actions .bulk-count {
    font-size: 12px;
    color: #1976d2;
    white-space: nowrap;
}

/* Contextual Actions (single selection) */
.fm-contextual-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #fff3e0;
    border-radius: 4px;
    margin-left: 8px;
}

.fm-contextual-actions .contextual-label {
    font-size: 12px;
    color: #e65100;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Image Editor Modal */
.fm-modal-fullscreen .fm-image-editor-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    color: #fff;
}

.fm-image-editor-toolbar {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background: #2d2d2d;
    border-bottom: 1px solid #444;
    flex-wrap: wrap;
    align-items: center;
}

.fm-toolbar-group {
    display: flex;
    gap: 5px;
    padding-right: 15px;
    border-right: 1px solid #444;
    margin-right: 10px;
}

.fm-toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
}

.fm-toolbar-spacer {
    flex: 1;
}

.fm-toolbar-filename {
    color: #aaa;
    font-size: 13px;
    margin-right: 15px;
}

.fm-tool-btn,
.fm-image-editor-toolbar button {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: #3d3d3d;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.fm-tool-btn:hover,
.fm-image-editor-toolbar button:hover {
    background: #4d4d4d;
}

.fm-tool-btn.active {
    background: #0d6efd;
}

.fm-btn-success {
    background: #28a745 !important;
}

.fm-btn-success:hover {
    background: #218838 !important;
}

.fm-btn-secondary {
    background: #6c757d !important;
}

.fm-btn-secondary:hover {
    background: #5a6268 !important;
}

.fm-image-editor-toolbar input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.fm-image-editor-toolbar input[type="range"] {
    width: 80px;
}

.fm-image-editor-canvas-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 20px;
    background: #1a1a1a;
}

#fm-image-editor-canvas-container canvas {
    border: 2px solid #444;
    background: #fff;
}

.fm-image-editor-statusbar {
    padding: 8px 15px;
    background: #2d2d2d;
    border-top: 1px solid #444;
    font-size: 12px;
    color: #888;
}

/* ==========================================
   SEARCH RESULTS - GROUPED LAYOUT
   ========================================== */

.fm-search-grouped {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.fm-search-group {
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.fm-search-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.fm-search-group-header:hover {
    background: #eaeaea;
}

.fm-search-group-header > .fas:first-child {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.fm-search-group-label {
    font-weight: 600;
    color: #333;
    flex: 1;
    font-size: 12px;
}

.fm-search-group-count {
    font-size: 11px;
    color: #666;
    background: rgba(0,0,0,0.08);
    padding: 2px 8px;
    border-radius: 10px;
}

.fm-search-group-count.fm-count-zero {
    color: #999;
    background: rgba(0,0,0,0.04);
}

.fm-search-group-status {
    font-size: 11px;
    color: #666;
}

/* Toggle arrow */
.fm-search-group-header::after {
    content: '\f078';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 10px;
    color: #999;
    transition: transform 0.15s;
}

.fm-search-group.collapsed .fm-search-group-header::after {
    transform: rotate(-90deg);
}

.fm-search-group.collapsed .fm-search-group-content {
    display: none;
}

.fm-search-group-content {
    max-height: 500px;
    overflow-y: auto;
}

.fm-search-group-content .fm-grid {
    padding: 8px;
    gap: 8px;
}

.fm-search-group-content .fm-list {
    padding: 0;
}

/* Source badge on items */
.fm-source-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    z-index: 5;
    opacity: 0.9;
}

.fm-list-item .fm-source-badge {
    position: static;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Match highlighting */
.fm-match-highlight {
    background: #fff3cd;
    color: #856404;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

/* Content match preview */
.fm-content-match-preview {
    font-size: 10px;
    color: #666;
    background: #fffbeb;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    border-left: 2px solid #fbbf24;
}

.fm-content-match-preview .match {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}

/* Empty/error states */
.fm-search-empty-source {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

/* Skeleton loading */
.fm-search-skeleton {
    padding: 12px;
}

.fm-skeleton-item {
    height: 40px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
    margin-bottom: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   RESPONSIVE STYLES - Mobile (< 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Search groups */
    .fm-search-grouped {
        gap: 6px;
        padding: 6px;
    }

    .fm-search-group-header {
        padding: 6px 10px;
    }

    .fm-search-group-content .fm-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
        padding: 6px;
    }

    .fm-source-badge {
        font-size: 8px;
        padding: 1px 4px;
    }

    /* Toolbar compact */
    .fm-toolbar {
        padding: 8px 10px !important;
        gap: 6px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        max-width: 100% !important;
        overflow: hidden !important;
        align-items: stretch !important;
    }

    .fm-toolbar-left,
    .fm-toolbar-right {
        gap: 6px !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .fm-toolbar-left {
        flex: 1 1 100% !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        overflow: hidden !important;
    }

    .fm-toolbar-right {
        flex: 1 1 100% !important;
        width: 100% !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        overflow: hidden !important;
    }

    /* Boutons - taille confortable sur mobile */
    .fm-btn {
        padding: 8px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        font-size: 14px !important;
    }

    .fm-btn span.fas,
    .fm-btn span.fa {
        font-size: 14px !important;
    }

    .fm-btn-sm {
        padding: 6px !important;
        min-width: 32px !important;
        min-height: 32px !important;
    }

    .fm-btn-sm span.fas,
    .fm-btn-sm span.fa {
        font-size: 13px !important;
    }

    /* Actions contextuelles et bulk */
    .fm-bulk-actions,
    .fm-contextual-actions {
        gap: 5px !important;
        padding: 5px 10px !important;
        border-radius: 16px !important;
    }

    .fm-bulk-actions .bulk-count,
    .fm-contextual-actions .contextual-label {
        font-size: 12px !important;
        max-width: 90px !important;
    }

    /* Separateurs et toggles */
    .fm-toolbar-separator {
        margin: 0 5px !important;
        height: 22px !important;
    }

    .fm-view-toggle .fm-btn {
        padding: 8px 10px !important;
    }

    /* Grid items plus petits */
    .fm-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    .fm-grid-item {
        padding: 8px !important;
    }

    .fm-grid-item .fm-item-icon {
        font-size: 28px !important;
    }

    .fm-grid-item .fm-item-name {
        font-size: 11px !important;
    }

    /* Navigation breadcrumb */
    .fm-breadcrumb {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }

    .fm-breadcrumb .breadcrumb-item {
        padding: 3px 6px !important;
    }

    /* Champ de recherche - taille adaptée mobile */
    .fm-search-container {
        width: auto !important;
        max-width: min(100%, 220px) !important;
        min-width: 0 !important;
        flex: 1 1 180px !important;
        order: 1 !important;
        box-sizing: border-box !important;
    }

    .fm-toolbar-right > .fm-btn,
    .fm-toolbar-right > .fm-sort-dropdown,
    .fm-toolbar-right > .fm-view-toggle {
        order: 2 !important;
        flex: 0 0 auto !important;
    }

    .fm-search {
        width: 100% !important;
        min-width: 0 !important;
    }

    .fm-search input[type="text"],
    #search-input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 8px 78px 8px 34px !important;
        font-size: 14px !important;
    }

    .fm-search > .fa-search {
        font-size: 14px !important;
        left: 12px !important;
    }

    .fm-search-options-btn,
    .fm-search-clear {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 8px !important;
    }

    .fm-search-options-btn .fas,
    .fm-search-clear .fas {
        font-size: 14px !important;
    }

    .fm-search-options {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        max-height: min(70vh, 360px) !important;
        overflow-y: auto !important;
    }
}

@media (max-width: 480px) {
    .fm-search-container {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }
}

@media (max-width: 768px) {
    .fm-toolbar-right {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
    }

    .fm-search-container {
        max-width: none !important;
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
        order: 1 !important;
        box-sizing: border-box !important;
    }

    .fm-search-container {
        width: 100% !important;
        max-width: none !important;
    }

    .fm-toolbar-right > .fm-btn,
    .fm-toolbar-right > .fm-sort-dropdown,
    .fm-toolbar-right > .fm-view-toggle {
        order: 2 !important;
        flex: 0 0 auto !important;
    }

    .fm-search,
    .fm-search input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .fm-search input {
        padding: 8px 78px 8px 34px !important;
    }

    .fm-search-options {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ============================================
   MISSING DOCUMENTS ALERT - MINIMAL STYLES
   Uses Dolibarr native classes (noborder, oddeven, etc.)
   ============================================ */

/* Highlight mandatory rows */
tr.fm-row-mandatory {
    background-color: #fff8f8 !important;
}
tr.fm-row-mandatory:hover {
    background-color: #fff0f0 !important;
}

/* Show path under document name on mobile */
.visible-smartphone {
    display: none;
}

@media (max-width: 768px) {
    .visible-smartphone {
        display: inline;
    }
}

/* ============================================
   AUDIT 2025-12-31: ACCESSIBILITY FIXES
   WCAG 2.1 Compliance improvements
   ============================================ */

/* ============================================
   FOCUS VISIBLE STATES (WCAG 2.4.7)
   All interactive elements must have visible focus
   ============================================ */

/* Buttons - focus visible state */
.fm-btn:focus-visible,
.fm-modal-close:focus-visible,
.filemanager-container button:focus-visible,
button.fm-btn:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.2);
}

/* Links - focus visible state */
.filemanager-container a:focus-visible,
.fm-breadcrumb a:focus-visible,
.tree-link:focus-visible,
.file-card a:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Inputs - focus visible state */
.filemanager-container input:focus-visible,
.filemanager-container select:focus-visible,
.filemanager-container textarea:focus-visible,
.fm-input:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 1px;
    border-color: #0066cc;
}

/* Tab navigation items */
.fm-source-tab:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* File cards - focus visible for keyboard navigation */
.file-card:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-color: #0066cc;
}

/* Tree items - focus visible */
.tree-item:focus-visible,
.tree-toggle:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 1px;
}

/* ============================================
   TOUCH TARGET SIZES (WCAG 2.1.1)
   Minimum 44x44px for touch devices
   ============================================ */

/* Touch device detection - increase target sizes */
@media (hover: none) and (pointer: coarse) {
    /* All buttons minimum touch target */
    .fm-btn,
    .fm-modal-close,
    .fm-search-options-btn,
    .fm-search-clear,
    button[type="button"],
    button[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 16px;
    }

    /* Icon-only buttons */
    .fm-btn-icon,
    .btn-icon-only,
    .fm-toolbar button:not(.fm-btn) {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Tree navigation items */
    .tree-item,
    .tree-link {
        min-height: 44px;
        padding: 10px 12px;
    }

    /* Breadcrumb items */
    .fm-breadcrumb .breadcrumb-item {
        min-height: 44px;
        padding: 10px 8px;
    }

    /* Source tabs */
    .fm-source-tab {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Search input */
    .fm-search input[type="text"],
    #search-input {
        min-height: 44px;
    }

    /* Checkbox/radio - larger touch targets */
    .filemanager-container input[type="checkbox"],
    .filemanager-container input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
    }

    /* File action buttons on touch */
    .file-actions .fm-btn,
    .file-actions button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================
   REDUCED MOTION PREFERENCE (WCAG 2.3.3)
   Respect user's motion preferences
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .fa-spin {
        animation: none !important;
    }
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */

@media (prefers-contrast: high) {
    .fm-btn {
        border-width: 2px;
    }

    .file-card {
        border-width: 2px;
    }

    .fm-btn:focus-visible,
    button:focus-visible,
    a:focus-visible {
        outline-width: 3px;
    }
}

/* ============================================
   DARK MODE FOCUS STATES
   Adjust focus colors for dark themes
   ============================================ */

body.theme-eldy-dark .fm-btn:focus-visible,
body.theme-eldy-dark button:focus-visible,
body.theme-eldy-dark a:focus-visible,
body.theme-eldy-dark input:focus-visible {
    outline-color: #66b3ff;
    box-shadow: 0 0 0 4px rgba(102, 179, 255, 0.3);
}

/* ============================================
   SKIP LINK VISIBILITY (WCAG 2.4.1)
   Make skip link visible on focus
   ============================================ */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #0066cc;
    color: white;
    padding: 12px 20px;
    z-index: 10000;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ============================================================
   MOBILE / RESPONSIVE FIXES (v3.0.10) — appended last so they
   win the cascade over the earlier @media(max-width:768px) block.
   ============================================================ */
@media (max-width: 768px) {
    /* Fix 1 — GED source switcher. On narrow screens the surplus Dolibarr
       fiche-head source tabs collapse into the core ".popuptabset" dropdown
       (opened by ".moretab"); it was painting BEHIND the file-manager content
       so the user could not switch source. Lift the tab container's stacking
       context above the content (kept well under modals @ z-index 10000). */
    div.tabBar,
    div.tabs,
    .fiche .tabs {
        position: relative !important;
        z-index: 1050 !important;
    }
    .popuptabset {
        z-index: 1060 !important;
    }

    /* Fix 2 — hide the redundant "hide left menu" toggle on phones. Dolibarr
       already hides the left menu (#id-left) at this width, so the in-toolbar
       toggle does nothing but consume space. */
    #btn-toggle-sidebar {
        display: none !important;
    }

    /* Fix 3 — make the action / contextual / bulk toolbars horizontally
       swipe-scrollable instead of clipping unreachable buttons.
       Root cause: .fm-toolbar-left had overflow:hidden + flex-wrap:nowrap. */
    .fm-toolbar-left {
        overflow-x: auto !important;
        overflow-y: visible !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .fm-toolbar-left > * {
        flex-shrink: 0 !important;
    }
    #toolbar-actions,
    .fm-contextual-actions,
    .fm-bulk-actions {
        flex-wrap: nowrap !important;
        flex-shrink: 0 !important;
    }
    .fm-toolbar-left::-webkit-scrollbar,
    .fm-contextual-actions::-webkit-scrollbar,
    .fm-bulk-actions::-webkit-scrollbar {
        height: 4px;
    }
    .fm-toolbar-left::-webkit-scrollbar-thumb,
    .fm-contextual-actions::-webkit-scrollbar-thumb,
    .fm-bulk-actions::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.25);
        border-radius: 2px;
    }
}
