/**
 * FDS Library Styles
 * @author AK Digital
 */

/* ========================================
   FDS LIBRARY - PRINCIPAL
   ======================================== */

.fds-library {
    margin: 0 auto;
    font-family: 'Lato', sans-serif;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ========================================
   CATEGORIES VISUELLES (grille avec images)
   ======================================== */

.fds-library__categories {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.fds-library__category-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
    text-align: left;
    min-height: 72px;
}

.fds-library__category-card:hover {
    background: #eef2f5;
    border-color: #0B3954;
}

.fds-library__category-card.is-active {
    background: #e8f0f5;
    border-color: #0B3954;
}

.fds-library__category-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.fds-library__category-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
    mix-blend-mode: multiply;
}

.fds-library__category-img svg {
    color: #0B3954;
}

.fds-library__category-name {
    font-size: 14px;
    font-weight: 700;
    color: #2B2B2B;
    line-height: 1.3;
}

/* ========================================
   TOOLBAR (Recherche + filtres langues)
   ======================================== */

.fds-library__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    flex-wrap: wrap;
}

.fds-library__search {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 500px;
    min-width: 280px;
}

.fds-library__search-icon {
    color: #0B3954;
    flex-shrink: 0;
}

.fds-library__search-wrapper {
    position: relative;
    flex: 1;
}

.fds-library__search-input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 4px;
    font-size: 15px;
    font-family: 'Lato', sans-serif;
    color: #2B2B2B;
    background: #fff;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.fds-library__search-input::placeholder {
    color: #999;
}

.fds-library__search-input:focus {
    outline: none;
    border-color: #0B3954;
    box-shadow: 0 0 0 3px rgba(11, 57, 84, 0.1);
}

.fds-library__search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 26px;
    height: 26px;
    border-radius: 4px;
}

.fds-library__search-clear:hover {
    color: #fff;
    background: #0B3954;
}

/* Groupe reset + dropdown langue */
.fds-library__toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Dropdown langue */
.fds-library__lang-dropdown {
    position: relative;
}

.fds-library__lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 2px solid #e5e5e5;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    color: #2B2B2B;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fds-library__lang-toggle:hover {
    border-color: #0B3954;
}

.fds-library__lang-toggle.is-all-langs {
    background: #0B3954;
    border-color: #0B3954;
    color: #fff;
}

.fds-library__lang-toggle.is-all-langs:hover {
    background: #0a2e42;
    border-color: #0a2e42;
}

.fds-library__lang-toggle.is-all-langs .fds-library__lang-chevron {
    color: #fff;
}

.fds-library__lang-dropdown.is-open .fds-library__lang-toggle {
    border-color: #0B3954;
    box-shadow: 0 0 0 3px rgba(11, 57, 84, 0.1);
}

.fds-library__lang-toggle-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fds-library__lang-toggle-text .fi {
    font-size: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.fds-library__lang-chevron {
    transition: transform 0.2s ease;
    color: #666;
    flex-shrink: 0;
}

.fds-library__lang-dropdown.is-open .fds-library__lang-chevron {
    transform: rotate(180deg);
}

.fds-library__lang-list {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 100;
}

.fds-library__lang-dropdown.is-open .fds-library__lang-list {
    display: block;
}

.fds-library__lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    color: #444;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    white-space: nowrap;
}

.fds-library__lang-option:hover {
    background: #f5f7f9;
    color: #0B3954;
}

.fds-library__lang-option.is-active {
    background: #0B3954;
    color: #fff;
}

.fds-library__lang-option .fi {
    font-size: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.fds-library__lang-option.is-active .fi {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

/* Bouton reinitialiser */
.fds-library__reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: none;
    border: none;
    font-size: 13px;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fds-library__reset:hover {
    color: #c0392b;
    background-color: #c0392b0f;
    border-radius: 4px;
}

.fds-library__reset svg {
    flex-shrink: 0;
}

/* ========================================
   EN-TETE RESULTATS
   ======================================== */

.fds-library__results-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 24px;
}

.fds-library__results-title {
    font-size: 22px;
    font-weight: 700;
    color: #2B2B2B;
    margin: 0;
}

.fds-library__results-count {
    font-size: 14px;
    color: #999;
    font-weight: 400;
}

/* ========================================
   GRILLE
   ======================================== */

.fds-library__results {
    min-height: 300px;
    width: 100%;
    max-width: 100%;
    position: relative;
    box-sizing: border-box;
}

.fds-library__results.is-loading {
    pointer-events: none;
}

.fds-library__loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    color: #666;
    font-size: 15px;
    font-weight: 500;
}

