/* ============================================================
   IMAGE EDITOR CANVAS — Shared foundation styles
   ============================================================ */

/* ---- Editor shell ------------------------------------------------ */
.image-editor-shell {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

@media (min-width: 900px) {
    .image-editor-shell {
        flex-direction: row;
        align-items: stretch;
        height: calc(100vh - 240px);
        min-height: 520px;
        max-height: 820px;
    }

    .image-editor-canvas-wrap {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .image-editor-canvas-box {
        flex: 1 1 auto;
        height: auto;
        min-height: 280px;
    }

    .image-editor-sidebar {
        width: 320px;
        flex-shrink: 0;
        overflow-y: auto;
        max-height: 100%;
    }
}

/* ---- Canvas area ------------------------------------------------- */
.image-editor-canvas-wrap {
    background: var(--tb-bg-secondary);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-md);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.image-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--tb-bg-elevated);
    border-bottom: 1px solid var(--tb-border);
}

.image-editor-canvas-box {
    position: relative;
    width: 100%;
    height: 420px;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
}

.image-editor-canvas-box canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}

@media (max-width: 640px) {
    .image-editor-shell {
        height: auto;
        min-height: auto;
        max-height: none;
    }

    .image-editor-canvas-box {
        height: 320px;
        min-height: 240px;
        flex: none !important;
    }

    .image-editor-canvas-wrap {
        flex: none;
    }

    .image-editor-sidebar {
        max-height: none;
        overflow-y: visible;
    }

    .image-editor-toolbar {
        gap: 6px;
        padding: 8px;
    }
}

/* Full-screen editor mode (mobile) */
.image-editor-shell.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--tb-bg-primary);
    padding: 12px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
}

.image-editor-shell.fullscreen .image-editor-canvas-box {
    height: calc(100vh - 130px);
    min-height: 0;
}

.image-editor-shell.fullscreen .image-editor-sidebar {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 45vh;
    background: var(--tb-bg-elevated);
    border-radius: var(--tb-radius-md);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

/* ---- Toolbar controls -------------------------------------------- */
.ie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-bg-elevated);
    color: var(--tb-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--tb-transition-fast);
    white-space: nowrap;
}

.ie-btn:hover {
    background: var(--tb-bg-hover);
    border-color: var(--tb-border-focus);
}

.ie-btn:active {
    transform: translateY(1px);
}

.ie-btn.active {
    background: var(--tb-primary);
    border-color: var(--tb-primary);
    color: white;
}

.ie-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ie-btn-icon {
    width: 34px;
    padding: 0;
}

.ie-zoom-label {
    min-width: 52px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--tb-text-secondary);
    user-select: none;
}

.ie-toolbar-spacer {
    flex: 1;
}

/* Undo/redo toolbar buttons */
.ie-btn-history {
    /* Inherits .ie-btn .ie-btn-icon styling */
}

/* ---- Sidebar ----------------------------------------------------- */
.image-editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ie-panel {
    background: var(--tb-bg-elevated);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-md);
    padding: 16px;
}

.ie-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--tb-text);
    margin-bottom: 12px;
    letter-spacing: -0.2px;
}

/* ---- Live preview ------------------------------------------------ */
.ie-preview-wrap {
    text-align: center;
}

.ie-preview-img {
    max-width: 100%;
    max-height: 160px;
    border-radius: var(--tb-radius-sm);
    border: 1px solid var(--tb-border);
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 0 0 / 12px 12px;
    object-fit: contain;
}

.ie-preview-dim {
    font-size: 12px;
    color: var(--tb-text-secondary);
    margin-top: 8px;
}

/* ---- Pixel inputs ------------------------------------------------ */
.ie-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ie-input-grid .form-group {
    margin: 0;
}

.ie-input-grid label {
    font-size: 12px;
    color: var(--tb-text-secondary);
    margin-bottom: 4px;
    display: block;
}

.ie-input-grid input {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-bg-tertiary);
    color: var(--tb-text);
    font-size: 14px;
    font-weight: 500;
}

.ie-input-grid input:focus {
    outline: none;
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-border-focus);
}

/* ---- Custom ratio input ------------------------------------------ */
.ie-ratio-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ie-ratio-input input {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-bg-tertiary);
    color: var(--tb-text);
    font-size: 13px;
}

.ie-ratio-input input:focus {
    outline: none;
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-border-focus);
}

.ie-ratio-input .ie-btn {
    height: 36px;
    padding: 0 12px;
}

/* ---- Presets ----------------------------------------------------- */
.ie-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ie-preset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--tb-border);
    border-radius: 20px;
    background: var(--tb-bg-tertiary);
    color: var(--tb-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--tb-transition-fast);
    white-space: nowrap;
}

