/* Photo Editor States
   ==================== */
.photo-state {
    display: none;
    animation: stepFadeIn 0.3s ease-out;
}

.photo-state.active {
    display: block;
}

/* Upload state: fill height so dropzone can center vertically */
.photo-state-upload.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Upload State */

/* Photo Disclaimer */
.photo-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 16px;
}

.photo-disclaimer svg {
    flex-shrink: 0;
    color: #d97706;
    margin-top: 1px;
}

.photo-disclaimer p {
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
    margin: 0;
}

/* Photo Grid Editor
   ==================== */

.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 4px 0 100px 0; /* bottom padding for sticky bar */
    overflow-y: auto;
    align-content: flex-start;
}

/* Individual photo card */
.pg-card {
    width: 220px;
    background: white;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: width 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

/* Portrait photos get narrower card */
.pg-card.portrait {
    width: 160px;
}

/* Expanded = ~3x, nearly full panel width */
.pg-card.expanded {
    width: 600px;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.15);
    border-color: rgba(79, 70, 229, 0.25);
}

/* Photo display area inside card */
.pg-card-photo {
    position: relative;
    background: var(--color-bg-subtle);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    overflow: hidden;
}

.pg-card-photo canvas {
    width: 100%;
    display: block;
    border-radius: 0;
}

/* Loading overlay per card */
.pg-card-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.05);
    z-index: 10;
    overflow: hidden;
    pointer-events: none;
    display: none;
}

.pg-card.processing .pg-card-loading {
    display: block;
}

/* Reuse the edge glow + logo from original editor */
.pg-card-loading .editor-edge-glow {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 2;
    overflow: hidden;
}

.pg-card-loading .editor-edge-glow::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        transparent 60%,
        rgba(99, 102, 241, 0.12) 75%,
        rgba(99, 102, 241, 0.2) 80%,
        rgba(99, 102, 241, 0.12) 85%,
        transparent 100%
    );
    animation: editorEdgeSpin 3s linear infinite;
}

.pg-card-loading .editor-edge-glow::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: transparent;
    border-radius: inherit;
    box-shadow: inset 0 0 0 2000px rgba(0, 0, 0, 0);
}

@keyframes editorEdgeSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pg-card-loading .editor-loading-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 50%;
    opacity: 0.55;
    z-index: 3;
    animation: editorLogoPulse 2s ease-in-out infinite;
}

