/* ═══════════════════════════════════════════════
   RemoveBG — Design System
   Dark premium glassmorphism theme
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #06060b;
    --bg-secondary: #0d0d16;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(168, 85, 247, 0.3);

    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --accent: #a855f7;
    --accent-light: #c084fc;
    --accent-dark: #7c3aed;
    --accent-glow: rgba(168, 85, 247, 0.25);

    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.2);

    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Shared screen transitions ── */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.5s ease;
}

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

/* ═══════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════ */
#login-screen {
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

/* Animated background glow */
.login-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulseGlow 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.15); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow:
        0 0 80px rgba(168, 85, 247, 0.06),
        0 25px 60px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    margin-bottom: 20px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.login-icon svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

/* ── Form inputs ── */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.06);
}

/* ── Error message ── */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13px;
    padding: 10px 14px;
    margin-bottom: 16px;
    animation: shakeX 0.4s ease;
}

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
}

/* ── Buttons ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-ghost:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* ── Loader spinner ── */
.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ═══════════════════════════════════════════════
   PASSWORD MODAL
   ═══════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.modal-card {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.modal-header svg {
    color: var(--accent);
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ═══════════════════════════════════════════════
   APP SCREEN — TOP BAR
   ═══════════════════════════════════════════════ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: rgba(6, 6, 11, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-left .logo svg {
    color: var(--accent);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-greeting {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px;
    gap: 32px;
}

.section-card {
    width: 100%;
    max-width: 800px;
}

/* ── Dropzone ── */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 80px 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.04);
    box-shadow: 0 0 40px var(--accent-glow);
}

.dropzone.dragover {
    transform: scale(1.01);
}

.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 20px;
    transition: var(--transition);
}

.dropzone:hover .dropzone-icon {
    color: var(--accent);
    transform: translateY(-4px);
}

.dropzone h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dropzone p {
    color: var(--text-secondary);
    font-size: 15px;
}

.dropzone-formats {
    margin-top: 16px;
    font-size: 12px !important;
    color: var(--text-muted) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Processing ── */
.processing-content {
    text-align: center;
    padding: 60px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}

.processing-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-right-color: var(--cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.processing-content > p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    margin: 0 auto 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Result ── */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.result-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.result-actions .btn-primary {
    width: auto;
}

.btn-download {
    background: linear-gradient(135deg, var(--success), #16a34a);
}

.btn-download:hover {
    box-shadow: 0 8px 30px rgba(34, 197, 94, 0.25);
}

/* ── Comparison slider ── */
.comparison-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.comparison-wrapper {
    position: relative;
    overflow: hidden;
    cursor: col-resize;
    /* Checkerboard pattern for transparency */
    background-image:
        linear-gradient(45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a24 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a24 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #12121c;
}

.comparison-img {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

.result-clip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    clip-path: inset(0 50% 0 0);
}

.result-clip .comparison-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.slider-line {
    width: 100%;
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.slider-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--accent-glow);
    cursor: col-resize;
    pointer-events: auto;
    transition: transform 0.2s ease;
}

.slider-knob:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.slider-knob svg {
    width: 14px;
    height: 14px;
    color: #fff;
}

.comparison-labels {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* ── Image info ── */
.image-info {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
}

.image-info span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.image-info .label {
    color: var(--text-muted);
}

.image-info .value {
    color: var(--text-primary);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════ */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .login-card {
        padding: 36px 24px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .main-content {
        padding: 24px 16px;
    }

    .dropzone {
        padding: 48px 20px;
    }

    .dropzone h2 {
        font-size: 18px;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
    }

    .result-actions .btn-primary,
    .result-actions .btn-secondary {
        flex: 1;
    }

    .image-info {
        flex-direction: column;
        gap: 8px;
    }

    .modal-card {
        padding: 28px 20px;
    }
}

@media (max-width: 480px) {
    .topbar-left .logo span {
        display: none;
    }

    .user-greeting {
        display: none;
    }
}
