/* ==========================================================================
   BACKGROUND CHANGER TOOL — VertualHands Theme (v12.31)
   ========================================================================== */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --text-main: #f8fafc;
    --text-muted: #ffffff;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.tool-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: 'Inter', system-ui, sans-serif;
    box-sizing: border-box;
    overflow-x: hidden;
    width: 100%;
}

.tool-header {
    text-align: center;
    margin-bottom: 32px;
}

.tool-header h1,
.tool-header h2 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.tool-header p {
    color: #ffffff;
    font-size: 1.1rem;
}

.premium-notice {
    display: block;
    clear: both;
    background: transparent !important;
    border: 1px solid #ffffff !important;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: center;
    color: #ffffff !important;
}

.premium-notice strong {
    color: #ffffff !important;
}

.premium-notice a {
    color: #ffffff !important;
    font-weight: 700;
    text-decoration: underline;
}

.premium-notice a:hover {
    color: #ffffff !important;
    opacity: 0.85;
}

/* ============================================================
   WORKSPACE WRAPPERS
   ============================================================ */
.tool-workspace,
.control-group,
.file-queue-container {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 2px dotted rgba(255, 255, 255, 0.3) !important;
    border-radius: 20px;
    box-sizing: border-box;
    max-width: 100%;
}

.workspace-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr;
}

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 2px dotted #ffffff !important;
    border-radius: 20px;
    box-sizing: border-box;
    max-width: 100%;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 30px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: rgba(255, 255, 255, 0.9) !important;
    background: rgba(255, 255, 255, 0.02) !important;
    transform: translateY(-2px);
    box-shadow: none;
}

.upload-area[data-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #ef4444 !important;
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

/* Upload area title (h3.upload-title) */
.upload-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
}

/* Upload area sub-text (p.upload-text) */
.upload-text {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0;
}

.upload-hint {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-top: 6px;
}

.upload-input {
    display: none;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', system-ui, sans-serif;
    box-sizing: border-box;
    text-decoration: none;
}

.action-btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Upload / Select Image button */
.upload-btn,
button.upload-btn,
.upload-area .btn-primary {
    background: var(--accent-gradient) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 12px 28px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    margin-top: 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    transition: opacity 0.2s, transform 0.2s !important;
    box-shadow: none !important;
    min-width: 140px !important;
}

.upload-btn:hover,
button.upload-btn:hover {
    opacity: 0.9 !important;
    transform: translateY(-2px) !important;
}

.upload-btn:disabled,
button.upload-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* btn-success — Apply Crop */
.btn-success,
button.btn-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
}

.btn-success:hover,
button.btn-success:hover {
    opacity: 0.9 !important;
    transform: translateY(-1px) !important;
}

/* btn-secondary — generic ghost button */
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: white;
    transform: translateY(-2px);
}

