﻿/* ══════════════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════════════ */
:root {
    --pj-accent: #E1701A;
    --pj-accent-light: rgba(225, 112, 26, 0.08);
    --pj-accent-ring: rgba(225, 112, 26, 0.18);
    --pj-blue: #3b82f6;
    --pj-blue-light: rgba(59, 130, 246, 0.08);
    --pj-danger: #ef4444;
    --pj-success: #22c55e;
    --pj-warning: #f59e0b;
    --pj-border: #e5e7eb;
    --pj-border-hover: #d1d5db;
    --pj-bg: #fff;
    --pj-bg-subtle: #fafafa;
    --pj-bg-muted: #f8f9fa;
    --pj-text: #1f2937;
    --pj-text-muted: #6b7280;
    --pj-text-faint: #9ca3af;
    --pj-radius-sm: 6px;
    --pj-radius: 10px;
    --pj-radius-lg: 14px;
    --pj-shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --pj-shadow: 0 4px 12px rgba(0,0,0,0.08);
    --pj-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --pj-transition: 0.15s ease;
    --pj-restricted: #6b7280;
    --pj-restricted-bg: #f3f4f6;
    --pj-restricted-border: #d1d5db;
}

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
.pj-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pj-border);
}

.pj-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--pj-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0;
}

.pj-header-actions {
    display: flex;
    gap: 8px;
}

/* ══════════════════════════════════════════════════════════════
   ROOT & LAYOUT
══════════════════════════════════════════════════════════════ */
.pieces-jointes-root {
    font-family: inherit;
    position: relative;
    color: var(--pj-text);
}

.main-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 12px;
    min-height: 420px;
}

/* ══════════════════════════════════════════════════════════════
   GROUP PANEL (left)
══════════════════════════════════════════════════════════════ */
.group-panel {
    border: 1px solid var(--pj-border);
    border-radius: var(--pj-radius);
    background: var(--pj-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--pj-shadow-sm);
}

.group-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 12px;
    font-weight: 600;
    color: var(--pj-text);
    transition: background var(--pj-transition), color var(--pj-transition);
}

    .group-item .badge {
        margin-left: auto;
    }

    .group-item:hover {
        background: var(--pj-bg-muted);
    }

    .group-item.active {
        background: var(--pj-accent-light);
        border-left: 3px solid var(--pj-accent);
        color: var(--pj-accent);
        font-weight: 700;
    }

/* ══════════════════════════════════════════════════════════════
   PIECES GRID (right)
══════════════════════════════════════════════════════════════ */
.pieces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    align-content: start;
    overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════════
   PIECE CARD
══════════════════════════════════════════════════════════════ */
.piece-card {
    background: var(--pj-bg);
    border: 1px solid var(--pj-border);
    border-radius: var(--pj-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color var(--pj-transition), box-shadow var(--pj-transition);
}

    .piece-card:hover {
        border-color: var(--pj-border-hover);
        box-shadow: var(--pj-shadow-sm);
    }

    .piece-card.drag-over {
        border: 2px dashed var(--pj-accent) !important;
        background: var(--pj-accent-light);
        box-shadow: 0 0 0 4px var(--pj-accent-ring);
    }

/* Card header */
.piece-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px 7px;
    border-bottom: 1px solid #f3f4f6;
    background: var(--pj-bg-subtle);
}

.piece-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.piece-header-actions {
    display: flex;
    gap: 6px;
}

.piece-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--pj-blue);
    line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════════
   BADGE
══════════════════════════════════════════════════════════════ */
.badge {
    background: #f0f0f0;
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 11px;
    color: var(--pj-text-muted);
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   ATTACHMENT ROWS
══════════════════════════════════════════════════════════════ */
.attachment-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: var(--pj-radius-sm);
    background: var(--pj-bg-muted);
    border: 1px solid transparent;
    font-size: 12px;
    cursor: grab;
    user-select: none;
    transition: background var(--pj-transition), border-color var(--pj-transition), box-shadow 120ms ease;
}

    .attachment-row:hover {
        background: #eef1f5;
        border-color: var(--pj-border);
    }

    .attachment-row:active {
        cursor: grabbing;
    }

    .attachment-row.is-dragging {
        opacity: 0.45;
        box-shadow: var(--pj-shadow);
    }

    .attachment-row.att-selected {
        background: rgba(0, 120, 215, 0.08);
        border-left: 3px solid #0078d7;
    }

.att-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--pj-text);
    font-size: 12px;
}

/* ── Action buttons ── */
.att-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--pj-transition);
}

.attachment-row:hover .att-actions {
    opacity: 1;
}

.att-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: var(--pj-radius-sm);
    line-height: 1;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--pj-transition), color var(--pj-transition);
}

.download-btn {
    color: #2980b9;
}

    .download-btn:hover {
        background: #e8f4fd;
        color: #1a5f8a;
    }

.att-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Restricted button (lock icon variant) ── */
.att-btn.pj-btn-restricted {
    opacity: 0.4 !important;
    color: #9ca3af !important;
    background: #f3f4f6 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.image-btn {
    color: #c9a600;
}

    .image-btn:hover {
        background: #fefce8;
        color: #a07800;
    }

.edit-btn {
    color: var(--pj-text-muted);
}

    .edit-btn:hover:not(:disabled):not(.pj-btn-restricted) {
        background: #f3f4f6;
        color: var(--pj-text);
    }

.delete-btn {
    color: var(--pj-text-faint);
}

    .delete-btn:hover:not(:disabled):not(.pj-btn-restricted) {
        background: #fef2f2;
        color: var(--pj-danger);
    }