.fds-library__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* ========================================
   CARDS FDS
   ======================================== */

.fds-library__card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.25s ease;
    min-width: 0;
}

.fds-library__card:hover {
    border-color: #0B3954;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

/* Header : icone + langue */
.fds-library__card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fds-library__card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 4px;
    color: #0B3954;
    flex-shrink: 0;
    overflow: hidden;
    padding: 6px;
    border: 1px solid #f0f0f0;
    background: #fff;
    box-sizing: border-box;
}

.fds-library__card-icon img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.fds-library__card-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    background: #f5f5f5;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Drapeaux dans les cards */
.fds-library__card-lang .fi {
    font-size: 14px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* Titre */
.fds-library__card-title {
    font-size: 15px;
    font-weight: 600;
    color: #2B2B2B;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Description */
.fds-library__card-desc-wrap {
    position: relative;
}

.fds-library__card-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fds-library__card-desc-wrap.is-expanded .fds-library__card-desc {
    display: block;
    -webkit-line-clamp: unset;
}

.fds-library__card-desc-toggle {
    display: none;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    margin-top: 2px;
    cursor: pointer;
    color: #999;
    font-size: 12px;
    font-family: 'Lato', sans-serif;
    transition: color 0.2s ease;
}

.fds-library__card-desc-toggle.is-visible {
    display: inline-flex;
}

.fds-library__card-desc-toggle:hover {
    color: #0B3954;
}

.fds-library__card-desc-toggle svg {
    transition: transform 0.2s ease;
}

.fds-library__card-desc-toggle-less {
    display: none;
}

.fds-library__card-desc-wrap.is-expanded .fds-library__card-desc-toggle-more {
    display: none;
}

.fds-library__card-desc-wrap.is-expanded .fds-library__card-desc-toggle-less {
    display: inline;
}

.fds-library__card-desc-wrap.is-expanded .fds-library__card-desc-toggle svg {
    transform: rotate(180deg);
}

/* Badges categories */
.fds-library__card-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fds-library__card-cat {
    font-size: 12px;
    font-weight: 500;
    color: #0B3954;
    background: #e8f0f5;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Nom du fichier */
.fds-library__card-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #888;
    overflow: hidden;
}

.fds-library__card-file svg {
    flex-shrink: 0;
    color: #aaa;
}

.fds-library__card-file span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Actions */
.fds-library__card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

.fds-library__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Lato', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    flex: 1;
}

.fds-library__btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.fds-library__btn--view {
    background: #0B3954;
    color: #fff;
}

.fds-library__btn--view:hover {
    background: #0a2e42;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 57, 84, 0.25);
}

.fds-library__btn--download {
    background: #f5f5f5;
    color: #333;
}

.fds-library__btn--download:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
}

.fds-library__no-file {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* Etat vide */
.fds-library__empty {
    text-align: center;
    padding: 80px 20px;
    color: #888;
    min-height: 200px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.fds-library__empty p {
    font-size: 16px;
    margin: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1100px) {
    .fds-library__categories {
        grid-template-columns: repeat(3, 1fr);
    }

    .fds-library__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .fds-library__categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .fds-library__category-card {
        padding: 12px 14px;
        gap: 10px;
        min-height: 60px;
    }

    .fds-library__category-img {
        width: 60px;
        height: 60px;
    }

    .fds-library__category-name {
        font-size: 13px;
    }

    .fds-library__toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .fds-library__search {
        max-width: none;
        min-width: 0;
    }

    .fds-library__lang-toggle {
        font-size: 13px;
        padding: 8px 12px;
    }

    .fds-library__lang-list {
        right: auto;
        left: 0;
    }

    .fds-library__btn {
        font-size: 13px;
        padding: 8px 10px;
    }

    .fds-library__results-title {
        font-size: 18px;
    }
}

@media (max-width: 600px) {
    .fds-library__grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .fds-library__categories {
        grid-template-columns: 1fr;
    }

    .fds-library__card-actions {
        flex-direction: column;
    }

    .fds-library__btn {
        font-size: 12px;
        padding: 8px 10px;
    }
}