/**
 * TLC Photo Editor — styles du modal d'édition (crop / rotate / flip).
 * Thème bleu nuit cohérent avec le reste du site.
 */

/* Quand le modal est ouvert, on bloque le scroll du body */
body.tlc-photo-editor-open {
    overflow: hidden;
}

/* ── Overlay plein écran ───────────────────────────────────────────────── */
.tlc-photo-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002; /* au-dessus du modal Premium guest (9999) et du capture sheet (10001) */
    background: rgba(4, 12, 26, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: tlc-pe-fade-in 0.18s ease-out;
}

@keyframes tlc-pe-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Dialog ────────────────────────────────────────────────────────────── */
.tlc-photo-editor-dialog {
    background: linear-gradient(180deg, #0b1e3b 0%, #06152b 100%);
    border: 1px solid rgba(98, 178, 255, 0.18);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: tlc-pe-pop 0.22s cubic-bezier(.16,1,.3,1);
}

@keyframes tlc-pe-pop {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ── Header ────────────────────────────────────────────────────────────── */
.tlc-photo-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(98, 178, 255, 0.10);
    flex-shrink: 0;
}

.tlc-photo-editor-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
}

.tlc-photo-editor-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}

.tlc-photo-editor-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── Stage (image à éditer) ────────────────────────────────────────────── */
.tlc-photo-editor-stage {
    flex: 1 1 auto;
    min-height: 0;
    background: #04101f;
    position: relative;
    overflow: hidden;
    /* hauteur minimum pour mobile */
    min-height: 320px;
}

.tlc-photo-editor-img {
    display: block;
    max-width: 100%;
    /* Cropper.js prend ensuite la main */
}

/* Correction Cropper : background translucide pour voir la zone coupée */
.tlc-photo-editor-stage .cropper-modal {
    background: #000;
    opacity: 0.6;
}

.tlc-photo-editor-stage .cropper-view-box {
    outline: 2px solid #62b2ff;
    outline-color: rgba(98, 178, 255, 0.85);
}

.tlc-photo-editor-stage .cropper-line,
.tlc-photo-editor-stage .cropper-point {
    background-color: #62b2ff;
}

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.tlc-photo-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid rgba(98, 178, 255, 0.10);
    background: rgba(6, 20, 40, 0.6);
    flex-shrink: 0;
    overflow-x: auto;
}

.tlc-photo-editor-toolbar button {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(98, 178, 255, 0.08);
    border: 1px solid rgba(98, 178, 255, 0.14);
    color: #b9d6ff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tlc-photo-editor-toolbar button:hover {
    background: rgba(98, 178, 255, 0.14);
    border-color: rgba(98, 178, 255, 0.28);
    color: #fff;
}

.tlc-photo-editor-toolbar button:active {
    transform: scale(0.96);
}

.tlc-photo-editor-toolbar button svg {
    pointer-events: none;
}

/* ── Actions (Annuler / Valider) ──────────────────────────────────────── */
.tlc-photo-editor-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(98, 178, 255, 0.10);
    flex-shrink: 0;
}

.tlc-pe-btn {
    flex: 1;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 800;
    border: 0;
    cursor: pointer;
    transition: transform 0.1s, filter 0.15s;
    letter-spacing: 0.01em;
}

.tlc-pe-btn:active {
    transform: scale(0.98);
}

.tlc-pe-btn--ghost {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e7eefc;
}

.tlc-pe-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.10);
}

