/* ================================================================
   FZ.PhotoEdit — modal edycji zdjęcia (mobile-first bottom sheet)
   ================================================================ */

/* Modal container — full screen overlay */
.fz-edit-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(0, 0, 0, 0.92);
    flex-direction: column;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body.fz-edit-open {
    overflow: hidden;
}

/* ── Header (top bar) ────────────────────────────────────────────── */
.fz-edit-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: rgba(0, 0, 0, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 56px;
    box-sizing: border-box;
}

.fz-edit-header-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.fz-edit-header-btn {
    min-width: 88px;
    min-height: 44px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.1s;
}

.fz-edit-header-btn--cancel {
    background: #555;
    color: #fff;
}
.fz-edit-header-btn--cancel:active { background: #666; }

.fz-edit-header-btn--apply {
    background: #4caf50;
    color: #fff;
}
.fz-edit-header-btn--apply:active { background: #43a047; transform: scale(0.98); }

/* ── Preview area (canvas) ───────────────────────────────────────── */
.fz-edit-preview {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    padding: 16px;
    position: relative;
    background: #1a1a1a;
}

.fz-edit-preview canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    display: block;
}

/* Compare indicator (gdy user trzyma palec/spację) */
.fz-edit-preview[data-comparing] canvas {
    outline: 3px solid rgba(255, 200, 50, 0.85);
    outline-offset: -3px;
}
.fz-edit-preview[data-comparing]::before {
    content: 'ORYGINAŁ';
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 200, 50, 0.95);
    color: #1a1a1a;
    padding: 6px 14px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    z-index: 5;
    pointer-events: none;
}