.ie-preset:hover {
    border-color: var(--tb-primary);
    color: var(--tb-primary);
    background: var(--tb-primary-soft);
}

.ie-preset.active {
    border-color: var(--tb-primary);
    background: var(--tb-primary);
    color: white;
}

/* ---- Output controls --------------------------------------------- */
.ie-output-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ie-output-row .form-group {
    margin: 0;
}

.ie-output-row select,
.ie-output-row input[type="range"] {
    width: 100%;
}

/* ---- Action buttons ---------------------------------------------- */
.ie-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ie-actions .btn {
    width: 100%;
    justify-content: center;
}

/* ---- Empty / upload state ---------------------------------------- */
.ie-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--tb-text-secondary);
    text-align: center;
    padding: 24px;
}

.ie-empty-state i {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--tb-text-tertiary);
}

/* ---- Result area ------------------------------------------------- */
.ie-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.ie-result-col {
    text-align: center;
}

.ie-result-col img {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--tb-radius-sm);
    border: 1px solid var(--tb-border);
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 0 0 / 12px 12px;
}

.ie-result-label {
    font-size: 12px;
    color: var(--tb-text-secondary);
    margin-bottom: 8px;
}

.ie-result-meta {
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

@media (max-width: 640px) {
    .ie-result-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Comparison slider (Compressor) ------------------------------ */
.ie-compare-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    user-select: none;
    border-radius: var(--tb-radius-md);
    overflow: hidden;
    border: 1px solid var(--tb-border);
}

.ie-compare-wrap img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.ie-compare-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.ie-compare-overlay img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
}

.ie-compare-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    z-index: 2;
}

.ie-compare-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 1;
}

.ie-compare-knob {
    position: absolute;
    top: 50%;
    width: 32px;
    height: 32px;
    margin-top: -16px;
    margin-left: -16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.ie-compare-knob i {
    font-size: 10px;
    color: var(--tb-text-secondary);
}

/* ---- Batch grid (Compressor) ------------------------------------- */
.ie-batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.ie-batch-item {
    position: relative;
    background: var(--tb-bg-elevated);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    padding: 10px;
    text-align: center;
    transition: var(--tb-transition-fast);
}

.ie-batch-item:hover {
    border-color: var(--tb-border-focus);
}

.ie-batch-item.dragging {
    opacity: 0.4;
}

.ie-batch-item.drag-over {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 2px var(--tb-border-focus);
}

.ie-batch-item.selected {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 2px var(--tb-border-focus);
}

.ie-batch-thumb {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--tb-bg-secondary);
    margin-bottom: 8px;
}

.ie-batch-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--tb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ie-batch-meta {
    font-size: 11px;
    color: var(--tb-text-secondary);
    margin-top: 2px;
}

.ie-batch-status {
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
    min-height: 16px;
}

.ie-batch-status.done {
    color: var(--tb-success);
}

.ie-batch-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.ie-batch-item:hover .ie-batch-remove {
    opacity: 1;
}

@media (max-width: 480px) {
    .ie-batch-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- Resizer tabs ------------------------------------------------ */
.ie-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--tb-border);
    margin-bottom: 16px;
}

.ie-tab {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tb-text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--tb-transition-fast);
}

.ie-tab:hover {
    color: var(--tb-text);
}

.ie-tab.active {
    color: var(--tb-primary);
    border-bottom-color: var(--tb-primary);
}

/* ---- Warnings / notices ------------------------------------------ */
.ie-warning {
    color: #f59e0b;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ie-warning i {
    color: #f59e0b;
}

/* ---- Utility ----------------------------------------------------- */
.ie-hidden {
    display: none !important;
}

/* ---- Pages preview (Image to PDF) -------------------------------- */
.ie-pages-preview {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px;
    margin: 16px 0;
    background: var(--tb-bg-elevated);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-md);
    scroll-snap-type: x mandatory;
}

.ie-page-card {
    flex: 0 0 auto;
    width: 150px;
    background: var(--tb-bg-primary);
    border: 2px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    padding: 8px;
    cursor: pointer;
    transition: var(--tb-transition-fast);
    scroll-snap-align: start;
}

.ie-page-card:hover {
    border-color: var(--tb-border-focus);
}

.ie-page-card.selected {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-border-focus);
}

.ie-page-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--tb-text-secondary);
    margin-bottom: 6px;
    text-align: center;
}

