/* ========================================== */
/* DASHBOARD ARCHIVES — REDESIGN COMPLET     */
/* Remplace l'ancienne section profil        */
/* ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

/* ==========================================
   LAYOUT PRINCIPAL (Mobile-first)
   ========================================== */

.archives-dashboard {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 80px);
    width: 100%;
}

/* ==========================================
   SIDEBAR (Dossiers + Crédits)
   ========================================== */

.dash-sidebar {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.dash-sidebar-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-sidebar-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.btn-new-folder {
    background: var(--gold);
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.btn-new-folder:hover {
    background: var(--gold-hover);
}

/* Arbre des dossiers */
.dash-folder-tree {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dash-f-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.dash-f-node:hover {
    background: var(--panel-light);
}

.dash-f-node.active {
    background: rgba(197, 160, 89, 0.12);
    border-left: 3px solid var(--gold);
}

.dash-f-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-main);
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.dash-f-label span:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-f-node.active .dash-f-label {
    color: var(--gold);
    font-weight: 600;
}

.dash-f-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--panel-light);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.dash-f-node.active .dash-f-count {
    background: rgba(197, 160, 89, 0.15);
    color: var(--gold);
}

.dash-f-sub {
    padding-left: 28px;
}

.dash-f-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.dash-f-node:hover .dash-f-actions {
    opacity: 1;
}

.dash-f-act {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background 0.15s;
}

.dash-f-act:hover {
    background: var(--border-color);
}

/* Credits footer sidebar */
.dash-credits {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.dash-credits-num {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--gold);
    line-height: 1;
}

.dash-credits-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.dash-credits-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.dash-credits-link:hover {
    opacity: 0.7;
}

/* ==========================================
   ZONE PRINCIPALE (Top bar + Grille)
   ========================================== */

.dash-main {
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* Top bar */
.dash-topbar {
    padding: 14px 20px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.dash-breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.dash-breadcrumb-root {
    cursor: pointer;
    transition: color 0.15s;
}

.dash-breadcrumb-root:hover {
    color: var(--gold);
}

.dash-breadcrumb strong {
    color: var(--text-main);
    font-weight: 600;
}

.dash-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 7px 14px;
    flex: 1;
    max-width: 350px;
    min-width: 150px;
    transition: border-color 0.2s;
}

.dash-search:focus-within {
    border-color: var(--gold);
}

.dash-search-icon {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.dash-search input {
    border: none;
    background: none;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    flex: 1;
    min-width: 0;
}

.dash-search input::placeholder {
    color: var(--text-muted);
}

/* Filtres par type */
.dash-filters {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.dash-filter-pill {
    padding: 5px 13px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}

.dash-filter-pill:hover,
.dash-filter-pill.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(197, 160, 89, 0.06);
}

/* Toggle vue grille / liste */
.dash-view-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.dash-vt-btn {
    padding: 5px 10px;
    background: var(--panel-bg);
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.dash-vt-btn.active {
    background: var(--gold);
    color: #fff;
}

/* ==========================================
   GRILLE DES ARCHIVES (Cards)
   ========================================== */

.dash-archive-grid {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    align-content: start;
}

/* Vue liste (override complet) */
.dash-archive-grid.view-list {
    grid-template-columns: 1fr !important; /* Force une seule colonne */
    gap: 8px;
}

.dash-archive-grid.view-list .dash-a-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    flex-wrap: nowrap;
}

.dash-archive-grid.view-list .dash-a-type {
    margin-bottom: 0;
    flex-shrink: 0;
    min-width: 80px;
    text-align: center;
}

.dash-archive-grid.view-list .dash-a-title {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    font-size: 13px;
    -webkit-line-clamp: 1;
    line-clamp: 1; /* standard property */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.dash-archive-grid.view-list .dash-a-meta {
    flex-shrink: 0;
    margin-bottom: 0;
    gap: 10px;
    font-size: 11px;
}

/* Cacher les éléments secondaires en mode liste */
.dash-archive-grid.view-list .dash-a-cote,
.dash-archive-grid.view-list .dash-a-tags,
.dash-archive-grid.view-list .dash-a-status,
.dash-archive-grid.view-list .dash-a-new {
    display: none;
}

.dash-archive-grid.view-list .dash-a-actions {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    flex-shrink: 0;
}

/* Sur mobile en mode liste, empiler quand même */
@media (max-width: 768px) {
    .dash-archive-grid.view-list .dash-a-card {
        flex-wrap: wrap;
    }
    .dash-archive-grid.view-list .dash-a-title {
        flex-basis: 100%;
        white-space: normal;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* Archive card */
.dash-a-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.dash-a-card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 16px rgba(197, 160, 89, 0.1);
    transform: translateY(-1px);
}

.dash-a-card[draggable="true"] {
    cursor: grab;
}

.dash-a-card[draggable="true"]:active {
    cursor: grabbing;
}

/* Badge type */
.dash-a-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 8px;
    width: fit-content;
}

.dash-type-notaire { background: #e0e7ff; color: #3730a3; }
.dash-type-bms { background: #dcfce7; color: #166534; }
.dash-type-parchemin { background: #fef3c7; color: #92400e; }
.dash-type-militaire { background: #fce7f3; color: #9d174d; }
.dash-type-default { background: var(--panel-light); color: var(--text-muted); }

/* Titre */
.dash-a-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Titre éditable */
.dash-a-title-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 6px;
}

.dash-a-title-row .dash-a-title {
    margin-bottom: 0;
    flex: 1;
}

.dash-a-edit-title {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted, #245B6D);
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-top: 2px;
}

.dash-a-card:hover .dash-a-edit-title {
    opacity: 0.6;
}

.dash-a-edit-title:hover {
    opacity: 1 !important;
    color: var(--gold, #C5A059);
    background: rgba(197, 160, 89, 0.08);
}

.dash-a-title[contenteditable="true"] {
    outline: none;
    border: 1.5px solid var(--gold, #C5A059);
    border-radius: 4px;
    padding: 4px 6px;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    display: block;
    overflow: visible;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.12);
}

/* Metadata ligne */
.dash-a-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.dash-a-meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Cote source */
.dash-a-cote {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--panel-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-style: italic;
    display: inline-block;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

/* Tags */
.dash-a-tags {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.dash-a-tag {
    font-size: 10px;
    background: rgba(197, 160, 89, 0.12);
    color: var(--gold);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Actions */
.dash-a-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    margin-top: auto;
}

.dash-a-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dash-a-btn-primary {
    background: var(--gold);
    color: #fff;
}

.dash-a-btn-primary:hover {
    background: var(--gold-hover);
}

.dash-a-btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.dash-a-btn-icon:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(197, 160, 89, 0.06);
}

.dash-a-btn-delete {
    margin-left: auto;
}

.dash-a-btn-delete:hover {
    border-color: var(--danger, #e74c3c);
    color: var(--danger, #e74c3c);
    background: rgba(231, 76, 60, 0.06);
}

/* Badge nouveau */
.dash-a-new {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #4ade80;
    color: #052e16;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

/* Status badges */
.dash-a-status {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 8px;
}

.dash-a-status-progress { background: #fef3c7; color: #92400e; }
.dash-a-status-error { background: #fce7f3; color: #9d174d; }

/* Empty state */
.dash-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.dash-empty-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 8px;
}

.dash-empty p {
    font-size: 14px;
    margin: 0;
}

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

/* Tablette (600px+) */
@media (min-width: 600px) {
    .dash-archive-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        padding: 20px 24px;
    }
}

/* Desktop (851px+) */
@media (min-width: 851px) {
    .archives-dashboard {
        flex-direction: row;
    }

    .dash-sidebar {
        width: 260px;
        min-width: 180px;
        max-width: 450px;
        border-bottom: none;
        border-right: none; /* Le resizer fait office de bordure */
        height: calc(100vh - 80px);
        position: sticky;
        top: 80px;
        flex-shrink: 0;
    }

    .dash-f-actions {
        opacity: 0;
    }

    .dash-f-node:hover .dash-f-actions {
        opacity: 1;
    }

    .dash-archive-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    /* Resizer (séparateur draggable) */
    .dash-resizer {
        width: 5px;
        cursor: col-resize;
        background: var(--border-color);
        flex-shrink: 0;
        position: relative;
        transition: background 0.15s;
        z-index: 10;
    }

    .dash-resizer:hover,
    .dash-resizer.dragging {
        background: var(--gold);
    }

    .dash-resizer::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 3px;
        height: 30px;
        border-left: 1px solid rgba(0,0,0,0.15);
        border-right: 1px solid rgba(0,0,0,0.15);
    }

    .dash-resizer:hover::after,
    .dash-resizer.dragging::after {
        border-color: rgba(255,255,255,0.5);
    }
}

/* Mobile (<600px) */
@media (max-width: 599px) {
    .dash-sidebar {
        max-height: none;
    }

    .dash-f-actions {
        opacity: 1;
    }

    .dash-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px 16px;
    }

    .dash-search {
        max-width: none;
    }

    .dash-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .dash-a-card {
        padding: 14px;
    }
}