/* Add More Images button */
.btn-add-more {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-add-more:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.credit-tag {
    display: inline-block;
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid rgba(245, 158, 11, 0.4);
    margin-left: 8px;
}

/* ============================================================
   PREVIEW CANVAS
   ============================================================ */
.preview-container {
    min-height: 400px;
    background-color: #0f172a;
    background-image:
        linear-gradient(45deg, #1e293b 25%, transparent 25%),
        linear-gradient(-45deg, #1e293b 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1e293b 75%),
        linear-gradient(-45deg, transparent 75%, #1e293b 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

.preview-canvas {
    max-width: 100%;
    max-height: 50vh;
    display: block;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.process-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.progress-bar {
    width: 60%;
    max-width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 15px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s;
}

/* ============================================================
   QUEUE POSITION DISPLAY
   ============================================================ */
.queue-position-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 14px 24px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    animation: queueFadeIn 0.4s ease-out;
}

@keyframes queueFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.queue-position-icon {
    font-size: 24px;
    line-height: 1;
}

.queue-position-text {
    color: #93c5fd;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

.queue-position-text span {
    color: #60a5fa;
    font-size: 1.4rem;
    font-weight: 800;

    animation: queueCountPulse 2s ease-in-out infinite;
}

@keyframes queueCountPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7;  }
}

.queue-position-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.queue-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #60a5fa;
    animation: queueDotBounce 1.4s ease-in-out infinite;
}

.queue-dot:nth-child(2) { animation-delay: 0.2s; }
.queue-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes queueDotBounce {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40%            { opacity: 1;   transform: scale(1.2); }
}

/* ============================================================
   CONTROLS SIDEBAR
   ============================================================ */
.control-section {
    margin-bottom: 24px;
}

.control-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 12px;
    font-weight: 600;
    display: block;
}

/* ============================================================
   COLOR GRID
   ============================================================ */
.color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.color-btn {
    aspect-ratio: 1;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.color-transparent {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-color: #fff;
}

.custom-color-wrapper {
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 0;
    z-index: 10;
    display: block !important;
    opacity: 0 !important;
    pointer-events: auto !important;
}

.custom-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.custom-color-input::-webkit-color-swatch { border: none; border-radius: 8px; }
.custom-color-input::-moz-color-swatch { border: none; border-radius: 8px; }

/* ============================================================
   FILE QUEUE (merged from two blocks)
   ============================================================ */
.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    padding: 16px;
    max-height: 250px;
    overflow-y: auto;
}

/* Single consolidated .queue-item rule */
.queue-item {
    position: relative !important;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: visible !important;
    border: 2px solid var(--glass-border);
    background: #0f172a;
    cursor: pointer;
    transition: all 0.2s;
}

.queue-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.queue-item.active    { border-color: #3b82f6; }
.queue-item.completed { border-color: #10b981; }
.queue-item.error     { border-color: #ef4444; }

.queue-remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid #1e293b;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
}

.queue-item:hover .queue-remove-btn { opacity: 1; }

/* ============================================================
   BACKGROUND IMAGE UPLOAD
   ============================================================ */
.bg-image-section {
    margin-top: 16px;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.3); /* single border, no duplicate */
    border-radius: 12px;
}

.bg-image-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.bg-image-upload-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px dashed rgba(139, 92, 246, 0.5);
    color: #a78bfa;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
}

.bg-image-upload-btn:hover {
    background: rgba(139, 92, 246, 0.3);
}

.bg-image-preview {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(139, 92, 246, 0.5);
    display: none;
}

.bg-image-preview.visible { display: block; }

/* ============================================================
   OUTPUT QUALITY
   ============================================================ */
.quality-section {
    margin-top: 24px;
    padding: 16px;
    background: transparent;
    border: 1px solid rgba(16, 185, 129, 0.2); /* single border */
    border-radius: 14px;
}

.quality-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
}

.quality-slider-wrap        { display: block; }
.quality-slider-wrap.hidden { display: none; }

.quality-slider {
    width: 100%;
    height: 8px;
    background: #334155;
    border-radius: 4px;
    -webkit-appearance: none;
    margin: 8px 0;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    cursor: pointer;
    border: 2px solid #1e293b;
}

/* ============================================================
   RESIZE CONTROLS
   ============================================================ */
.resize-section {
    margin-top: 12px;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(59, 130, 246, 0.2); /* single border */
    border-radius: 12px;
}

.resize-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.resize-preset-btn {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.resize-preset-btn:hover  { background: rgba(255, 255, 255, 0.1); color: white; }
.resize-preset-btn.active { background: rgba(59, 130, 246, 0.2); border-color: #3b82f6; color: white; }

.custom-resize-inputs {
    display: none;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.custom-resize-inputs.visible { display: flex; }

.resize-input {
    width: 80px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-main);
    font-size: 0.9rem;
    text-align: center;
}

.resize-x {
    color: var(--text-muted);
    font-weight: 600;
}

/* Aspect Ratio Lock */
.aspect-lock-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
    height: auto;
}

.aspect-lock-toggle input { display: none; }

.aspect-lock-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.aspect-lock-toggle input:checked + .aspect-lock-icon {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

.aspect-lock-toggle:hover { color: white; }

/* ============================================================
   CROP MODAL — PURE LIQUID GLASS THEME (MOBILE OPTIMIZED)
   ============================================================ */

.crop-modal,
#cropModal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px;
    box-sizing: border-box;
}

.crop-modal.show,
.crop-modal.active,
.crop-modal[style*="display: flex"],
.crop-modal[style*="display: block"],
#cropModal.show,
#cropModal.active,
#cropModal[style*="display: flex"],
#cropModal[style*="display: block"] {
    display: flex !important;
}

.crop-modal-content {
    background: linear-gradient(135deg, rgba(20, 26, 40, 0.95) 0%, rgba(10, 15, 28, 0.98) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 24px !important;
    padding: 24px !important;
    max-width: 880px !important;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.6), 0 25px 60px rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    color: #ffffff !important;
}

/* Ensure all text inside the crop modal is clean white */
#cropModal .crop-modal-content,
#cropModal .crop-modal-content p,
#cropModal .crop-modal-content span,
#cropModal .crop-modal-content label,
#cropModal .crop-modal-content strong,
#cropModal .upload-hint,
#cropModal .crop-hint {
    color: #ffffff !important;
}