/* ── Tab bar (horizontal scroll) ─────────────────────────────────── */
.fz-edit-tabs {
    flex-shrink: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(0, 0, 0, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.fz-edit-tabs::-webkit-scrollbar { display: none; }

.fz-edit-tab {
    flex-shrink: 0;
    min-width: 80px;
    min-height: 48px;
    padding: 10px 18px;
    background: transparent;
    color: #bbb;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.fz-edit-tab.active {
    color: #fff;
    border-bottom-color: #4caf50;
    background: rgba(76, 175, 80, 0.08);
}

/* ── Tab content (bottom sheet) ──────────────────────────────────── */
.fz-edit-content {
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.78);
    padding: 14px 16px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* ── Sliders ─────────────────────────────────────────────────────── */
.fz-edit-sliders,
.fz-edit-effects {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.fz-edit-slider-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fz-edit-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #ddd;
}

.fz-edit-slider-name {
    font-weight: 500;
}

.fz-edit-slider-value {
    min-width: 36px;
    text-align: right;
    color: #4caf50;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Touch-friendly slider (28px handle, 8px track) */
.fz-edit-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: transparent;
    cursor: pointer;
    touch-action: pan-y;
    padding: 0;
    margin: 0;
}

.fz-edit-slider::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(to right, #444, #666);
    border-radius: 4px;
}

.fz-edit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #4caf50;
    margin-top: -10px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s;
}

.fz-edit-slider:active::-webkit-slider-thumb {
    transform: scale(1.15);
}

.fz-edit-slider::-moz-range-track {
    height: 8px;
    background: linear-gradient(to right, #444, #666);
    border-radius: 4px;
}

.fz-edit-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #4caf50;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ── Auto tab ────────────────────────────────────────────────────── */
.fz-edit-auto {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.fz-edit-auto-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 240px;
    min-height: 56px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transition: transform 0.1s, box-shadow 0.15s;
}

.fz-edit-auto-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.fz-edit-auto-btn svg {
    width: 24px;
    height: 24px;
}

.fz-edit-auto-desc {
    text-align: center;
    font-size: 0.85rem;
    color: #bbb;
    line-height: 1.5;
    max-width: 480px;
}

.fz-edit-auto-undo {
    margin-top: 4px;
    min-height: 44px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    touch-action: manipulation;
}
.fz-edit-auto-undo:active { background: rgba(255, 255, 255, 0.15); }

/* ── Presety (horizontal scroll thumbnails) ──────────────────────── */
.fz-edit-presets {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.fz-edit-presets::-webkit-scrollbar { height: 4px; }
.fz-edit-presets::-webkit-scrollbar-thumb { background: #555; border-radius: 2px; }

.fz-edit-preset {
    flex-shrink: 0;
    width: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.fz-edit-preset-thumb {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    background: #333 center/cover;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
}

.fz-edit-preset.active .fz-edit-preset-thumb {
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.fz-edit-preset-label {
    font-size: 0.78rem;
    color: #ddd;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.fz-edit-preset.active .fz-edit-preset-label {
    color: #4caf50;
    font-weight: 600;
}

.fz-edit-preset:active .fz-edit-preset-thumb {
    transform: scale(0.95);
}

/* ── Toggle (B&W) ────────────────────────────────────────────────── */
.fz-edit-toggle-row {
    display: flex;
    justify-content: flex-start;
    margin-top: 4px;
}

.fz-edit-toggle {
    min-height: 44px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.08);
    color: #ddd;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 22px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.fz-edit-toggle.active {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
}

.fz-edit-toggle:active { transform: scale(0.97); }

/* ================================================================
   Desktop enhancements (≥1025px, hover supported)
   ================================================================ */
@media (min-width: 1025px) and (hover: hover) {

    .fz-edit-modal {
        /* Centrowany modal z marginesami, nie full-screen */
        align-items: center;
        justify-content: center;
        padding: 24px;
    }

    /* Wewnętrzny "okno" zamiast full-screen overlay */
    .fz-edit-modal::before {
        content: '';
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.78);
        z-index: -1;
    }

    .fz-edit-modal > .fz-edit-header,
    .fz-edit-modal > .fz-edit-preview,
    .fz-edit-modal > .fz-edit-tabs,
    .fz-edit-modal > .fz-edit-content {
        width: 100%;
        max-width: 1400px;
    }

    .fz-edit-modal > .fz-edit-header {
        border-radius: 12px 12px 0 0;
        background: #222;
    }

    .fz-edit-modal > .fz-edit-preview {
        background: #111;
        max-height: 60vh;
    }

    .fz-edit-modal > .fz-edit-tabs {
        background: #1a1a1a;
    }

    .fz-edit-modal > .fz-edit-content {
        background: #222;
        border-radius: 0 0 12px 12px;
        max-height: 28vh;
    }

    /* Hover states */
    .fz-edit-header-btn--cancel:hover { background: #666; }
    .fz-edit-header-btn--apply:hover  { background: #43a047; }

    .fz-edit-tab:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.04);
    }

    .fz-edit-preset:hover .fz-edit-preset-thumb {
        transform: scale(1.04);
        border-color: rgba(76, 175, 80, 0.5);
    }

    .fz-edit-toggle:hover {
        background: rgba(255, 255, 255, 0.14);
        border-color: rgba(255, 255, 255, 0.28);
    }
    .fz-edit-toggle.active:hover {
        background: #43a047;
    }

    .fz-edit-auto-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
    }

    /* Preview cursor — wskazówka że można press-hold do compare */
    .fz-edit-preview canvas {
        cursor: zoom-in;
    }
    .fz-edit-preview[data-comparing] canvas {
        cursor: grabbing;
    }

    /* Keyboard hints w headerze */
    .fz-edit-header-title::after {
        content: ' · Spacja = porównaj · A = Auto · Esc/Enter';
        font-weight: 400;
        opacity: 0.55;
        font-size: 0.78rem;
        margin-left: 8px;
    }
}

/* Mobile portrait — bardzo wąskie ekrany */
@media (max-width: 360px) {
    .fz-edit-header { padding: 8px 10px; min-height: 52px; }
    .fz-edit-header-btn { min-width: 72px; padding: 8px 12px; font-size: 0.88rem; }
    .fz-edit-header-title { font-size: 0.92rem; }
    .fz-edit-tab { min-width: 70px; padding: 8px 12px; font-size: 0.82rem; }
    .fz-edit-preset { width: 76px; }
    .fz-edit-preset-thumb { width: 70px; height: 70px; }
}
