/* ==========================================================================
   ToolSphare Background Remover - Luxury Dark Glass Design System
   ========================================================================== */

.bgr-app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: inherit;
    color: #e2e8f0;
}

/* Trust Bar */
.bgr-trust-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.bgr-trust-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #94a3b8;
}

.bgr-trust-item--highlight {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(2, 132, 199, 0.15);
}

/* Card Shell */
.bgr-card {
    background: radial-gradient(circle at 50% 0%, rgba(30, 58, 138, 0.22) 0%, rgba(15, 23, 42, 0.85) 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

/* Dropzone */
.bgr-dropzone {
    border: 2px dashed rgba(56, 189, 248, 0.4);
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.bgr-dropzone:hover,
.bgr-dropzone.is-dragover {
    border-color: #38bdf8;
    background: rgba(2, 132, 199, 0.12);
    box-shadow: 0 0 28px rgba(56, 189, 248, 0.25);
    transform: scale(1.005);
}

.bgr-drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    background: rgba(2, 132, 199, 0.18);
    border: 1px solid rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.bgr-drop-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
}

.bgr-drop-hint {
    font-size: 0.92rem;
    color: #94a3b8;
    max-width: 520px;
    margin: 0 auto 20px auto;
    line-height: 1.5;
}

/* Primary and Auxiliary Buttons */
.bgr-btn-primary {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    min-height: 52px !important;
    min-width: 240px !important;
    padding: 14px 28px !important;
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(56, 189, 248, 0.45) !important;
    border-radius: 12px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 18px rgba(2, 132, 199, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    white-space: nowrap !important;
}

.bgr-btn-primary:hover {
    background: linear-gradient(135deg, #0369a1 0%, #1d4ed8 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 26px rgba(2, 132, 199, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    border-color: #38bdf8 !important;
}

.bgr-btn-secondary {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    min-height: 46px !important;
    min-width: 170px !important;
    padding: 11px 22px !important;
    background: rgba(30, 41, 59, 0.8) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-radius: 12px !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    white-space: nowrap !important;
}

.bgr-btn-secondary:hover {
    background: rgba(51, 65, 85, 0.95) !important;
    color: #ffffff !important;
    border-color: rgba(56, 189, 248, 0.45) !important;
    transform: translateY(-1px) !important;
}

.bgr-btn-subtle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 40px !important;
    padding: 8px 18px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 10px !important;
    color: #cbd5e1 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.18s ease !important;
    white-space: nowrap !important;
}

.bgr-btn-subtle:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.24) !important;
}

/* Sample Images Row */
.bgr-samples-row {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bgr-samples-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bgr-sample-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.bgr-sample-chip:hover {
    background: rgba(2, 132, 199, 0.25);
    border-color: rgba(56, 189, 248, 0.5);
    color: #38bdf8;
    transform: translateY(-1px);
}

/* Processing & Loading Overlay */
.bgr-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 24px;
    text-align: center;
}

.bgr-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(56, 189, 248, 0.2);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: bgrSpin 0.9s linear infinite;
}

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

.bgr-loading-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.bgr-loading-sub {
    font-size: 0.88rem;
    color: #94a3b8;
    max-width: 420px;
}

.bgr-progress-bar-wrap {
    width: 260px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.bgr-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0284c7, #38bdf8);
    transition: width 0.3s ease;
}

/* Workspace Shell */
.bgr-workspace {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Top Toolbar */
.bgr-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bgr-mode-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bgr-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 18px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #94a3b8;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.bgr-mode-btn:hover {
    color: #ffffff;
    background: rgba(51, 65, 85, 0.9);
}

.bgr-mode-btn.is-active {
    background: rgba(2, 132, 199, 0.25);
    border-color: rgba(56, 189, 248, 0.55);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.bgr-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    font-size: 0.82rem;
    color: #94a3b8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Controls Grid */
.bgr-controls-panel {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    align-items: center;
}

.bgr-control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bgr-control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.84rem;
    font-weight: 600;
    color: #cbd5e1;
}

.bgr-control-val {
    color: #38bdf8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
}

.bgr-slider {
    width: 100%;
    accent-color: #0284c7;
    cursor: pointer;
}

.bgr-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
    color: #cbd5e1;
    cursor: pointer;
    margin-top: 12px;
}

.bgr-toggle-wrap input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #0284c7;
    cursor: pointer;
}

/* Background Replacement Palette */
.bgr-bg-palette-card {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.bgr-bg-options {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bgr-bg-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
    padding: 0;
    outline: none;
    box-sizing: border-box;
}

.bgr-bg-swatch:hover {
    transform: scale(1.15);
    border-color: #ffffff;
}

.bgr-bg-swatch.is-active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.4);
    transform: scale(1.1);
}

.bgr-bg-swatch--checker {
    background-image: linear-gradient(45deg, #334155 25%, transparent 25%),
                      linear-gradient(-45deg, #334155 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #334155 75%),
                      linear-gradient(-45deg, transparent 75%, #334155 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    background-color: #1e293b;
}

.bgr-bg-swatch--white { background-color: #ffffff; }
.bgr-bg-swatch--black { background-color: #000000; }
.bgr-bg-swatch--grad1 { background: linear-gradient(135deg, #0f172a, #1e293b); }
.bgr-bg-swatch--grad2 { background: linear-gradient(135deg, #ff7e5f, #feb47b); }
.bgr-bg-swatch--grad3 { background: linear-gradient(135deg, #4338ca, #06b6d4); }
.bgr-bg-swatch--grad4 { background: linear-gradient(135deg, #065f46, #10b981); }

.bgr-custom-color-input {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

/* Canvas Viewport */
.bgr-canvas-container {
    position: relative;
    width: 100%;
    min-height: 480px;
    max-height: 75vh;
    border-radius: 16px;
    overflow: hidden;
    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;
    background-color: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

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

.bgr-canvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

/* Before / After Slider Handle */
.bgr-slider-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #38bdf8;
    box-shadow: 0 0 12px #38bdf8;
    cursor: ew-resize;
    z-index: 10;
}

.bgr-slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #0284c7;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    pointer-events: none;
}

.bgr-canvas-tag {
    position: absolute;
    bottom: 16px;
    padding: 6px 14px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #ffffff;
    pointer-events: none;
    z-index: 5;
}

.bgr-tag--before { left: 16px; }
.bgr-tag--after { right: 16px; color: #38bdf8; }

/* Export Bar Actions */
.bgr-export-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.bgr-export-group-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bgr-export-group-sub {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Toast */
.bgr-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    border: 1px solid #38bdf8;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.3);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bgr-toast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
    .bgr-card {
        padding: 20px 16px !important;
    }
    .bgr-dropzone {
        padding: 36px 16px !important;
    }
    .bgr-workspace-header {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .bgr-mode-tabs {
        width: 100% !important;
    }
    .bgr-mode-btn {
        flex: 1 !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
        padding: 8px 10px !important;
    }
    .bgr-export-bar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .bgr-export-group-main,
    .bgr-export-group-sub {
        width: 100% !important;
    }
    .bgr-btn-primary,
    .bgr-btn-secondary {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 640px) {
    .bgr-controls-panel {
        grid-template-columns: 1fr !important;
        padding: 16px !important;
    }
    .bgr-canvas-container {
        min-height: 360px !important;
    }
    .bgr-mode-tabs {
        flex-direction: column !important;
    }
    .bgr-mode-btn {
        width: 100% !important;
    }
}
