/* ==========================================================================
   EQM MODAL - SYSTEME GLOBAL
   Styles du backdrop, modal generique, animations, confirm overlay,
   search overlay et sidebar overlay.
   Fichier independant extrait de footer.php.
   ========================================================================== */

/* ------ Backdrop ------ */
.eqm-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    inset: 0;
    z-index: 9998;
    background: rgba(255, 255, 255, .35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: auto;
    cursor: pointer;
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

.eqm-backdrop.show {
    display: block;
    animation: eqmFadeIn .4s cubic-bezier(.4, 0, .2, 1) forwards
}

.eqm-backdrop.closing {
    animation: eqmFadeOut .25s ease forwards
}

@keyframes eqmFadeIn {
    from { opacity: 0 }
    to   { opacity: 1 }
}

@keyframes eqmFadeOut {
    from { opacity: 1 }
    to   { opacity: 0 }
}

/* ------ Modal container ------ */
.eqm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 1rem;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-sizing: border-box
}

.eqm-modal.show,
.eqm-modal.is-open {
    display: flex !important;
    pointer-events: none
}

.eqm-modal.show .eqm-modal-content,
.eqm-modal.is-open .eqm-modal-content {
    pointer-events: auto;
    position: relative;
    z-index: 2
}

/* Backdrop inline (enfant direct de .eqm-modal) */
.eqm-modal > .eqm-backdrop {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 1;
    pointer-events: auto
}
.eqm-modal > .eqm-backdrop.show,
.eqm-modal.show > .eqm-backdrop,
.eqm-modal.is-open > .eqm-backdrop {
    display: block;
    animation: eqmFadeIn .4s cubic-bezier(.4, 0, .2, 1) forwards
}

/* ------ Modal content ------ */
.eqm-modal-content {
    pointer-events: auto;
    background: #fff;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    width: 100%;
    max-width: 520px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column
}

.eqm-modal-content-inner {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0
}

/* ------ Variante wide ------ */
.eqm-modal.eqm-modal-wide .eqm-modal-content {
    max-width: 1100px;
    width: 100%;
    max-height: 94vh;
    height: 90vh
}

@media(max-width:1024px) {
    .eqm-modal.eqm-modal-wide .eqm-modal-content {
        height: 94vh;
        max-height: 94vh;
        width: 100%;
        border-radius: 1.25rem 1.25rem 0 0
    }
}

/* ------ Drag handle ------ */
.eqm-modal-drag-handle {
    display: none;
    height: 24px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none
}

.eqm-modal-drag-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
}

/* ------ Animations ouverture / fermeture ------ */
.eqm-modal.show .eqm-modal-content,
.eqm-modal.is-open .eqm-modal-content {
    animation: eqmWowIn .5s cubic-bezier(.175, .885, .32, 1.1) forwards
}

.eqm-modal.closing .eqm-modal-content {
    animation: eqmScaleOut .25s ease forwards
}

@keyframes eqmWowIn {
    0%   { transform: scale(0.92); opacity: 0 }
    60%  { transform: scale(1.02); opacity: 1 }
    100% { transform: scale(1);    opacity: 1 }
}

@keyframes eqmWowInCenter {
    0%   { transform: translate(-50%, -50%) scale(0.92); opacity: 0 }
    60%  { transform: translate(-50%, -50%) scale(1.02); opacity: 1 }
    100% { transform: translate(-50%, -50%) scale(1);    opacity: 1 }
}

@keyframes eqmScaleOut {
    0%   { transform: scale(1);    opacity: 1 }
    100% { transform: scale(0.98); opacity: 0 }
}

/* ------ Page push / return (effet parallaxe fond) ------ */
.page-scaled .main-wrapper {
    animation: eqmPagePush .4s cubic-bezier(.4, 0, .2, 1) forwards;
    overflow: hidden
}

.page-unscaling .main-wrapper {
    animation: eqmPageReturn .35s cubic-bezier(.4, 0, .2, 1) forwards
}

@keyframes eqmPagePush {
    0%   { transform: scale(1);    border-radius: 0 }
    100% { transform: scale(0.98); border-radius: 1.25rem }
}

@keyframes eqmPageReturn {
    0%   { transform: scale(0.98); border-radius: 1.25rem }
    100% { transform: scale(1);    border-radius: 0 }
}

/* ------ Utilitaire color-dot ------ */
.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0
}

/* ------ Sections internes du modal ------ */
.eqm-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 0%;
    min-height: 0
}

.eqm-modal-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem .5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem
}

