/* ========================================
   SuperCutout — Tool Page Styles V2 Unified
   Teal+Coral theme · Canvas compositing
   Size presets · VIP modal · Mobile bottom panel
   ======================================== */

.tool-page {
    background: var(--bg-secondary);
}

.tool-main {
    min-height: calc(100vh - 72px);
    padding-top: 72px;
}

/* ========================================
   Upload State
   ======================================== */
.tool-upload-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 72px);
    padding: 2rem;
}

.tool-upload-area {
    max-width: 640px;
    width: 100%;
}

.upload-visual {
    background: white;
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 4rem 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.02), var(--shadow-md);
}

.upload-visual:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow:
        inset 0 2px 12px rgba(13, 148, 136, 0.04),
        0 0 0 6px rgba(13, 148, 136, 0.06),
        var(--shadow-lg);
    transform: translateY(-2px);
}

.upload-visual.drag-over {
    border-color: var(--primary);
    border-style: solid;
    background: rgba(13, 148, 136, 0.04);
    box-shadow: 0 0 0 8px rgba(13, 148, 136, 0.08), 0 0 40px rgba(13, 148, 136, 0.06);
    transform: scale(1.01);
}

.upload-visual.drag-over .upload-circle {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.upload-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(6, 182, 212, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--primary);
    transition: all 0.3s ease;
}

.upload-visual:hover .upload-circle {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(6, 182, 212, 0.12));
}

.upload-visual h1,
.upload-visual h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-visual p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-formats {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-bottom: 1.5rem;
}

.upload-visual .btn-primary,
.upload-visual .btn {
    background: var(--gradient-cta);
    padding: 0.875rem 2.25rem;
    font-size: 1rem;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.3);
    color: white;
    font-weight: 700;
    transition: all 0.25s ease;
}

.upload-visual .btn-primary:hover,
.upload-visual .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}

/* ========================================
   Processing State
   ======================================== */
.tool-processing-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 72px);
    padding: 2rem;
}

.processing-visual {
    text-align: center;
    max-width: 400px;
}

.processing-spinner {
    width: 80px;
    height: 80px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-right-color: var(--primary-light);
    border-radius: 50%;
    margin: 0 auto 2rem;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.1);
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing-visual h3 { font-size: 1.25rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.processing-visual p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.processing-tip { font-size: 0.875rem; color: var(--text-tertiary); font-style: italic; margin-bottom: 1.5rem; }

.processing-progress { width: 320px; max-width: 90%; height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; margin: 0 auto; }
.progress-bar { height: 100%; background: var(--gradient-brand); border-radius: 4px; width: 0%; transition: width 0.5s ease; }
.processing-tip { transition: opacity 0.3s ease; }
.progress-percent { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-top: 0.75rem; margin-bottom: 0; }
.processing-retry { margin-top: 1.5rem; }
.retry-message { color: #78716c; font-size: 0.85rem; margin-bottom: 0.75rem; font-style: italic; }
.retry-btn { background: var(--gradient-brand); color: #fff; border: none; padding: 0.5rem 1.5rem; border-radius: 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; opacity: 0.9; }
.retry-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,148,136,0.3); opacity: 1; }

/* ========================================
   Result State — High Contrast Override
   ======================================== */
.tool-result-state {
    padding: 1rem 1.5rem;
    background: #E8EDEC;
    animation: fadeScaleIn 0.5s ease;
}

@keyframes fadeScaleIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.result-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Preview */
.result-preview {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #C8D8D5;
}

.preview-tabs {
    display: flex;
    border-bottom: 2px solid #D4E4E1;
    background: #F5F7F6;
}

.preview-tab {
    flex: 1;
    padding: 0.875rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #3D5250;
    transition: all var(--transition);
    border-bottom: 3px solid transparent;
    text-align: center;
}

.preview-tab:hover { color: #0F1B19; background: #EDF0EF; }
.preview-tab.active { color: #0D9488; border-bottom-color: #0D9488; background: white; }

.preview-canvas-wrapper {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image:
        linear-gradient(45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(-45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d0d0d0 75%),
        linear-gradient(-45deg, transparent 75%, #d0d0d0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    padding: 2rem;
}

/* Composite Canvas */
.composite-canvas {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: none;
}

.composite-canvas.visible {
    display: block;
    animation: resultReveal 0.5s ease;
}

.result-img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    animation: resultReveal 0.5s ease;
}

.original-img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

@keyframes resultReveal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ========================================
   Compare Slider
   ======================================== */
.compare-slider { position: absolute; inset: 0; overflow: hidden; }
.compare-before, .compare-after { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.compare-before { clip-path: inset(0 50% 0 0); background: var(--bg-secondary); }
.compare-before img, .compare-after img { max-width: 100%; max-height: 500px; object-fit: contain; }
.compare-before::after { content: 'BEFORE'; position: absolute; top: 1rem; left: 1rem; padding: 0.25rem 0.75rem; background: rgba(0,0,0,0.6); color: white; border-radius: var(--radius-full); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.05em; }
.compare-after::after { content: 'AFTER'; position: absolute; top: 1rem; right: 1rem; padding: 0.25rem 0.75rem; background: rgba(13,148,136,0.8); color: white; border-radius: var(--radius-full); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.05em; }

.compare-handle { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: 40px; display: flex; flex-direction: column; align-items: center; cursor: ew-resize; z-index: 10; }
.handle-line { flex: 1; width: 2px; background: white; box-shadow: 0 0 4px rgba(0,0,0,0.3); }
.handle-circle { width: 44px; height: 44px; border-radius: 50%; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 3px rgba(13,148,136,0.2); display: flex; align-items: center; justify-content: center; font-size: 1.125rem; color: var(--primary); flex-shrink: 0; transition: transform 0.15s ease; }
.handle-circle:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 4px rgba(13,148,136,0.25); }

/* ========================================
   Sidebar
   ======================================== */
.result-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: calc(100vh - 72px - 2rem);
    position: sticky;
    top: calc(72px + 1rem);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(13,148,136,0.25) transparent;
    padding-bottom: 0.25rem;
}

.sidebar-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 0.625rem 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #C8D8D5;
}

.sidebar-section h4 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #3D5250;
    margin-bottom: 0.375rem;
}

/* Background Color Swatches */
.bg-options { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.bg-option { padding: 3px; border: 2px solid #A8BAB7; border-radius: 50%; transition: all var(--transition); cursor: pointer; background: none; }
.bg-option:hover, .bg-option.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.25); }
.bg-swatch { width: 32px; height: 32px; border-radius: 50%; }
.checkerboard-sm { 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-position: 0 0, 0 5px, 5px -5px, -5px 0; }

.bg-upload-option { margin-top: 0.25rem; }
.bg-upload-option .btn { width: 100%; justify-content: center; font-size: 0.8125rem; }

/* ========================================
   Size / Ratio Presets — NEW
   ======================================== */
.size-preset-group {
    margin-bottom: 0.375rem;
}

.preset-group-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.size-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.size-preset-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.35rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #2D3B39;
    background: #F0F4F3;
    border: 1.5px solid #B8CCC8;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.size-preset-btn small {
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: 1px;
}