.ie-page-thumb-wrap {
    width: 100%;
    aspect-ratio: 0.707;
    background: #ffffff;
    border: 1px solid var(--tb-border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ie-page-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ie-page-meta {
    font-size: 10px;
    color: var(--tb-text-secondary);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

@media (max-width: 640px) {
    .ie-page-card {
        width: 120px;
    }
}

/* ---- Watermark preview (Watermark Adder) ------------------------- */
.wm-preview-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.wm-preview-wrap canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--tb-radius-sm);
}

.wm-layer {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    user-select: none;
    touch-action: none;
    cursor: move;
}

.wm-text-layer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.wm-image-layer {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ---- Color swatches (Passport Photo) ----------------------------- */
.ie-color-swatches {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ie-color-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid var(--tb-border);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--tb-transition-fast);
    padding: 0;
}

.ie-color-swatch:hover {
    transform: scale(1.1);
}

.ie-color-swatch.active {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-border-focus);
}

/* ============================================
   PREMIUM "COMING SOON" UI FOR OUT-OF-SCOPE IMAGE TOOLS
   ============================================ */

.coming-soon-card {
    max-width: 760px;
    margin: 24px auto;
    padding: 48px 40px;
    text-align: center;
    border-radius: var(--tb-radius-xl, 20px);
    background: linear-gradient(135deg, var(--tb-surface, #ffffff) 0%, var(--tb-bg-elevated, #f8fafc) 100%);
    border: 1px solid var(--tb-border, #e2e8f0);
    box-shadow: var(--tb-shadow-lg, 0 10px 30px rgba(0,0,0,0.08));
    position: relative;
    overflow: hidden;
}

.coming-soon-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(59,130,246,0.08) 0%, transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(139,92,246,0.08) 0%, transparent 40%);
    pointer-events: none;
}

.coming-soon-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--tb-primary, #3b82f6);
    background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(139,92,246,0.12));
    border: 1px solid rgba(59,130,246,0.2);
    position: relative;
    z-index: 1;
}

.coming-soon-badge i {
    animation: coming-soon-pulse 1.8s ease-in-out infinite;
}

.coming-soon-card h2 {
    font-size: 28px;
    font-weight: 800;
    margin: 20px 0 12px;
    color: var(--tb-text-primary, #0f172a);
    position: relative;
    z-index: 1;
}

.coming-soon-card > p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--tb-text-secondary, #64748b);
    max-width: 560px;
    margin: 0 auto 32px;
    position: relative;
    z-index: 1;
}

.coming-soon-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
    position: relative;
    z-index: 1;
}

.coming-soon-feature {
    padding: 18px 14px;
    border-radius: var(--tb-radius-lg, 14px);
    background: var(--tb-surface, #ffffff);
    border: 1px solid var(--tb-border, #e2e8f0);
    box-shadow: var(--tb-shadow-sm, 0 2px 8px rgba(0,0,0,0.04));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.coming-soon-feature:hover {
    transform: translateY(-3px);
    box-shadow: var(--tb-shadow-md, 0 6px 18px rgba(0,0,0,0.06));
}

.coming-soon-feature i {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--tb-primary, #3b82f6);
    background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(139,92,246,0.12));
}

.coming-soon-feature span {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--tb-text-primary, #0f172a);
}

.coming-soon-notify {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 460px;
    margin: 0 auto 24px;
    position: relative;
    z-index: 1;
}

.coming-soon-notify input {
    flex: 1 1 240px;
    padding: 12px 16px;
    border-radius: var(--tb-radius-md, 10px);
    border: 1px solid var(--tb-border, #e2e8f0);
    background: var(--tb-surface, #ffffff);
    color: var(--tb-text-primary, #0f172a);
    font-size: 14px;
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.coming-soon-notify input:focus {
    border-color: var(--tb-primary, #3b82f6);
    box-shadow: 0 0 0 3px var(--tb-border-focus, rgba(59,130,246,0.15));
}

.coming-soon-notify button {
    flex: 0 0 auto;
    padding: 12px 20px;
    border-radius: var(--tb-radius-md, 10px);
    border: none;
    background: linear-gradient(135deg, var(--tb-primary, #3b82f6), var(--tb-primary-dark, #2563eb));
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.coming-soon-notify button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37,99,235,0.28);
}

.coming-soon-notify button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.coming-soon-alternatives {
    font-size: 13px;
    color: var(--tb-text-secondary, #64748b);
    position: relative;
    z-index: 1;
}

.coming-soon-alternatives a {
    color: var(--tb-primary, #3b82f6);
    font-weight: 600;
    text-decoration: none;
    margin: 0 6px;
}

.coming-soon-alternatives a:hover {
    text-decoration: underline;
}

@keyframes coming-soon-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

@media (max-width: 600px) {
    .coming-soon-card {
        padding: 32px 20px;
        margin: 16px;
    }
    .coming-soon-card h2 {
        font-size: 22px;
    }
}