@keyframes editorLogoPulse {
    0%, 100% {
        opacity: 0.4;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.65;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Card info bar (filename + badge) */
.pg-card-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    gap: 6px;
    min-height: 28px;
}

.pg-card-filename {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.pg-card-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.pg-card-badge.edited {
    background: #ede9fe;
    color: #4f46e5;
}

.pg-card-badge.processing {
    background: #fef3c7;
    color: #d97706;
}

/* Card action buttons row */
.pg-card-actions {
    display: flex;
    gap: 4px;
    padding: 4px 8px 8px;
}

.pg-card-btn {
    flex: 1;
    padding: 5px 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    background: white;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    color: var(--color-text-secondary);
}

.pg-card-btn:hover:not(:disabled) {
    border-color: var(--color-primary, #4f46e5);
    color: var(--color-primary, #4f46e5);
    background: rgba(79, 70, 229, 0.04);
}

.pg-card-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pg-card-btn.btn-delete {
    color: #dc2626;
}

.pg-card-btn.btn-delete:hover:not(:disabled) {
    border-color: #f87171;
    color: #dc2626;
    background: #fef2f2;
}

/* Preset buttons row — Rotate (instant) + toggleable Enhance/Furnish */
.pg-card-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.pg-preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: white;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pg-preset-btn:hover:not(:disabled) {
    border-color: var(--color-primary, #4f46e5);
    color: var(--color-primary, #4f46e5);
    background: rgba(79, 70, 229, 0.04);
}

/* Selected toggle state */
.pg-preset-btn.pg-toggle.selected {
    background: rgba(79, 70, 229, 0.08);
    border-color: #818cf8;
    color: #4f46e5;
    font-weight: 600;
}

.pg-preset-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pg-preset-btn.active {
    background: rgba(79, 70, 229, 0.08);
    border-color: #818cf8;
    color: #4f46e5;
}

/* Convert format modal */
.pg-convert-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pg-convert-modal-box {
    background: white;
    border-radius: 14px;
    padding: 28px 32px;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.pg-convert-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.pg-convert-modal-sub {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.pg-convert-modal-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 14px;
}

.pg-convert-modal-btn {
    padding: 10px 22px;
    border: 2px solid rgba(79, 70, 229, 0.2);
    border-radius: 10px;
    background: white;
    color: var(--color-primary, #4f46e5);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pg-convert-modal-btn:hover {
    background: var(--color-primary, #4f46e5);
    border-color: var(--color-primary, #4f46e5);
    color: white;
}

.pg-convert-modal-skip {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
}

/* Convert inline row */
.pg-convert-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.pg-convert-row.hidden {
    display: none;
}

.pg-convert-select {
    padding: 6px 10px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    color: var(--color-text-secondary);
    background: white;
    cursor: pointer;
}

.pg-convert-go {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: var(--color-primary, #4f46e5);
    color: white;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* Close button inside expanded edit form */
.pg-card-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text-muted);
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.pg-card-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text);
}

/* Inline edit form (shown when card is expanded) */
.pg-card-edit {
    position: relative;
    padding: 8px 10px 10px;
    display: none;
}

.pg-card.expanded .pg-card-edit {
    display: block;
    animation: stepFadeIn 0.2s ease-out;
}

.pg-card-edit-row {
    display: flex;
    gap: 6px;
}

.pg-card-edit-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    background: var(--color-bg);
    font-family: inherit;
    min-width: 0;
}

.pg-card-edit-input:focus {
    outline: none;
    border-color: rgba(79, 70, 229, 0.4);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.pg-card-edit-submit {
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: box-shadow 0.15s ease;
}

.pg-card-edit-submit:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.pg-card-edit-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Edit history inside expanded card */
.pg-card-history {
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.pg-card-history:empty {
    display: none;
}

.pg-card-history-item {
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.pg-card-history-item:last-child {
    border-bottom: none;
}

.pg-card-history-item strong {
    color: #4f46e5;
    font-weight: 600;
}

/* Deleted card state */
.pg-card.deleted {
    opacity: 0.4;
    pointer-events: none;
}

.pg-card.deleted .pg-card-photo {
    filter: grayscale(1);
}

/* Sticky download bar at bottom — compact, right-aligned */
.photo-grid-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0 0 12px 12px;
    z-index: 20;
}

.photo-grid-bar-summary {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-right: auto;
}

.photo-grid-bar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.photo-grid-bar-actions .complete-btn {
    flex: none;
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
}

/* Complete Action Buttons */
.complete-actions {
    display: flex;
    gap: 10px;
}

.complete-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    font-family: inherit;
}

.complete-download-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.complete-download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.complete-download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.complete-startover-btn {
    background: white;
    color: var(--color-text-secondary);
    border-color: var(--color-border-strong);
}

.complete-startover-btn:hover {
    border-color: var(--color-text-faint);
    background: var(--color-bg-subtle);
}

/* Re-edit button on thumbnails */
.complete-thumb-reedit {
    display: block;
    width: 100%;
    padding: 6px 0;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: transparent;
    color: #4f46e5;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.complete-thumb-reedit:hover {
    background: var(--color-primary-bg);
}

/* Complete Upsell Overlay */
.complete-upsell-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: upsellFadeIn 0.25s ease-out;
}

.complete-upsell-overlay.hidden {
    display: none;
}

@keyframes upsellFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.complete-upsell-modal {
    background: white;
    border-radius: 16px;
    padding: 36px 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: upsellSlideUp 0.3s ease-out;
}

@keyframes upsellSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.complete-upsell-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 14px;
    color: #4f46e5;
    margin-bottom: 16px;
}

.complete-upsell-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.complete-upsell-text {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0 0 24px 0;
}

.complete-upsell-text strong {
    color: #4f46e5;
    font-weight: 600;
}

.complete-upsell-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.complete-upsell-btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    border: none;
    width: 100%;
}

.complete-upsell-yes {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.complete-upsell-yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

.complete-upsell-no {
    background: transparent;
    color: var(--color-text-faint);
    font-weight: 500;
}

.complete-upsell-no:hover {
    color: var(--color-text-muted);
}

/* ==========================================
   iLoveIMG Quick Tools Toolbar
   ========================================== */

.imgt-toolbar {
    padding: 8px 12px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
    background: var(--color-bg-secondary, #FAFBFC);
    margin: 8px 0;
}

.imgt-toolbar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.imgt-toolbar-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.imgt-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}

.imgt-btn:hover:not(:disabled) {
    border-color: var(--color-primary, #4F46E5);
    color: var(--color-primary, #4F46E5);
    background: var(--color-primary-bg, rgba(79, 70, 229, 0.04));
}

.imgt-btn.active {
    border-color: var(--color-primary, #4F46E5);
    color: var(--color-primary, #4F46E5);
    background: var(--color-primary-bg, rgba(79, 70, 229, 0.06));
}

.imgt-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.imgt-btn svg {
    flex-shrink: 0;
}

/* Inline options */
.imgt-inline-opts {
    margin-top: 8px;
}

.imgt-inline-opts.hidden {
    display: none;
}

.imgt-opt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--color-text);
}

.imgt-opt-row.hidden {
    display: none;
}

.imgt-opt-row label {
    font-weight: 500;
    font-size: 12px;
    color: var(--color-text-muted);
}

.imgt-opt-input {
    padding: 4px 8px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    border-radius: 5px;
    font-size: 12px;
    width: 70px;
    background: var(--color-bg);
    color: var(--color-text);
}

.imgt-opt-input:focus {
    outline: none;
    border-color: var(--color-primary, #4F46E5);
}

.imgt-opt-go {
    padding: 4px 12px;
    background: var(--color-primary, #4F46E5);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.imgt-opt-go:hover {
    opacity: 0.9;
}

/* ── Photo Lightbox ── */
.pg-card-zoomable {
    cursor: zoom-in;
}

.pg-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: pgLightboxIn 0.15s ease;
}

@keyframes pgLightboxIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pg-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.pg-lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

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

