/**
 * PorikkhaDaw AI Background Remover Studio - Modern Pro UI Theme
 * Inspired by Adobe Express, Canva Magic Studio & PhotoRoom
 */

:root {
    --bgr-primary: #7c3aed;
    --bgr-primary-hover: #6d28d9;
    --bgr-primary-light: #f5f3ff;
    --bgr-secondary: #06b6d4;
    --bgr-accent-grad: linear-gradient(135deg, #7c3aed 0%, #7c3aed 50%, #06b6d4 100%);
    --bgr-accent-glow: 0 12px 32px -4px rgba(124, 58, 237, 0.28);
    --bgr-bg-surface: #ffffff;
    --bgr-bg-subtle: #f8fafc;
    --bgr-border: #e2e8f0;
    --bgr-border-focus: #a78bfa;
    --bgr-text-main: #0f172a;
    --bgr-text-muted: #64748b;
    --bgr-radius-xl: 1.25rem;
    --bgr-radius-lg: 0.85rem;
    --bgr-radius-md: 0.6rem;
    --bgr-shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --bgr-shadow-hover: 0 20px 35px -8px rgba(15, 23, 42, 0.12), 0 10px 15px -5px rgba(15, 23, 42, 0.06);
}

/* Base Studio Container */
.bgr-studio-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ─── Hero Header ─── */
.bgr-hero {
    background: linear-gradient(135deg, #2e1065 0%, #4c1d95 40%, #6d28d9 100%);
    border-radius: var(--bgr-radius-xl);
    padding: 2.75rem 2.25rem 2.25rem;
    color: #ffffff;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px -15px rgba(46, 16, 101, 0.4);
}

.bgr-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.25) 0%, rgba(124, 58, 237, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.bgr-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bgr-accent-grad);
}

.bgr-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 1;
}

.bgr-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.45rem 1rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #a5f3fc;
}

.bgr-hero-chips {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.bgr-hero-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ede9fe;
}

.bgr-hero-title {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 1;
}

.bgr-hero-title-grad {
    background: linear-gradient(135deg, #a5f3fc 0%, #38bdf8 50%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bgr-hero-desc {
    color: #ddd6fe;
    font-size: 1.05rem;
    max-width: 720px;
    line-height: 1.6;
    margin-bottom: 1.75rem;
    position: relative;
    z-index: 1;
}

.bgr-hero-steps {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.65rem 1.25rem;
    border-radius: 9999px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.bgr-hero-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #ede9fe;
}

.bgr-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #06b6d4;
    color: #082f49;
    font-weight: 800;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bgr-hero-step-arrow {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
}

/* ─── Upload Dropzone Card ─── */
.bgr-dropzone-card {
    background: #ffffff;
    border: 2px dashed #cbd5e1;
    border-radius: var(--bgr-radius-xl);
    padding: 4rem 2rem 3rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--bgr-shadow-card);
    position: relative;
    overflow: hidden;
}

.bgr-dropzone-card:hover, .bgr-dropzone-card.dragover {
    border-color: var(--bgr-primary);
    background: #fafafa;
    transform: translateY(-3px);
    box-shadow: var(--bgr-shadow-hover);
}

.bgr-dropzone-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    background: var(--bgr-accent-grad);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
    box-shadow: var(--bgr-accent-glow);
    animation: bgrFloat 3.5s ease-in-out infinite;
}

@keyframes bgrFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.bgr-btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--bgr-accent-grad);
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.95rem 2.25rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    box-shadow: var(--bgr-accent-glow);
    transition: all 0.25s ease;
    margin-bottom: 1.75rem;
}

.bgr-btn-upload:hover {
    transform: scale(1.03);
    box-shadow: 0 16px 36px -4px rgba(124, 58, 237, 0.4);
    color: #ffffff;
}

.bgr-dropzone-amend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 2.5rem;
}

.bgr-format-chip {
    background: var(--bgr-bg-subtle);
    border: 1px solid var(--bgr-border);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bgr-text-muted);
}

.bgr-format-chip-private {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

/* Sample Presets Grid */
.bgr-samples-row {
    border-top: 1px solid var(--bgr-border);
    padding-top: 2rem;
    margin-top: 1.5rem;
}

.bgr-samples-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bgr-text-muted);
    margin-bottom: 1.25rem;
}

.bgr-sample-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.bgr-sample-item {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: var(--bgr-radius-md);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.bgr-sample-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.bgr-sample-item:hover {
    border-color: var(--bgr-primary);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.25);
}

.bgr-sample-item:hover img {
    transform: scale(1.12);
}

.bgr-sample-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.85));
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.35rem 0.2rem 0.25rem;
    text-align: center;
}

/* ─── Studio Workspace Layout ─── */
.bgr-workspace {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .bgr-workspace {
        grid-template-columns: 1fr;
    }
}