.crop-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent !important;
}

.crop-modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(180deg, #ffffff 40%, rgba(255, 255, 255, 0.75) 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    letter-spacing: -0.01em;
}

.crop-modal-close {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    width: 36px;
    height: 36px;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.crop-modal-close:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    transform: rotate(90deg);
}

.crop-modal-close svg {
    fill: #ffffff !important;
    width: 18px;
    height: 18px;
}

/* Crop Workspace */
.crop-workspace {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    padding: 0 !important;
    min-height: 480px;
}

.crop-area-container {
    flex: 1;
    min-width: 0;
    height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.crop-area {
    position: relative;
    flex: none !important;
    background: #000000 !important;
    border: 2px solid rgba(59, 130, 246, 0.6) !important;
    border-radius: 12px !important;
    overflow: hidden;
    cursor: grab;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(0, 0, 0, 0.8) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-area:active { cursor: grabbing; }

#cropImage {
    position: absolute;
    left: 50%;
    top: 50%;
    max-width: none !important;
    max-height: none !important;
    transform-origin: center center;
    pointer-events: none;
    user-select: none;
}

.crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 2px dashed rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65) !important;
    z-index: 10;
}

/* Sidebar Controls */
.crop-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 300px;
    min-width: 280px;
    max-width: 300px;
    flex-shrink: 0;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 100;
}

.crop-control-group {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.015) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    padding: 16px 18px !important;
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.crop-control-group label,
.crop-controls label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff !important;
    margin-bottom: 8px;
}

.crop-controls #zoomValue,
.crop-controls #cropBrightnessValue {
    color: #60a5fa !important;
    font-weight: 700 !important;
    float: none !important;
}

/* Ratio Presets */
.crop-ratio-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.ratio-preset-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ratio-preset-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.ratio-preset-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.crop-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s;
}

.crop-input:focus {
    border-color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.1) !important;
    box-shadow: none !important;
}

#cropZoom,
#cropBrightness {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.12) !important;
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
    margin-top: 6px;
}

#cropZoom::-webkit-slider-thumb,
#cropBrightness::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    cursor: pointer;
    border: 2px solid #ffffff !important;
    box-shadow: none !important;
}

#btnRotate {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-radius: 10px !important;
    padding: 10px !important;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#btnRotate:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.btn-reset-crop {
    background: rgba(239, 68, 68, 0.15) !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
    border-radius: 10px !important;
    padding: 10px !important;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-reset-crop:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: none !important;
    transform: translateY(-2px);
}

#cropModal .upload-hint {
    color: #94a3b8 !important;
    font-size: 0.85rem;
    text-align: center;
}

.crop-hint {
    font-size: 0.88rem;
    color: #e2e8f0 !important;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    line-height: 1.55;
    text-align: center;
}

.crop-hint strong { color: #60a5fa !important; }

/* Modal Footer Actions: Cancel (Red) & Apply Crop (Green) */
.crop-modal-actions {
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding-top: 16px !important;
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    background: transparent !important;
}

.crop-modal-actions .btn-secondary {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 13px 28px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    cursor: pointer;
    transition: all 0.25s ease !important;
    box-shadow: none !important;
}

.crop-modal-actions .btn-secondary:hover {
    transform: translateY(-2px) !important;
    box-shadow: none !important;
}

.crop-modal-actions .btn-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 13px 32px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    cursor: pointer;
    transition: all 0.25s ease !important;
    box-shadow: none !important;
}

.crop-modal-actions .btn-success:hover {
    transform: translateY(-2px) !important;
    box-shadow: none !important;
}

/* Responsive */
@media (max-width: 900px) {
    .crop-modal-content {
        max-width: 95vw !important;
        padding: 18px !important;
        gap: 16px;
    }

    .crop-workspace {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        min-height: auto;
    }

    .crop-area-container {
        width: 100%;
        height: 360px;
        max-height: 45vh;
    }

    .crop-controls {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    .crop-modal-actions {
        justify-content: stretch;
        gap: 10px;
    }

    .crop-modal-actions .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
        padding: 12px 16px !important;
    }
}

