/* --- CSS Resets and Configuration scoped to the tool --- */
.bg-remover-tool-scope {
    /* Define scoped variables for easy maintenance */
    --background-color: #0d0d10; 
    --card-background: #1c1c24; 
    --primary-color: #3366FF; 
    --secondary-color: #00FFFF; 
    --text-color: #f0f0f0; 
    --shadow-medium: 0 10px 30px rgba(0, 0, 0, 0.4); 
    --border-radius: 16px;
    --transition-speed: 0.3s;
    
    /* Ensure the scope is a block container */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    background-color: var(--background-color);
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
}

.bg-remover-tool-scope * {
    box-sizing: border-box;
    /* Optional: Reset margin/padding for internal elements if conflicts persist */
    /* margin: 0; padding: 0; */ 
}


/* --- Header & Typography --- */
.bg-remover-tool-scope header {
    text-align: center;
    margin-bottom: 40px;
    max-width: 800px;
}

.bg-remover-tool-scope .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

/* Ensure tool's H1 doesn't conflict with site's H1 */
.bg-remover-tool-scope h1 {
    font-size: 2.5rem;
    color: var(--text-color);
    font-weight: 700;
    margin-bottom: 5px;
}

.bg-remover-tool-scope header p {
    color: #a0a0a0;
    font-size: 1.1rem;
}

.bg-remover-tool-scope h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    display: inline-block;
    color: var(--text-color);
}

/* --- Main Layout: Grid Container (1-over-2 structure) --- */
.bg-remover-tool-scope .tool-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    padding: 120px; /* Internal padding for the grid */
}

/* --- Card Styling --- */
.bg-remover-tool-scope .tool-card {
    background: var(--card-background);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bg-remover-tool-scope .tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

/* --- Button Styling --- */
.bg-remover-tool-scope .btn {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bg-remover-tool-scope .btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(51, 102, 255, 0.4);
}

.bg-remover-tool-scope .btn-primary:hover {
    background-color: #2a55d4;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(51, 102, 255, 0.6);
}

.bg-remover-tool-scope .btn-success {
    background-color: #28a745; 
    color: white;
    margin-top: 20px;
}

.bg-remover-tool-scope .btn-success:hover:not(:disabled) {
    background-color: #1e7e34;
    transform: translateY(-1px);
}

.bg-remover-tool-scope .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- 1. Upload Box Specifics --- */
.bg-remover-tool-scope .upload-box {
    grid-column: 1 / span 2;
    align-items: center;
    text-align: center;
    justify-content: space-between;
    position: relative;
}

.bg-remover-tool-scope .drag-drop-area {
    width: 100%;
    padding: 40px 20px;
    border: 3px dashed var(--secondary-color);
    border-radius: 12px;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
    cursor: pointer;
    margin-bottom: 20px;
}

.bg-remover-tool-scope .drag-drop-area.hover {
    background-color: rgba(51, 102, 255, 0.1);
    border-color: var(--primary-color);
}

.bg-remover-tool-scope .drag-drop-area .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.bg-remover-tool-scope .drag-drop-area small {
    color: #a0a0a0;
}

/* --- 2 & 3. Image Display Boxes --- */
.bg-remover-tool-scope .image-display-area {
    flex-grow: 1;
    width: 100%;
    min-height: 250px; 
    background-color: #33333f;
    background-image: linear-gradient(45deg, #2c2c36 25%, transparent 25%), 
                      linear-gradient(-45deg, #2c2c36 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #2c2c36 75%),
                      linear-gradient(-45deg, transparent 75%, #2c2c36 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid #33333f;
}

.bg-remover-tool-scope .placeholder-text {
    color: #777;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.bg-remover-tool-scope .image-preview {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    display: none; 
}

.bg-remover-tool-scope .image-preview.visible {
    display: block;
}

/* --- Loading Indicator --- */
.bg-remover-tool-scope .loading-spinner {
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute; 
    top: 0;
    left: 0;
    background: rgba(28, 28, 36, 0.98);
    border-radius: var(--border-radius);
    z-index: 10;
    text-align: center;
    color: var(--text-color);
}

.bg-remover-tool-scope .loading-spinner.active {
    display: flex;
}

.bg-remover-tool-scope .spinner {
    border: 5px solid #3e3e4a;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

/* --- Error Styling --- */
.bg-remover-tool-scope .error-message {
    color: white;
    background-color: #dc3545;
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-weight: 600;
    display: none;
    animation: fadeIn 0.5s ease-out;
}

/* --- Responsiveness --- */
@media (max-width: 768px) {
    .bg-remover-tool-scope .tool-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .bg-remover-tool-scope .upload-box {
        grid-column: span 1;
    }
    .bg-remover-tool-scope h1 {
        font-size: 2rem;
    }
}