.size-preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.size-preset-btn.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15);
}

.ratio-presets .ratio-btn {
    min-width: 50px;
    text-align: center;
}

/* Custom size input row */
.custom-size-row {
    display: flex;
    align-items: flex-end;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.size-input-group {
    flex: 1;
}

.size-input-group label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #3D5250;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.size-input-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1.5px solid #A8BAB7;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: #0F1B19;
    background: #F5F7F6;
    transition: border-color 0.2s;
}

.size-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.size-x {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    padding-bottom: 0.5rem;
}

.custom-size-row .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Format Options */
.format-options { display: flex; flex-direction: row; gap: 0.375rem; }
.format-option { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.5rem; background: #F0F4F3; border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); border: 1.5px solid #C8D8D5; flex: 1; }
.format-option:hover { background: var(--bg-tertiary); }
.format-option:has(input:checked) { border-color: var(--primary); background: var(--primary-bg); }
.format-option input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; }
.format-label strong { display: block; font-size: 0.875rem; color: #1A2B28; }
.format-label small { font-size: 0.75rem; color: #5A7370; }

/* Sidebar Actions — always visible, sticky at top of sidebar scroll */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    position: sticky;
    top: 0;
    background: #E8EDEC;
    padding: 0.5rem 0;
    z-index: 5;
}

#downloadBtn {
    background: var(--gradient-cta);
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.3);
    border-radius: var(--radius-md);
    color: white;
    font-weight: 700;
}

#downloadBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}

/* VIP Hint */
.vip-hint {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(6, 182, 212, 0.1));
    border: 1px solid rgba(13, 148, 136, 0.3);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.625rem;
    text-align: center;
}

.vip-hint p {
    font-size: 0.75rem;
    color: #2D3B39;
    margin-bottom: 0.375rem;
}

.vip-hint .btn {
    font-size: 0.8125rem;
}

/* ========================================
   VIP Access Modal
   ======================================== */
.access-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.25s ease;
    padding: 1rem;
}

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

.access-modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.modal-icon { font-size: 3rem; margin-bottom: 1rem; }

.access-modal h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.access-modal p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.modal-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.modal-pill {
    padding: 0.375rem 0.75rem;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.875rem;
    font-size: 0.9375rem;
}

/* ========================================
   Responsive — Desktop Wide
   ======================================== */
@media (min-width: 1440px) {
    .result-layout { max-width: 1320px; grid-template-columns: 1fr 380px; }
}

/* ========================================
   Responsive — Tablet / Mobile
   ======================================== */
@media (max-width: 768px) {
    .result-layout { grid-template-columns: 1fr; }

    .result-sidebar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: white;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        padding: 1rem 1.5rem;
        z-index: 100;
        flex-direction: column;
        gap: 0.75rem;
        max-height: 50vh;
        overflow-y: auto;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    .result-sidebar .sidebar-section {
        padding: 1rem;
        box-shadow: none;
        border: none;
        border-bottom: 1px solid var(--border-light);
        border-radius: 0;
    }

    .result-sidebar .sidebar-section:last-of-type { border-bottom: none; }

    .bg-options {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
        gap: 0.375rem;
    }

    .size-presets {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }

    .sidebar-actions { flex-direction: row; position: static; background: transparent; padding: 0; }
    .sidebar-actions .btn { flex: 1; }

    .result-preview { margin-bottom: 200px; }
    .upload-visual { padding: 3rem 1.5rem; }
    .upload-visual h1, .upload-visual h2 { font-size: 1.25rem; }
    .preview-canvas-wrapper { min-height: 300px; }
}

@media (max-width: 480px) {
    .upload-visual { padding: 2.5rem 1.25rem; }
    .upload-circle { width: 80px; height: 80px; }
    .upload-circle svg { width: 48px; height: 48px; }
    .result-sidebar { padding: 0.75rem 1rem; }
    .sidebar-actions { flex-direction: column; }
    .custom-size-row { flex-wrap: wrap; }
}
