/* batch-tool.css — shared additions for batch image tool pages (loads after /style.css) */

/* selected files list */
.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.file-item {
    position: relative;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.file-item img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
}

.file-item-info {
    padding: 6px 8px;
}

.file-item-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1D1D1F;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-meta {
    font-size: 0.7rem;
    color: #8E8E93;
}

.file-item-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.file-item-remove:hover {
    background: #FF3B30;
}

/* results grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    padding: 15px;
    background: #F2F2F7;
    border-radius: 12px;
}

.result-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 10px;
}

.result-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.result-item-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1D1D1F;
    padding: 6px 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.result-item-meta {
    font-size: 0.7rem;
    color: #8E8E93;
    padding-bottom: 6px;
}

.btn-small {
    padding: 7px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* generic form controls used by tool settings */
.setting-item select,
.setting-item textarea,
.setting-item input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #D1D1D6;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
}

.setting-item select:focus,
.setting-item textarea:focus,
.setting-item input[type="text"]:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.setting-item textarea {
    resize: vertical;
    min-height: 60px;
}

.setting-item input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    border: 2px solid #D1D1D6;
    border-radius: 10px;
    background: white;
    cursor: pointer;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #007AFF;
    cursor: pointer;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #3C3C43;
    cursor: pointer;
}

/* segmented (radio-as-button) control */
.seg-control {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.seg-control label {
    flex: 1;
    min-width: 60px;
}

.seg-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.seg-control span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 10px;
    border: 2px solid #D1D1D6;
    border-radius: 10px;
    background: white;
    font-size: 0.85rem;
    font-weight: 600;
    color: #3C3C43;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 6px;
}

.seg-control span:hover {
    border-color: #007AFF;
}

.seg-control input[type="radio"]:checked + span {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
}

.range-value {
    font-size: 0.85rem;
    color: #007AFF;
    font-weight: 600;
    text-align: right;
}

/* settings grid spanning full width for wide controls */
.settings-grid .full-width {
    grid-column: 1 / -1;
}

/* lightbox: enlarged preview of processed results */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.lightbox.open {
    display: flex;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 84vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 24px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-caption {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

@media (max-width: 600px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 8px;
    }

    .lightbox-next {
        right: 8px;
    }
}

/* live preview section (before processing) */
.preview-section {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeIn 0.3s ease;
}

.preview-section h2 {
    font-size: 1.1rem;
    color: #1D1D1F;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-section h2 i {
    color: #007AFF;
}

.preview-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.preview-compare figure {
    background: #F2F2F7;
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
}

.preview-compare img,
.preview-compare canvas {
    width: 100%;
    height: 240px;
    object-fit: contain;
    display: block;
    background:
        repeating-conic-gradient(#E5E5EA 0% 25%, #ffffff 0% 50%) 50% / 20px 20px;
}

.preview-compare figcaption {
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #8E8E93;
}

.preview-note {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #8E8E93;
    text-align: center;
}

@media (max-width: 600px) {
    .preview-compare {
        grid-template-columns: 1fr;
    }
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #007AFF;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.back-link:hover {
    text-decoration: underline;
}

/* before/after comparison slider (live preview) */
.preview-slider-mode {
    display: block;
}

.ba-stage {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: repeating-conic-gradient(#E5E5EA 0% 25%, #ffffff 0% 50%) 50% / 20px 20px;
    touch-action: none;
    cursor: ew-resize;
    user-select: none;
}

.ba-stage > img {
    width: 100%;
    display: block;
    pointer-events: none;
}

.ba-top {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 50%;
    overflow: hidden;
}

.ba-top canvas {
    display: block;
}

.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: #ffffff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
    cursor: ew-resize;
}

.ba-handle:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

.ba-grip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #007AFF;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.ba-tag {
    position: absolute;
    bottom: 10px;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 600;
    pointer-events: none;
}

.ba-tag-before {
    left: 10px;
}

.ba-tag-after {
    right: 10px;
}

.preview-mode-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.preview-mode-btn {
    border: 1px solid #D1D1D6;
    background: #ffffff;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.15s ease;
}

.preview-mode-btn.active {
    background: #007AFF;
    border-color: #007AFF;
    color: #ffffff;
}

/* side-by-side mode reuses the same markup */
.preview-side-mode .ba-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: none;
    overflow: visible;
    cursor: default;
}

.preview-side-mode .ba-stage > img,
.preview-side-mode .ba-top canvas {
    width: 100%;
    height: 240px;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    background: repeating-conic-gradient(#E5E5EA 0% 25%, #ffffff 0% 50%) 50% / 20px 20px;
}

.preview-side-mode .ba-top {
    position: static;
    width: auto;
    overflow: visible;
}

.preview-side-mode .ba-handle,
.preview-side-mode .ba-tag {
    display: none;
}

@media (max-width: 600px) {
    .preview-side-mode .ba-stage {
        grid-template-columns: 1fr;
    }
}

/* output naming pattern setting */
.naming-setting input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #D1D1D6;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
}

.naming-setting input[type="text"]:focus {
    outline: 2px solid #007AFF;
    border-color: #007AFF;
}

.naming-setting .naming-hint {
    font-size: 0.78rem;
    color: #8E8E93;
    margin-top: 6px;
}

/* interactive crop editor */
.crop-stage-wrap {
    text-align: center;
}

.crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}

.crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 480px;
    pointer-events: none;
}

.crop-box {
    position: absolute;
    left: 10%;
    top: 10%;
    width: 80%;
    height: 80%;
    border: 2px solid #007AFF;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
    box-sizing: border-box;
}

.crop-box.crop-circle {
    border-radius: 50%;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 2px solid #007AFF;
    border-radius: 50%;
    box-sizing: border-box;
}

.crop-handle[data-dir="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle[data-dir="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle[data-dir="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle[data-dir="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