.eqm-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0
}

.eqm-modal-footer {
    flex-shrink: 0;
    background: #fff;
    z-index: 5;
    padding: .75rem 1.25rem;
    padding-bottom: max(1rem, calc(.75rem + env(safe-area-inset-bottom, 0px)));
    display: flex;
    gap: .5rem;
}

/* ------ Boutons footer (meme style que eqm-confirm-btn) ------ */
.eqm-modal-btn-primary,
.eqm-modal-btn-secondary,
.eqm-modal-btn-danger {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .625rem 1.25rem;
    border-radius: .75rem;
    font-family: 'Outfit', sans-serif;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .2s
}

.eqm-modal-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px -2px rgba(var(--primary-rgb), .4)
}
.eqm-modal-btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px)
}
.eqm-modal-btn-primary:active { transform: translateY(0) }
.eqm-modal-btn-primary:disabled { opacity: .5; pointer-events: none }

.eqm-modal-btn-secondary {
    background: #f1f5f9;
    color: #475569
}
.eqm-modal-btn-secondary:hover {
    background: #e2e8f0;
    color: #334155
}

.eqm-modal-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 4px 14px -2px rgba(239, 68, 68, .4)
}
.eqm-modal-btn-danger:hover {
    filter: brightness(1.08);
    transform: translateY(-1px)
}

/* ------ Bouton fermeture ------ */
.eqm-modal-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: linear-gradient(135deg, var(--primary, #10b981), var(--primary-dark, #059669));
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    box-shadow: 0 6px 18px rgba(var(--primary-rgb, 16 185 129), .35);
}
.eqm-modal-close:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(var(--primary-rgb, 16 185 129), .5);
}

/* ------ Desktop : cacher le drag handle ------ */
@media(min-width:1025px) {
    .eqm-modal-drag-handle {
        display: none !important
    }
}

/* ------ Mobile : bottom-sheet ------ */
@media(max-width:1024px) {
    .eqm-modal {
        padding: 0;
        align-items: flex-end;
        justify-content: flex-end
    }

    .eqm-modal-content {
        max-height: 90vh;
        border-radius: 1.25rem 1.25rem 0 0;
        display: flex;
        flex-direction: column;
        overflow: hidden
    }

    .eqm-modal.show .eqm-modal-content,
    .eqm-modal.is-open .eqm-modal-content {
        animation: eqmSlideUp .5s cubic-bezier(.175, .885, .32, 1.1) forwards
    }

    .eqm-modal-drag-handle {
        display: flex;
        padding-top: 8px;
        padding-bottom: 4px
    }
}

/* ------ Smartphone : tous les modaux ouvrent a 70% par defaut.
   Standard Equimondo (cf. .cursor/rules/standard-modals-equimondo.mdc
   regle 6 et ARCHITECTURE_REFERENCE.md section 10.1).
   L'utilisateur etire jusqu'a 95dvh via le drag-handle.
   Variantes pour deroger : .eqm-modal-content--full / .eqm-modal-wide  */
@media(max-width:640px) {
    .eqm-modal-content {
        height: 70%;
        max-height: 70%
    }
    .eqm-modal-content.eqm-modal-content--h70 {
        height: 70%;
        max-height: 70%
    }
    .eqm-modal-content.eqm-modal-content--h85 {
        height: 85%;
        max-height: 85%
    }
    .eqm-modal-content.eqm-modal-content--full {
        height: 94%;
        max-height: 94%
    }
    .eqm-modal-content.eqm-modal-content--auto {
        height: auto;
        max-height: 90vh
    }
}

@keyframes eqmSlideUp {
    from { transform: translateY(100%) }
    to   { transform: translateY(0) }
}

/* ------ Confirm overlay ------ */
.eqm-confirm-overlay {
    cursor: pointer;
    background: rgba(255, 255, 255, .35) !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
}

.eqm-confirm-overlay.eqm-confirm-show .eqm-confirm-box {
    animation: eqmWowIn .5s cubic-bezier(.175, .885, .32, 1.1) forwards;
}

/* ------ Search modal overlay ------ */
#searchModalOverlay {
    background: rgba(255, 255, 255, .35) !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px)
}

/* ------ Sidebar overlay ------ */
.sidebar-overlay {
    pointer-events: none !important
}

.sidebar-overlay.open {
    pointer-events: auto !important
}

@media(max-width:1023px) {
    .sidebar:not(.open) {
        pointer-events: none !important
    }

    .sidebar.open {
        pointer-events: auto !important
    }
}