/* Canvas Viewport Card */
.bgr-canvas-card {
    background: #ffffff;
    border-radius: var(--bgr-radius-xl);
    border: 1px solid var(--bgr-border);
    box-shadow: var(--bgr-shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Canvas Toolbar */
.bgr-canvas-toolbar {
    background: #ffffff;
    border-bottom: 1px solid var(--bgr-border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    z-index: 10;
}

.bgr-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.bgr-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--bgr-radius-md);
    background: var(--bgr-bg-subtle);
    border: 1px solid var(--bgr-border);
    color: var(--bgr-text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bgr-tool-btn:hover:not(:disabled) {
    background: var(--bgr-primary-light);
    border-color: var(--bgr-border-focus);
    color: var(--bgr-primary);
}

.bgr-tool-btn.active {
    background: var(--bgr-primary);
    border-color: var(--bgr-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.bgr-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Viewport Area */
.bgr-viewport-wrap {
    position: relative;
    width: 100%;
    min-height: 520px;
    max-height: 720px;
    background-color: #f1f5f9;
    background-image: 
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 1.5rem;
}

/* Split Comparison Slider Container */
.bgr-split-container {
    position: relative;
    max-width: 100%;
    max-height: 580px;
    overflow: hidden;
    border-radius: var(--bgr-radius-lg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    background-image: 
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.bgr-split-img-cutout {
    display: block;
    max-width: 100%;
    max-height: 580px;
    object-fit: contain;
    user-select: none;
}

.bgr-split-original-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    clip-path: inset(0 0 0 50%);
}

.bgr-split-img-original {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
}

/* Modern Split Slider Handle */
.bgr-split-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.45);
    cursor: ew-resize;
    transform: translateX(-50%);
    z-index: 5;
    touch-action: none;
}

.bgr-split-handle-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--bgr-primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bgr-primary);
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.bgr-split-handle:hover .bgr-split-handle-btn {
    transform: translate(-50%, -50%) scale(1.15);
}

/* Render Canvas */
#bgrRenderCanvas {
    max-width: 100%;
    max-height: 580px;
    object-fit: contain;
    border-radius: var(--bgr-radius-lg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.16);
}

/* Loading Overlay */
.bgr-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.bgr-scanner-box {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: var(--bgr-radius-lg);
    background: var(--bgr-accent-grad);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--bgr-accent-glow);
    overflow: hidden;
}

.bgr-scan-beam {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #a5f3fc;
    box-shadow: 0 0 15px #a5f3fc;
    animation: bgrScan 1.6s ease-in-out infinite alternate;
}

@keyframes bgrScan {
    0% { top: 0%; }
    100% { top: 95%; }
}

.bgr-load-stages {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.bgr-stage {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--bgr-text-muted);
    background: var(--bgr-bg-subtle);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid var(--bgr-border);
}

.bgr-progress-bar {
    width: 280px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.bgr-progress-fill {
    height: 100%;
    width: 20%;
    background: var(--bgr-accent-grad);
    transition: width 0.3s ease;
}

/* ─── Controls Sidebar Card ─── */
.bgr-controls-card {
    background: #ffffff;
    border-radius: var(--bgr-radius-xl);
    border: 1px solid var(--bgr-border);
    box-shadow: var(--bgr-shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tabs Header */
.bgr-tabs-header {
    display: flex;
    border-bottom: 1px solid var(--bgr-border);
    background: var(--bgr-bg-subtle);
}

.bgr-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--bgr-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bgr-tab-btn:hover {
    color: var(--bgr-primary);
    background: rgba(124, 58, 237, 0.04);
}

.bgr-tab-btn.active {
    color: var(--bgr-primary);
    background: #ffffff;
    border-bottom-color: var(--bgr-primary);
}

/* Panel Section */
.bgr-panel-section {
    display: none;
    padding: 1.5rem;
    max-height: 480px;
    overflow-y: auto;
}

.bgr-panel-section.active {
    display: block;
}

.bgr-control-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--bgr-text-main);
    margin-bottom: 0.75rem;
    margin-top: 1rem;
}

.bgr-control-title:first-child {
    margin-top: 0;
}

/* Swatches Grid */
.bgr-swatch-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.bgr-swatch-btn {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--bgr-radius-md);
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.bgr-swatch-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.bgr-swatch-btn.active {
    border-color: var(--bgr-primary);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.4);
    transform: scale(1.08);
}

.bgr-swatch-btn.transparent {
    background-color: #f1f5f9;
    background-image: 
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

/* Scene Grid */
.bgr-scene-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.bgr-scene-btn {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--bgr-radius-md);
    overflow: hidden;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    padding: 0;
    background: transparent;
    transition: all 0.2s ease;
}

.bgr-scene-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bgr-scene-btn:hover {
    border-color: var(--bgr-primary);
    transform: translateY(-2px);
}

.bgr-scene-btn:hover img {
    transform: scale(1.1);
}

.bgr-scene-btn.active {
    border-color: var(--bgr-primary);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.4);
}

.bgr-scene-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.85));
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.2rem;
    text-align: center;
}

/* Slider Controls */
.bgr-slider-group {
    margin-bottom: 1.15rem;
}

.bgr-slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bgr-text-muted);
    margin-bottom: 0.4rem;
}

.bgr-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 9999px;
    outline: none;
}

.bgr-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bgr-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4);
    transition: transform 0.15s ease;
}

.bgr-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Export Panel & Buttons */
.bgr-export-panel {
    border-top: 1px solid var(--bgr-border);
    padding: 1.25rem 1.5rem;
    background: var(--bgr-bg-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bgr-btn-download-hd {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: var(--bgr-accent-grad);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--bgr-radius-lg);
    border: none;
    cursor: pointer;
    box-shadow: var(--bgr-accent-glow);
    transition: all 0.25s ease;
}

.bgr-btn-download-hd:hover {
    transform: scale(1.02);
    box-shadow: 0 16px 36px -4px rgba(124, 58, 237, 0.4);
    color: #ffffff;
}

.bgr-btn-set-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1rem;
    background: #ffffff;
    border: 1px solid var(--bgr-primary);
    color: var(--bgr-primary);
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: var(--bgr-radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.bgr-btn-set-avatar:hover {
    background: var(--bgr-primary-light);
}

.bgr-export-subgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