@media (max-width: 480px) {
    .crop-modal-content {
        padding: 14px !important;
        border-radius: 18px !important;
    }

    .crop-modal-header h3 {
        font-size: 1.15rem;
    }

    .crop-area-container {
        height: 300px;
        max-height: 40vh;
    }

    .crop-control-group {
        padding: 12px 14px !important;
    }

    .crop-hint {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

/* ============================================================
   RESPONSIVE — Desktop (≥ 900px)
   ============================================================ */
@media (min-width: 900px) {
    .workspace-grid {
        grid-template-columns: 1fr 340px;
        align-items: start;
    }

    .controls-column { order: 2; }
    .preview-column  { order: 1; }

    .preview-container {
        min-height: 600px;
    }
}

/* ============================================================
   RESPONSIVE — Tablet (≤ 900px) + Crop Modal Mobile
   ============================================================ */
@media (max-width: 900px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .controls-column { order: 2; }
    .preview-column  { order: 1; }

}

/* ============================================================
   RESPONSIVE — Mobile (≤ 768px)   [merged into single block]
   ============================================================ */
@media (max-width: 768px) {
    .tool-container {
        padding: 20px 12px;
        overflow-x: hidden;
    }

    .tool-workspace,
    .control-group,
    .upload-area,
    .file-queue-container {
        padding: 16px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .color-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .color-btn { min-width: 0; }

    .resize-presets {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .resize-preset-btn {
        padding: 6px 4px;
        font-size: 0.75rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success {
        min-width: 0;
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    /* Always show remove button on touch devices */
    .queue-remove-btn { opacity: 1 !important; }
}

/* ============================================================
   RESPONSIVE — Small Mobile (≤ 600px)
   ============================================================ */
@media (max-width: 600px) {
    .tool-container {
        padding: 16px 8px;
        max-width: 100%;
    }

    .tool-workspace {
        padding: 12px 8px !important;
        border-radius: 12px;
    }

    .tool-header {
        margin-bottom: 16px;
        padding: 0 4px;
    }

    .tool-header h1 {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    .tool-header p { font-size: 0.9rem; }

    .premium-notice {
        padding: 10px;
        font-size: 0.85rem;
        margin: 0 4px 16px 4px;
    }

    .upload-area {
        padding: 24px 12px;
        min-height: 120px;
        margin: 0 0 16px 0;
        border-radius: 12px;
    }

    .upload-icon {
        font-size: 40px;
        margin-bottom: 10px;
    }

    .upload-title { font-size: 1rem; }
    .upload-text  { font-size: 0.85rem; }
    .upload-hint  { font-size: 0.8rem; }

    .preview-container {
        min-height: 200px;
        border-radius: 10px;
        margin-bottom: 12px;
    }

    .preview-canvas { max-height: 35vh; }

    .control-section {
        margin-bottom: 12px;
        padding: 0 4px;
    }

    .control-label {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .color-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .color-btn {
        min-width: 40px;
        min-height: 40px;
        border-radius: 8px;
    }

    .bg-image-section {
        padding: 10px;
        margin-top: 10px;
    }

    .bg-image-upload { flex-wrap: wrap; gap: 8px; }

    .bg-image-upload-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        width: 100%;
    }

    .quality-section {
        padding: 10px;
        margin-top: 12px;
    }

    .quality-select {
        padding: 10px 12px;
        font-size: 0.85rem;
        padding-right: 30px;
    }

    .resize-section {
        padding: 10px;
        margin-top: 10px;
    }

    .resize-presets {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .resize-preset-btn {
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .custom-resize-inputs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .resize-input {
        width: 65px;
        padding: 8px 4px;
        font-size: 0.85rem;
    }

    .action-btn {
        padding: 12px 10px;
        font-size: 0.9rem;
        margin-top: 8px;
    }

    .credit-tag {
        font-size: 0.65rem;
        padding: 2px 5px;
        margin-left: 4px;
    }

    .queue-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
        padding: 10px;
        max-height: 160px;
    }

    .queue-item { border-radius: 6px; }

    .btn-add-more {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    #bulkActions { padding-top: 12px !important; }
}

/* ============================================================
   RESPONSIVE — Extra Small (≤ 375px)
   ============================================================ */
@media (max-width: 375px) {
    .tool-container { padding: 12px 8px; }
    .tool-header h1 { font-size: 1.3rem; }

    .upload-area {
        padding: 24px 12px;
        min-height: 120px;
    }

    .upload-icon { font-size: 40px; }

    .color-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .color-btn {
        min-width: 32px;
        min-height: 32px;
    }

    .resize-presets { grid-template-columns: repeat(2, 1fr); }

    .action-btn {
        padding: 12px 10px;
        font-size: 0.85rem;
    }
}

/* ============================================================
   TOGGLE SWITCH (Border Toggle)
   ============================================================ */
.switch input { opacity: 0; width: 0; height: 0; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #3b82f6; border-color: #3b82f6; }
input:checked + .slider:before { transform: translateX(20px); }