/* ═══════════════════════════════════════
   components.css — Suivi Colis
   Composants UI partagés : section-header,
   boutons, modales, messages, animations
   ═══════════════════════════════════════ */

/* ══ ANIMATIONS ══ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── État vide ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 36px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: .78rem;
    font-weight: 500;
}

.empty-state svg {
    width: 44px;
    height: 44px;
    color: var(--color-border);
    opacity: .7;
}

/* ══ MODALE PDF BLXO ══ */
.blxo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 28, 56, .45);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: none;
    opacity: 0;
    transition: opacity .3s ease;
}

.blxo-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.blxo-modal-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 60%;
    height: 100%;
    background: var(--color-white);
    z-index: 201;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(10, 37, 64, .18);
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.22, .68, 0, 1.2);
}

.blxo-modal-panel.open {
    transform: translateX(0);
}

.blxo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1.5px solid var(--color-border);
    flex-shrink: 0;
    gap: 16px;
}

.blxo-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    font-weight: 700;
    color: var(--color-primary-darker);
}

.blxo-modal-title svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.blxo-modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.blxo-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1.5px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .2s, color .2s, background .2s;
    flex-shrink: 0;
}

.blxo-modal-close:hover {
    border-color: #e53935;
    color: #c62828;
    background: #fff8f8;
}

.blxo-modal-close svg {
    width: 16px;
    height: 16px;
}

.blxo-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-soft);
}

.blxo-modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.blxo-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: .72rem;
    flex-shrink: 0;
}

.blxo-open-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.blxo-pdf-loading,
.blxo-pdf-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted);
    font-size: .82rem;
}

/* ══ RESTRICTIONS DE RÔLE ══ */
.role-disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.role-blocked {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none !important;
    user-select: none;
}

/* ══ MAIN ══ */
.main {
    margin: 0 auto;
    padding: 48px var(--spacing-xl) 64px;
}

/* ══ SECTION HEADER ══ */
.section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1.5px solid var(--color-border);
}

.section-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-lg);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-icon svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-darker);
    letter-spacing: 0.02em;
}

.section-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ══ BOUTONS ══ */

/* ── Styles de base communs à tous les boutons ── */
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--transition-base),
        transform var(--transition-fast),
        box-shadow var(--transition-base),
        background var(--transition-base),
        border-color var(--transition-base),
        color var(--transition-base);
    border: none;
    white-space: nowrap;
}

.btn-primary svg,
.btn-secondary svg,
.btn-danger svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Primaire ── */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-white);
    box-shadow: 0 4px 16px rgba(43, 123, 229, 0.30);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(43, 123, 229, 0.40);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* ── Secondaire ── */