/* ══════════════════════════════════════════════════════════════
   DROP ZONE
══════════════════════════════════════════════════════════════ */
.drop-zone {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: var(--pj-radius);
    padding: 18px;
    text-align: center;
    background: var(--pj-bg-subtle);
    transition: border-color var(--pj-transition), background var(--pj-transition);
}

    .drop-zone.drag-over {
        border-color: var(--pj-blue);
        background: var(--pj-blue-light);
        pointer-events: none;
    }

    /* Restricted upload state */
    .drop-zone.pj-drop-restricted {
        border-color: var(--pj-restricted-border);
        background: var(--pj-restricted-bg);
        cursor: not-allowed;
    }

        .drop-zone.pj-drop-restricted .file-input-overlay {
            pointer-events: none;
            cursor: not-allowed;
        }
.pj-drop-restricted {
    opacity: .5;
    filter: grayscale(100%);
    cursor: not-allowed;
}
.file-input-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: all;
    z-index: 5;
    cursor: pointer;
}

    .file-input-overlay:disabled {
        pointer-events: none;
        cursor: not-allowed;
    }

.drop-content {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--pj-text);
}

    .drop-content .icon {
        font-size: 28px;
        color: var(--pj-text-muted);
    }

    .drop-content strong {
        font-size: 12px;
        color: var(--pj-text-muted);
        font-weight: 600;
    }

    /* Restricted drop-zone hint */
    .drop-content.pj-restricted-hint .icon {
        font-size: 22px;
        color: var(--pj-restricted);
    }

    .drop-content.pj-restricted-hint strong {
        color: var(--pj-restricted);
        font-size: 11px;
    }

/* ══════════════════════════════════════════════════════════════
   UPLOAD PROGRESS
══════════════════════════════════════════════════════════════ */
.upload-progress-bar {
    width: 100%;
    height: 5px;
    background: var(--pj-border);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

    .upload-progress-bar:not(.indeterminate) .upload-progress-fill {
        height: 100%;
        width: var(--pct, 0%);
        background: var(--pj-blue);
        border-radius: 999px;
        transition: width 0.1s ease;
    }

    .upload-progress-bar.indeterminate::after {
        content: '';
        position: absolute;
        left: -40%;
        top: 0;
        height: 100%;
        width: 40%;
        background: var(--pj-blue);
        border-radius: 999px;
        animation: pj-indeterminate 1.2s ease-in-out infinite;
    }

.upload-label {
    font-size: 11px;
    color: var(--pj-text-muted);
    margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════════
   GLOBAL DRAG OVERLAY
══════════════════════════════════════════════════════════════ */
.global-drag-overlay {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    padding: 10px 22px;
    border-radius: var(--pj-radius);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    box-shadow: var(--pj-shadow-lg);
    animation: pj-slide-up 0.2s ease;
}

/* ══════════════════════════════════════════════════════════════
   CONFIRM POPUP
══════════════════════════════════════════════════════════════ */
.confirm-popup {
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.confirm-content {
    flex: 1;
    text-align: center;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 10px auto 20px;
    border-radius: 50%;
    background: #fff4e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.confirm-file {
    margin: 15px 0;
    padding: 12px;
    border-radius: var(--pj-radius-sm);
    background: var(--pj-bg-muted);
    border: 1px solid var(--pj-border);
    word-break: break-all;
    font-weight: 600;
    font-size: 13px;
}

.confirm-note {
    color: var(--pj-danger);
    font-size: 12px;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--pj-border);
}

/* ══════════════════════════════════════════════════════════════
   EDIT POPUP
══════════════════════════════════════════════════════════════ */
.file-upload-section {
    margin-bottom: 1rem;
}

.file-upload-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 13px;
    font-weight: 600;
    color: var(--pj-text);
}

.custom-file-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 2px dashed var(--pj-border-hover);
    border-radius: var(--pj-radius);
    background: var(--pj-bg-subtle);
    cursor: pointer;
    font-size: 13px;
    color: var(--pj-text-muted);
    transition: border-color var(--pj-transition), background var(--pj-transition);
}

    .custom-file-upload:hover {
        border-color: var(--pj-blue);
        background: var(--pj-blue-light);
    }

.hidden-file-input {
    display: none;
}

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 11px 18px;
    border-radius: var(--pj-radius-sm);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    min-width: 240px;
    box-shadow: var(--pj-shadow-lg);
    animation: pj-slide-in 0.25s ease;
}

    .toast-notification.success {
        background: var(--pj-success);
    }

    .toast-notification.error {
        background: var(--pj-danger);
    }

    .toast-notification.warning {
        background: var(--pj-warning);
    }

    .toast-notification.info {
        background: var(--pj-blue);
    }

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes pj-slide-up {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes pj-slide-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pj-indeterminate {
    0% {
        left: -40%;
    }

    100% {
        left: 110%;
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .group-panel {
        max-height: 180px;
        overflow-y: auto;
    }
}

/* ══════════════════════════════════════════════════════════════
   DISABLED STATE (new dossier)
══════════════════════════════════════════════════════════════ */
.pj-new-object-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: var(--pj-radius-sm);
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 13px;
    font-weight: 500;
}

.pj-disabled-wrapper {
    position: relative;
}

.pj-disabled {
    pointer-events: none;
    user-select: none;
}

    .pj-disabled::after {
        content: '';
        position: absolute;
        inset: 0;
        background: rgba(255, 255, 255, 0.6);
        border-radius: var(--pj-radius);
        z-index: 10;
    }