.tlc-pe-btn--primary {
    background: linear-gradient(180deg, #2e7fd6 0%, #1f5fa8 100%);
    color: #fff;
    box-shadow: 0 6px 16px rgba(32, 96, 170, 0.4);
}

.tlc-pe-btn--primary:hover {
    filter: brightness(1.08);
}

/* ── Spinner (pendant l'export canvas → blob) ─────────────────────────── */
.tlc-photo-editor-spinner {
    position: absolute;
    inset: 0;
    background: rgba(4, 15, 30, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    color: #62b2ff;
}

.tlc-photo-editor-spinner[hidden] {
    display: none;
}

/* ── Responsive mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .tlc-photo-editor-overlay {
        padding: 0;
    }

    .tlc-photo-editor-dialog {
        max-width: 100%;
        max-height: 100vh;
        height: 100dvh; /* dynamic viewport mobile */
        border-radius: 0;
        border: 0;
    }

    .tlc-photo-editor-stage {
        min-height: 0; /* laisse le flex prendre tout l'espace */
    }

    .tlc-photo-editor-toolbar {
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .tlc-photo-editor-toolbar button {
        width: 40px;
        height: 40px;
    }

    .tlc-photo-editor-actions {
        padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
    }

    .tlc-pe-btn {
        min-height: 46px;
    }
}

/* iPad / tablette paysage : laisser plus de hauteur */
@media (min-width: 641px) and (max-height: 700px) {
    .tlc-photo-editor-dialog {
        max-height: 96vh;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   Capture Sheet — menu Caméra / Galerie sur mobile
   ══════════════════════════════════════════════════════════════════════════ */

body.tlc-capture-sheet-open {
    overflow: hidden;
}

.tlc-capture-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001; /* au-dessus du modal Premium guest (9999), sous l'éditeur photo (10002) */
    background: rgba(4, 12, 26, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: tlc-cs-fade-in 0.18s ease-out;
}

.tlc-capture-sheet-overlay.is-closing {
    animation: tlc-cs-fade-out 0.16s ease-in forwards;
}

@keyframes tlc-cs-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes tlc-cs-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.tlc-capture-sheet {
    width: 100%;
    max-width: 560px;
    background: linear-gradient(180deg, #0c2142 0%, #071a35 100%);
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    border-top: 1px solid rgba(98, 178, 255, 0.18);
    padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
    animation: tlc-cs-slide-up 0.22s cubic-bezier(.16,1,.3,1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.is-closing .tlc-capture-sheet {
    animation: tlc-cs-slide-down 0.18s ease-in forwards;
}

@keyframes tlc-cs-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0);    }
}
@keyframes tlc-cs-slide-down {
    from { transform: translateY(0);    }
    to   { transform: translateY(100%); }
}

.tlc-cs-handle {
    align-self: center;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin: 4px 0 8px;
}

.tlc-cs-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(98, 178, 255, 0.08);
    border: 1px solid rgba(98, 178, 255, 0.14);
    color: #e7eefc;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    min-height: 62px;
}

.tlc-cs-btn:hover,
.tlc-cs-btn:focus-visible {
    background: rgba(98, 178, 255, 0.14);
    border-color: rgba(98, 178, 255, 0.28);
    outline: none;
}

.tlc-cs-btn:active {
    transform: scale(0.99);
    background: rgba(98, 178, 255, 0.2);
}

.tlc-cs-btn svg {
    flex-shrink: 0;
    color: #62b2ff;
    width: 26px;
    height: 26px;
}

.tlc-cs-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.tlc-cs-btn-label {
    font-weight: 800;
    font-size: 0.98rem;
    color: #fff;
}

.tlc-cs-btn-desc {
    font-size: 0.82rem;
    color: rgba(199, 215, 240, 0.65);
}

.tlc-cs-cancel {
    margin-top: 4px;
    min-height: 52px;
    padding: 0 20px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #e7eefc;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.tlc-cs-cancel:hover {
    background: rgba(255, 255, 255, 0.09);
}

.tlc-cs-cancel:active {
    transform: scale(0.99);
}

/* Tablette / desktop : centrer le sheet comme un dialog compact */
@media (min-width: 641px) {
    .tlc-capture-sheet-overlay {
        align-items: center;
        padding: 20px;
    }
    .tlc-capture-sheet {
        border-radius: 20px;
        border: 1px solid rgba(98, 178, 255, 0.18);
        padding: 18px;
    }
    .tlc-cs-handle {
        display: none;
    }
}
