/* =========================================================================
   UPLOAD2 - COMPACT CASCADING VARIANT SELECTION
   Smaller, space-efficient variant cards
   ========================================================================== */
   /* =========================================================================
   DUO FRAME (บานพับ) ADDITIONS - Add to upload2.css
   ========================================================================== */

/* Duo Frame Badge on variant cards */
.variant-card .duo-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
}

/* Duo Quantity Group */
#duoQuantityGroup {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
}

#duoQuantityGroup .form-input {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: #92400e;
}

/* Duo Upload Container */
.duo-set-container {
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    background: #f8f9ff;
    transition: all 0.3s ease;
}

.duo-set-container:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

/* Duo Side Upload Areas */
.duo-side-upload {
    border-radius: 8px;
    padding: 15px;
    background: white;
    transition: all 0.3s ease;
}

.duo-side-upload:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.upload-area-small {
    cursor: pointer;
    text-align: center;
    padding: 20px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.upload-area-small:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area-small:active {
    transform: scale(0.98);
}

/* Duo Side Badge on Photo Cards */
.photo-card-realistic .duo-side-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.duo-side-badge.left {
    background: #10b981;
    color: white;
}

.duo-side-badge.right {
    background: #ef4444;
    color: white;
}

/* Change Quantity Button */
.btn-secondary.btn-small {
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-secondary.btn-small:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.3);
}

.btn-secondary.btn-small:active {
    transform: translateY(0);
}

/* Duo Preview Success Message */
.duo-preview-success {
    margin-top: 10px;
    padding: 10px;
    background: #e0f2fe;
    border-radius: 6px;
    text-align: center;
}

.duo-preview-success i {
    color: #10b981;
}

.duo-preview-success p {
    color: #065f46;
    font-weight: 600;
    margin: 5px 0;
    font-size: 12px;
}

.duo-preview-success small {
    color: #666;
}