.btn-secondary {
    background: var(--color-white);
    color: var(--color-text-muted);
    border: 1.5px solid var(--color-border);
    padding: 12px 22px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: none;
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

/* ── Danger ── */
.btn-danger {
    background: var(--color-error);
    color: var(--color-white);
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* ── Actions de formulaire ── */
.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 4px;
}

/* ══ MESSAGES INLINE ══ */
.msg-block {
    margin-top: 14px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: none;
    line-height: 1.5;
}

.msg-block.success {
    display: block;
    background: var(--color-success-light);
    border: 1.5px solid var(--color-success-border);
    color: var(--color-success);
}

.msg-block.error {
    display: block;
    background: var(--color-error-light);
    border: 1.5px solid var(--color-error-border);
    color: var(--color-error);
}

/* ══ MODALES ══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 28, 56, 0.60);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.open,
.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: 36px 36px 32px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.94) translateY(16px);
    transition: transform var(--transition-bounce);
    position: relative;
}

.modal-overlay.open .modal,
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary-darker);
    margin-bottom: 6px;
}

.modal-desc {
    font-size: 0.79rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 5px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    transition: color var(--transition-base), background var(--transition-base);
}

.modal-close:hover {
    color: var(--color-primary-darker);
    background: var(--color-bg-soft);
}

.modal-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--spacing-md) 0;
}

/* ── Post-ajout / post-transfert ── */
.post-ajout-icon {
    width: 56px;
    height: 56px;
    background: var(--color-success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.post-ajout-icon svg {
    width: 28px;
    height: 28px;
    color: var(--color-success);
}

.post-ajout-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.post-ajout-actions .btn-primary,
.post-ajout-actions .btn-secondary {
    width: 100%;
    justify-content: center;
}

/* ── Étapes de modale ── */
.modal-step {
    display: none;
}

.modal-step.active {
    display: block;
}

/* ── Indicateur d'étapes ── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
    transition: background var(--transition-slow), transform var(--transition-slow);
}

.step-dot.active {
    background: var(--color-primary);
    transform: scale(1.3);
}

.step-dot.done {
    background: var(--color-primary-dark);
}

.step-line {
    width: 28px;
    height: 2px;
    background: var(--color-border);
    border-radius: 2px;
    transition: background var(--transition-slow);
}

.step-line.done {
    background: var(--color-primary-dark);
}

/* ── Écran de succès ── */
.success-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 0 8px;
    text-align: center;
}

.success-icon {
    width: 56px;
    height: 56px;
    background: var(--color-success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    width: 28px;
    height: 28px;
    color: var(--color-success);
}

.otp-hint {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* ── Item commande ── */
.commande-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-white);
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}

.commande-item:last-child {
    border-bottom: none;
}

.commande-item:hover {
    background: var(--color-bg-soft);
}

.commande-item.selected {
    background: #eef4fd;
    border-left: 3px solid var(--color-primary);
    padding-left: 13px;
}

.commande-item-body {
    flex: 1;
    min-width: 0;
}

.commande-item-blxo {
    font-size: .82rem;
    font-weight: 700;
    color: var(--color-primary-darker);
}

.commande-item-meta {
    font-size: .7rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commande-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.commande-nb-colis {
    font-size: .68rem;
    color: var(--color-text-muted);
}

/* ══ LISTE COLIS PARTAGÉE (attente + stock) ══ */
.colis-list {
    border: 1.5px solid var(--color-border);
    border-radius: 11px;
    overflow: hidden;
}

.colis-list-loading,
.colis-list-empty {
    padding: 40px 24px;
    text-align: center;
    font-size: .82rem;
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.colis-list-loading svg {
    width: 24px;
    height: 24px;
    color: var(--color-primary);
    animation: spin 1.2s linear infinite;
}

.colis-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-white);
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}

.colis-item:last-child {
    border-bottom: none;
}

.colis-item:hover {
    background: var(--color-bg-soft);
}

.colis-item.selected {
    background: var(--color-primary-light);
}

.colis-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--color-border);
    background: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, border-color .2s;
}

.colis-item.selected .colis-checkbox {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.colis-checkbox svg {
    width: 13px;
    height: 13px;
    color: var(--color-white);
    opacity: 0;
    transition: opacity .15s;
}

.colis-item.selected .colis-checkbox svg {
    opacity: 1;
}

.colis-info {
    flex: 1;
    min-width: 0;
}

.colis-type {
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-primary-darker);
}

.colis-meta {
    display: flex;
    gap: 12px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.colis-meta-item {
    font-size: .72rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.colis-meta-item svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.colis-badge {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
    flex-shrink: 0;
}

.colis-badge.nouveau {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: 1px solid #b6d0f7;
}

.colis-badge.sav {
    background: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffe082;
}

.colis-badge.preparer {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    margin-left: 6px;
}

/* ══ MODE SOMBRE ══ */
[data-theme="dark"] .section-header {
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .btn-secondary {
    background: #16213a;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

[data-theme="dark"] .modal {
    background: #16213a;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .blxo-modal-panel {
    background: #16213a;
    border-left: 1px solid var(--color-border);
}

[data-theme="dark"] .blxo-modal-header {
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .blxo-modal-body {
    background: #0f172a;
}

[data-theme="dark"] .blxo-modal-close {
    background: #16213a;
    border-color: var(--color-border);
}

[data-theme="dark"] .commande-item {
    background: #16213a;
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .commande-item:hover {
    background: #1a2840;
}

[data-theme="dark"] .commande-item.selected {
    background: #1a2d4a;
}

[data-theme="dark"] .colis-list {
    border-color: var(--color-border);
}

[data-theme="dark"] .colis-item {
    background: #16213a;
    border-color: var(--color-border);
}

[data-theme="dark"] .colis-item:hover {
    background: #1a2840;
}

[data-theme="dark"] .colis-item.selected {
    background: #1a2d4a;
}

[data-theme="dark"] .colis-checkbox {
    background: #0f172a;
    border-color: var(--color-border);
}

/* ══ RESPONSIVE ══ */
@media (max-width: 1024px) {
    .blxo-modal-panel {
        width: 85%;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 24px var(--spacing-md) 48px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary {
        justify-content: center;
        width: 100%;
    }

    .modal {
        margin: var(--spacing-md);
        padding: 28px 20px 24px;
    }

    .blxo-modal-panel {
        width: 100%;
    }
}