/* Mobile Responsive for Duo Frames */
@media (max-width: 768px) {
    .duo-set-container {
        padding: 15px;
    }
    
    .duo-set-container > div[style*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .duo-side-upload {
        padding: 12px;
    }
    
    .upload-area-small {
        padding: 15px;
    }
    
    .upload-area-small i {
        font-size: 24px !important;
    }
    
    .duo-side-badge {
        font-size: 10px !important;
        padding: 4px 8px !important;
    }
    
    /* Change Quantity Button on Mobile */
    .btn-secondary.btn-small {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Duo Frame Photo Grid Adjustments */
.photo-card-realistic[data-duo-frame="true"] {
    border: 2px solid #667eea;
}

.photo-card-realistic[data-duo-frame="true"].needs-adjustment {
    border-color: #f59e0b;
}

.photo-card-realistic[data-duo-frame="true"].ready {
    border-color: #10b981;
}

/* Info Message for Duo Frames */
.duo-info-message {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left: 4px solid #3b82f6;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 14px;
    color: #1e3a8a;
}

.duo-info-message i {
    color: #3b82f6;
    font-size: 18px;
    margin-right: 8px;
}

/* Duo Quantity Summary */
.duo-quantity-summary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: rgba(251, 191, 36, 0.2);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
}








.spacepage {
    margin-top: 70px;
}
.login-custom{
font-size: 60px; 
color: #00cc71; 
margin-bottom: 20px;
}
/* Step Number Badge - Smaller */
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(to right, #E100FF, #7F00FF);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
    margin-right: 8px;
}

.form-label {
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 10px;
}

.form-label i {
  margin-right: 6px;
  font-size: 16px;
  background: linear-gradient(to right, #E100FF, #7F00FF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* =========================================================================
   COMPACT VARIANT GRID (Smaller Cards)
   ========================================================================== */

.variant-grid.compact {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.variant-grid.compact.frames {
    grid-template-columns: repeat(8, 1fr);
}

.variant-card.compact {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.variant-card.compact:hover {
    border-color: #B0B0B0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.variant-card.compact.selected {
    border-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Compact Icon */
.variant-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(to right, #E100FF, #7F00FF);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.variant-icon i {
    font-size: 18px;
    color: white;
}

/* Compact Info */
.variant-info h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #1e293b;
    font-weight: 700;
    text-align: center;
}

.variant-info p {
    color: #64748b;
    font-size: 12px;
    margin: 0;
    text-align: center;
}

/* Compact Check */
.variant-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    /*background: #10b981;*/
    background: linear-gradient(90deg, hsla(152, 100%, 50%, 1) 0%, hsl(160.13deg 55.97% 47.96%) 100%);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.variant-card.compact.selected .variant-check {
    display: flex;
}

.variant-check i {
    color: white;
    font-size: 12px;
}

/* =========================================================================
   COMPACT FRAME CARDS (With Images)
   ========================================================================== */

.variant-card.compact.frame {
    padding: 0;
}

.frame-image-compact {
    width: 100%;
    height: 80px;
    overflow: hidden;
    background: #f8fafc;
}

.frame-image-compact img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.variant-card.compact.frame:hover .frame-image-compact img {
    transform: scale(1.05);
}

.frame-image-compact.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.frame-image-compact.placeholder i {
    font-size: 32px;
    color: #cbd5e1;
}

.variant-card.compact.frame .variant-info {
    padding: 10px;
}

/* =========================================================================
   COMPACT SUMMARY
   ========================================================================== */

.selected-summary.compact {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid #10b981;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
}

.selected-summary.compact .summary-content {
    font-size: 14px;
    color: #065f46;
}

/* =========================================================================
   PHOTO CARDS (Keep existing styles but ensure compatibility)
   ========================================================================== */

/* =========================================================================
   PHOTOS GRID WRAPPER – fixed-height scrollable box
   ========================================================================== */

.photos-grid-wrapper {
    border: 3px solid #a855f7;
    border-radius: 16px;
    overflow: hidden;
    margin-top: 15px;
    background: #faf5ff;
}

.photos-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    border-bottom: 1px solid #a855f730;
}

.photos-count-label {
    font-size: 15px;
    font-weight: 800;
    color: white;
    letter-spacing: 0.5px;
}

.btn-review-all {
    background: white;
    color: #7c3aed;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-review-all:hover { transform: scale(1.04); box-shadow: 0 3px 10px rgba(124,58,237,0.3); }

/* ── Scrollable inner area ── */
.photos-grid-scroll-area {
    max-height: 460px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    scroll-behavior: smooth;
}
.photos-grid-scroll-area::-webkit-scrollbar { width: 5px; }
.photos-grid-scroll-area::-webkit-scrollbar-track { background: #f3e8ff; }
.photos-grid-scroll-area::-webkit-scrollbar-thumb { background: #c084fc; border-radius: 4px; }

/* Desktop: 6 columns */
.photos-grid-realistic {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}/* =========================================================================
   PHOTO CARD – compact, tap-friendly
   ========================================================================== */

.photo-card-realistic {
    background: white;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}
.photo-card-realistic:active { transform: scale(0.96); }

.photo-card-realistic.needs-adjustment {
    border: 2px solid #f59e0b;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.2);
}
.photo-card-realistic.ready {
    border: 2px solid #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

/* ✕ Delete – top-right iOS-style */
.btn-delete-x {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 24px;
    height: 24px;
    background: #dc2626;
    color: white;
    border: 2.5px solid white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(220,38,38,0.5);
}
.btn-delete-x:hover { background: #b91c1c; transform: scale(1.2); }
.btn-delete-x:active { transform: scale(0.9); }

/* Thumbnail – click opens review modal */
.photo-preview-realistic {
    position: relative;
    background: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 140px;
    overflow: hidden;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}
.photo-preview-realistic:active { opacity: 0.85; }

/* Bottom bar: crop btn + qty side by side */
.photo-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 5px;
    background: white;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid #f1f5f9;
    gap: 4px;
}

/* Adjust crop button (small, next to qty) */
.btn-card-crop {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.btn-card-crop:hover { transform: scale(1.1); }
.btn-card-crop:active { transform: scale(0.92); }

.qty-fixed-badge {
    font-size: 9px;
    color: #94a3b8;
    font-weight: 600;
}

/* PC: show meta info below thumbnail */
.photo-meta-pc {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 5px 0;
    font-size: 9px;
    color: #64748b;
    line-height: 1.3;
}
.photo-meta-pc span { display: block; }


.preview-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.crop-overlay-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box-preview {
    position: absolute;
    border: 2px solid #ef4444;
    box-shadow: 
        0 0 0 1px rgba(239, 68, 68, 0.3),
        0 0 0 9999px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    cursor: grab;
}

.crop-frame {
    position: absolute;
    inset: -3px;
}

.crop-frame .corner {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #ef4444;
    background: white;
}

.crop-frame .corner.corner-tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
}

.crop-frame .corner.corner-tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
}

.crop-frame .corner.corner-bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
}

.crop-frame .corner.corner-br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
}

.crop-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
}

.adjustment-badge,
.ready-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.adjustment-badge {
    background: #f59e0b;
    color: white;
}

.ready-badge {
    background: #10b981;
    color: white;
}

.photo-info-realistic {
    padding: 6px;
    background: white;
    position: relative;
}

.photo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    background: #f8fafc;
    border-radius: 4px;
    font-size: 9px;
    color: #475569;
    white-space: nowrap;
    line-height: 1.2;
}

.meta-item i {
    color: #667eea;
    font-size: 9px;
}

.photo-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
}

.btn-edit-crop {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: all 0.3s;
    white-space: nowrap;
    flex: 1;
}

.btn-edit-crop:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #f1f5f9;
    padding: 2px 4px;
    border-radius: 6px;
}

.quantity-control .qty-btn {
    width: 20px;
    height: 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
}

.quantity-control .qty-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
}

.qty-display {
    min-width: 18px;
    text-align: center;
    font-weight: 700;
    font-size: 11px;
    color: #1e293b;
}

/* Old delete button kept for backward compat but hidden */
.btn-remove-photo-separated {
    display: none;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .variant-check {
    top: 3px;
    right: 3px;
}
    .selected-summary.compact {
    padding: 8px;
    margin: 7px 0;
}
    .variant-icon i {
    font-size: 13px;
    color: white;
}
    .variant-icon {
    width: 22px;
    height: 22px;
}
    .variant-card.compact{
    padding: 7px;
}
    .upload-area i {
    font-size: 30px !important;
    
}
    .photo-actions{
    display: inline-flex;
    gap: 3px;

}
    .spacepage {
    margin-top: 25px;
}
    .variant-grid.compact {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .variant-grid.compact.frames {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .photos-grid-realistic {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .photo-preview-realistic {
        height: 150px;
    }
    
    /* Hide PC meta on mobile */
    .photo-meta-pc { display: none; }

    .quantity-control .qty-btn {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
    
    .qty-display {
        min-width: 14px;
        font-size: 11px;
    }
    
    .btn-remove-photo-separated { display: none; }
    
    .adjustment-badge,
    .ready-badge {
        top: 3px;
        right: 3px;
        padding: 2px 5px;
        font-size: 8px;
        gap: 2px;
    }
    
    .crop-label {
        font-size: 7px;
        padding: 2px 5px;
    }
    
    .crop-frame .corner {
        width: 8px;
        height: 8px;
        border-width: 2px;
    }
}

@media (max-width: 480px) {
    .variant-grid.compact {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================================================
   CROP EDITOR MODAL
   ========================================================================== */

.crop-editor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.crop-editor-modal.active {
    display: flex;
}

.crop-editor-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f172a;
}

.crop-editor-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #334155;
    flex-wrap: wrap;
    gap: 15px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title i {
    font-size: 28px;
    color: #667eea;
}

.header-title h3 {
    color: white;
    font-size: 24px;
    margin: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.info-badge {
    background: rgba(102, 126, 234, 0.2);
    color: #a5b4fc;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-close-crop {
    width: 48px;
    height: 48px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 2px solid #ef4444;
    border-radius: 12px;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-close-crop:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

.crop-editor-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.crop-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow: auto;
    background: #fff;
}

.crop-canvas {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
}

#cropEditorImage {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box-draggable {
    position: absolute;
    border: 3px solid #ef4444;
    box-shadow: 
        0 0 0 2px rgba(239, 68, 68, 0.5),
        0 0 0 9999px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: move;
    pointer-events: auto;
}

.crop-box-draggable.dragging {
    cursor: grabbing;
    border-color: #10b981;
    box-shadow: 
        0 0 0 2px rgba(16, 185, 129, 0.5),
        0 0 0 9999px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.crop-frame-editor {
    position: absolute;
    inset: -6px;
}

.corner-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid #ef4444;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.corner-handle:hover,
.corner-handle.active {
    background: #ef4444;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3);
}

.corner-handle.tl {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.corner-handle.tr {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.corner-handle.bl {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.corner-handle.br {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.edge-handle {
    position: absolute;
    background: rgba(239, 68, 68, 0.5);
    z-index: 9;
    transition: all 0.2s;
}

.edge-handle:hover,
.edge-handle.active {
    background: #ef4444;
}

.edge-handle.top {
    top: -3px;
    left: 20px;
    right: 20px;
    height: 6px;
    cursor: ns-resize;
}

.edge-handle.bottom {
    bottom: -3px;
    left: 20px;
    right: 20px;
    height: 6px;
    cursor: ns-resize;
}

.edge-handle.left {
    left: -3px;
    top: 20px;
    bottom: 20px;
    width: 6px;
    cursor: ew-resize;
}

.edge-handle.right {
    right: -3px;
    top: 20px;
    bottom: 20px;
    width: 6px;
    cursor: ew-resize;
}

.crop-info-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.crop-grid {
    position: absolute;
    inset: 0;
}

.grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.grid-line.vertical {
    width: 1px;
    height: 100%;
}

.grid-line.vertical:nth-child(1) {
    left: 33.33%;
}

.grid-line.vertical:nth-child(2) {
    left: 66.67%;
}

.grid-line.horizontal {
    height: 1px;
    width: 100%;
}

.grid-line.horizontal:nth-child(3) {
    top: 33.33%;
}

.grid-line.horizontal:nth-child(4) {
    top: 66.67%;
}

.crop-dimensions {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.crop-tools {
    width: 320px;
    background: #1e293b;
    border-left: 2px solid #334155;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-btn {
    background: rgba(102, 126, 234, 0.2);
    color: #a5b4fc;
    border: 2px solid #667eea;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}

.tool-btn:hover {
    background: #667eea;
    color: white;
    transform: translateX(-4px);
}

.tool-tips {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    border: 2px dashed #667eea;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.5;
}

.tip-item i {
    color: #667eea;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.crop-editor-footer {
    background: #1e293b;
    padding: 20px 30px;
    border-top: 2px solid #334155;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.btn-cancel {
    background: #475569;
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-cancel:hover {
    background: #64748b;
}

.btn-save-crop {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-save-crop:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* ==========================================================================
   MOBILE CROP EDITOR
   ========================================================================== */

@media (max-width: 768px) {
    .mobile-text {
        display: none;
    }
    
    /* === LIGHT THEME APP-LIKE MODAL === */
    .crop-editor-modal {
        background: rgba(255, 255, 255, 0.98);
    }
    
    .crop-editor-container {
        background: #f8fafc;
    }
    
    /* === TOP BAR: Cancel & Confirm (icon only) === */
    .crop-editor-header {
        padding: 10px 15px;
        background: white;
        border-bottom: 1px solid #e2e8f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .header-title {
        display: none; /* Hide title on mobile */
    }
    
    .header-info {
        display: none; /* Hide info badges on mobile */
    }
    
    /* Cancel button (X) - top left */
    .btn-close-crop {
        width: 44px;
        height: 44px;
        background: #b60000;
        color: #ffffff;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        font-size: 20px;
        order: 1;
    }
    
    .btn-close-crop:active {
        background: #f1f5f9;
        transform: scale(0.95);
    }
    
    /* === BODY: Maximum canvas space === */
    .crop-editor-body {
        flex-direction: column;
        background: #f8fafc;
    }
    
    .crop-canvas-container {
        flex: 1;
        padding: 20px 15px;
        min-height: 0;
        max-height: calc(100svh - 130px);
        overflow: auto;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 16px;
        margin: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    
    /* Hide desktop tools */
    .crop-tools {
        display: none !important;
    }
    
    /* === BOTTOM BAR: 2 buttons per row === */
    .crop-editor-footer {
        padding: 6px;
        gap: 10px;
        background: white;
        border-top: 1px solid #e2e8f0;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
        grid-gap: 3px;
    }
    
    /* Tool buttons - icon only, 2 columns */
    .crop-editor-footer .tool-btn {
        background: white;
        color: #475569;
        border: 2px solid #e2e8f0;
        padding: 14px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .crop-editor-footer .tool-btn:active {
        transform: scale(0.97);
    }
   
.divider {
  width: 1px;
  height: 28px;
  background-color: #d1d5db;
  margin: auto; /* ⭐ สำคัญสุด สำหรับ grid */
}
    
    /* Row 1: Rotate Left | Rotate Right */
    .crop-editor-footer .tool-btn:nth-child(1) {
        background: none;
        color: none;
        border-color: none;
    }
    
    .crop-editor-footer .tool-btn:nth-child(2) {
        background: none;
        color: none;
        border-color: none;
    }
    
    /* Row 2: Center | Auto Fit */
    .crop-editor-footer .tool-btn:nth-child(3) {
        background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
        color: #2563eb;
        border-color: #60a5fa;
    }
    
    .crop-editor-footer .tool-btn:nth-child(4) {
        background: none;
        color: none;
        border-color: none;
    }
    
    /* Hide old cancel/save buttons */
    .btn-cancel,
    .btn-save-crop {
        display: none !important;
    }
    /*
    
    .crop-box-draggable {
        border: 3px solid #818cf8;
        box-shadow: 
            0 0 0 2px rgba(129, 140, 248, 0.4),
            0 0 0 9999px rgba(0, 0, 0, 0.4),
            inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    }
    */
    .crop-box-draggable {
  position: relative;
  border-radius: 12px;
}

/* animated border */
.crop-box-draggable::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 3px; /* ความหนา border */
  border-radius: inherit;

  background: linear-gradient(
    90deg,
    hsla(152, 100%, 50%, 1),
    hsla(186, 100%, 69%, 1),
    hsla(152, 100%, 50%, 1)
  );
  background-size: 300% 300%;
  animation: cropBorderAnimate 3s linear infinite;

  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;

  pointer-events: none;
}

@keyframes cropBorderAnimate {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}


.crop-box-draggable{
    border:none;
    box-shadow: none;
}
/*
    .crop-box-draggable.dragging {
        border-color: #34d399;
        box-shadow: 
            0 0 0 3px rgba(52, 211, 153, 0.5),
            0 0 0 9999px rgba(0, 0, 0, 0.4),
            inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    }
    

    .corner-handle {
        width: 32px;
        height: 32px;
        border: 3px solid #818cf8;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(129, 140, 248, 0.3);
    }
    
    .corner-handle:active,
    .corner-handle.active {
        background: #818cf8;
        border-color: #6366f1;
        transform: scale(1.05);
    }
    
    .edge-handle.top,
    .edge-handle.bottom {
        display: none;
    }
    
    .edge-handle.left,
    .edge-handle.right {
        display: none;
    }
    .edge-handle {
    position: absolute;
    
   
}
    
    .edge-handle:active,
    .edge-handle.active {
        background: #818cf8;
    }
    */


    /* ================================
   Crop box while dragging
   ================================ */
.crop-box-draggable.dragging {
  border-color: #34d399;
  box-shadow:
    0 0 0 3px rgba(52, 211, 153, 0.5),
    0 0 0 9999px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

/* ================================
   Corner handles
   ================================ */
    .corner-handle {
        position: absolute;
        width: 18px;
        height: 18px;
        border: 3px solid #00ffab;
        background: #ffffff;
        border-radius: 3px;
        box-shadow: 0 2px 8px rgba(129, 140, 248, 0.3);
        transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    }

/* Active / dragging */
.corner-handle:active,
.corner-handle.active {
  background: #818cf8;
  border-color: #6366f1;
  transform: scale(1.05);
}

/* ================================
   Edge handles (disabled)
   ================================ */
.edge-handle {
  position: absolute;
}

/* Hide top/bottom edges */
.edge-handle.top,
.edge-handle.bottom {
  display: none;
}

/* Hide left/right edges */
.edge-handle.left,
.edge-handle.right {
  display: none;
}

/* Active edge (if ever enabled later) */
.edge-handle:active,
.edge-handle.active {
  background: #818cf8;
}

    /* Crop dimensions display */
    .crop-dimensions {
        font-size: 13px;
        padding: 8px 12px;
        bottom: 10px;
        background: rgba(255, 255, 255, 0.95);
        color: #475569;
        border: 1px solid #e2e8f0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Grid lines - more visible */
    .grid-line {
        background: rgba(129, 140, 248, 0.4);
    }
    
    /* Crop label - softer color */
    .crop-label {
        background: rgba(129, 140, 248, 0.95);
        color: white;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* === Mobile Save Button (Top Right) === */
@media (max-width: 768px) {
    .btn-save-crop-mobile {
        width: 44px;
        height: 44px;
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 24px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        order: 2;
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    }
    
    .btn-save-crop-mobile:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(16, 185, 129, 0.4);
    }
}
/* ==========================================================================
   PHOTO REVIEW MODAL (PRM) – matches design spec Image 2
   Light grey background, status top-left, bin top-right,
   large photo + draggable red crop box, footer: qty + ยกเลิก + ยืนยัน
   ========================================================================== */

.photo-review-modal {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
    background: rgba(80,80,80,0.7);
    backdrop-filter: blur(4px);
}

.photo-review-modal.prm-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Main card container – full screen on ALL devices */
.prm-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    background: #d4d4d4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.97);
    transition: transform 0.22s ease;
    border-radius: 0;
    /* Safari: prevent layout shift when bottom bar appears */
    contain: strict;
}

.photo-review-modal.prm-visible .prm-container {
    transform: scale(1);
}

/* ── TOP BAR: status left, nav centre, bin right ── */
.prm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #d4d4d4;
    flex-shrink: 0;
    gap: 10px;
}

.prm-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prm-counter {
    color: #555;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.prm-status-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
}
.prm-status-badge.needs {
    background: #f59e0b;
    color: white;
}
.prm-status-badge.ready {
    background: #10b981;
    color: white;
}

/* Bin / delete button – top right, circle, dark red */
.prm-bin-btn {
    width: 44px;
    height: 44px;
    background: #7f1d1d;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(127,29,29,0.4);
}
.prm-bin-btn:hover { background: #991b1b; transform: scale(1.08); }
.prm-bin-btn:active { transform: scale(0.93); }

/* ── Image area ── */
.prm-image-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #d4d4d4;
    overflow: visible;
    min-height: 0;
    padding: 0 10px;
}

/* Photo + crop overlay wrapper – simple, no positioning tricks needed */
.prm-photo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.prm-photo-img {
    display: block;
    max-width: 100%;
    max-height: 72dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: 2px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}


/* Crop box: position:fixed, overlays exactly over the rendered image */
.prm-crop-box-fixed {
    position: absolute;
    border: 2.5px solid #ef4444;
    cursor: move;
    pointer-events: auto;
    touch-action: none;
    z-index: 12001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
}

/* 4 dark panels surrounding the crop box — no box-shadow hack */
.prm-overlay-panel {
    position: absolute;
    background: rgba(0,0,0,0.55);
    z-index: 12000;
    pointer-events: none;
}

.prm-crop-label {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Nav arrows (prev/next) */
.prm-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.25);
    border: 1.5px solid rgba(255,255,255,0.4);
    color: #333;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}
.prm-prev { left: 6px; }
.prm-next { right: 6px; }
.prm-nav:hover { background: rgba(255,255,255,0.55); }
.prm-nav-hidden { opacity: 0; pointer-events: none; }

/* ── Dot strip ── */
.prm-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 16px;
    flex-wrap: wrap;
    background: #d4d4d4;
    flex-shrink: 0;
    max-height: 40px;
    overflow: hidden;
}
.prm-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.18s;
    flex-shrink: 0;
    padding: 0;
}
.prm-dot.ready { background: #9ca3af; }
.prm-dot.needs { background: #d97706; }
.prm-dot.active { transform: scale(1.6); }
.prm-dot.ready.active { background: #10b981; }
.prm-dot.needs.active { background: #f59e0b; }

/* ── Footer: จำนวน | ยกเลิก | ยืนยัน ── */
.prm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.prm-qty-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.prm-qty-label {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.prm-qty-control {
    display: flex;
    align-items: center;
    gap: 3px;
}

.prm-qty-btn {
    width: 32px;
    height: 32px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.prm-qty-btn:hover { background: #059669; }
.prm-qty-btn:active { transform: scale(0.92); }

.prm-qty-val {
    min-width: 30px;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
}

.prm-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 20px;
    height: 44px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
}
.prm-btn:active { transform: scale(0.94); }

/* ยกเลิก – red */
.prm-btn-cancel {
    background: #ef4444;
    color: white;
    box-shadow: 0 3px 10px rgba(239,68,68,0.35);
}
.prm-btn-cancel:hover { background: #dc2626; }

/* ยืนยัน – green with icon */
.prm-btn-confirm {
    background: #10b981;
    color: white;
    box-shadow: 0 3px 10px rgba(16,185,129,0.35);
}
.prm-btn-confirm:hover { background: #059669; }

/* Small screen tweaks */
@media (max-width: 380px) {
    .prm-qty-label { font-size: 13px; }
    .prm-btn { padding: 0 14px; height: 40px; font-size: 13px; }
    .prm-footer { padding: 12px; gap: 8px; }
}

/* ── PRM img wrap: crop box lives inside here ── */
.prm-img-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
}
.prm-crop-box-abs {
    position: absolute;
    border: 2.5px solid #ef4444;
    cursor: move;
    touch-action: none;
    z-index: 10;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
    box-sizing: border-box;
}
.prm-overlay-abs {
    position: absolute;
    background: rgba(0,0,0,0.52);
    pointer-events: none;
    z-index: 9;
}
