/* 1. GLOBAL LAYOUT & THEME SYNC */
body, html { 
    margin: 0; 
    padding: 0; 
    height: 100%; 
    overflow: hidden; 
    background: var(--bg-page); /* Matches Merge CSS */
    color: var(--text-main);    /* Matches Merge CSS */
    font-family: 'Inter', sans-serif; 
    transition: background 0.3s ease, color 0.3s ease;
}

/* 2. STAGE 1: UPLOAD VIEW */
.hero-section.center-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px); /* Centers content below navbar */
    text-align: center;
    padding: 20px;
}

.upload-container {
    background: var(--primary); /* Red theme */
    color: white;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 80px 40px;
    border-radius: 24px;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 10px 30px rgba(229, 62, 62, 0.3);
    transition: transform 0.2s;
}

.upload-container:hover { transform: scale(1.02); }

.upload-btn-main {
    background: white;
    color: var(--primary);
    border: none;
    padding: 15px 40px;
    font-weight: 800;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
}

/* 3. STAGE 2: WORKSPACE (The Underlap Fix) */
.workspace-container { 
    display: flex; 
    height: calc(100vh - 80px); /* Strictly fills space below 80px navbar */
    background-color: var(--bg-page); 
}

.file-zone { 
    flex: 1; 
    padding: 40px; /* Safety zone to keep dots away from edges */
    background: #111; /* Contrast for editing */
    display: flex; 
    align-items: center; 
    justify-content: center;
    position: relative; 
    overflow: auto; 
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 10px 50px rgba(0,0,0,0.7);
    display: inline-block;
}

#imageCanvas { 
    max-width: 100% !important; 
    max-height: 80vh; /* Prevents vertical overflow */
    display: block; 
    transform-origin: top center; /* Fix for zoom-out alignment */
}

/* 4. SIDEBAR & CONTROLS */
.sidebar { 
    width: 320px; 
    background: var(--bg-sidebar); 
    border-left: 1px solid var(--border-color); 
    padding: 30px; 
    display: flex; 
    flex-direction: column; 
    z-index: 10;
}

/* Professional Orientation Buttons */
.btn-outline {
    background: var(--card-bg);
    color: var(--text-main);
    border: 2px solid var(--border-color);
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.action-btn { 
    background: var(--primary); 
    color: white; 
    padding: 18px; 
    border: none; 
    border-radius: 12px; 
    font-weight: 700; 
    cursor: pointer; 
    margin-top: auto; 
}

/* 5. GLOWING HANDLES (Visibility Fix) */
.corner-handle {
    position: absolute;
    width: 30px; 
    height: 30px;
    background: var(--primary); 
    border: 3px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%); 
    z-index: 1000; /* Floats above sidebar shadow */
    cursor: move;
    /* Glow ensures visibility on dark backgrounds */
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6); 
}

/* 6. STAGE 3: SUCCESS VIEW */
/* SUCCESS VIEW (Stage 3) */
#success-view {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: var(--bg-page); /* Adapts to theme variables */
    display: flex;
    align-items: center; 
    justify-content: center; 
    z-index: 2000; 
    backdrop-filter: blur(10px);
}

.success-container.center-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.success-ring {
    width: 100px; 
    height: 100px; 
    background: #dcfce7; /* Light green ring */
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    margin: 0 auto 30px; 
    animation: pulse 2s infinite; /* Uses the keyframes defined below */
}

.success-check {
    font-size: 40px;
    color: #22c55e;
}

.success-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 30px;
    color: var(--text-main);
}

/* Fix for the collapsed buttons */
.success-actions { 
    display: flex; 
    gap: 15px; 
    justify-content: center; 
    margin-top: 10px; 
}

/* Reusing your working Merge PDF button styles */
.btn-primary, .btn-outline { 
    padding: 14px 28px; 
    border-radius: 12px; 
    font-weight: 700; 
    cursor: pointer; 
    transition: 0.3s; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 15px;
}

.btn-primary { 
    background: var(--primary); 
    color: white; 
    border: none; 
}

.btn-outline { 
    background: var(--card-bg); 
    color: var(--text-main); 
    border: 2px solid var(--border-color); 
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { box-shadow: 0 0 0 20px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.hidden { display: none !important; }

/* MOBILE OPTIMIZATION for PDFHEROS Photo-to-PDF */
/* MOBILE-ONLY TOOL LAYOUT */
/* MOBILE-ONLY SCANNER LAYOUT */
@media (max-width: 768px) {
    /* 1. Hide titles and descriptive text */
    .sidebar h2, 
    .sidebar label, 
    .sidebar p,
    .sidebar .perspective-note {
        display: none !important;
    }

    /* 2. Transform Sidebar into a compact Bottom Bar */
    .sidebar {
        
        position: fixed !important;
        bottom: 0 !important; /* Forces bar to the very bottom */
        left: 0;
        width: 100% !important;
        height: auto !important;
        padding: 15px !important;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border-color);
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important; /* Space between the two buttons */
        z-index: 9999;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
    }

    /* 3. Style the Rotate Button */
    .sidebar button:has(span:contains("Rotate")), 
    .sidebar .rotate-btn {
        width: 100% !important;
        height: 45px !important;
        font-weight: 600 !important;
    }

    /* 4. Style the Extract Button */
    .action-btn, #extractBtn {
        width: 100% !important;
        height: 50px !important;
        margin: 0 !important;
        font-weight: 700 !important;
        text-transform: uppercase;
    }

    /* 5. Adjust the Image Canvas area to stop above the buttons */
    .file-zone {
        height: calc(100vh - 200px) !important;
        padding-bottom: 20px !important;
    }
    /* Make the visual dot slightly larger for mobile */
    .corner-handle {
        width: 35px !important; 
        height: 35px !important;
        /* Add a larger transparent area to catch finger touches */
        border: 10px solid transparent; 
        background-clip: padding-box;
    }
    /* 1. Scale down the heading */
    .success-title {
        font-size: 24px !important;
        line-height: 1.2 !important;
        padding: 0 15px !important;
        word-wrap: break-word;
    }

    /* 2. Stack buttons vertically */
    .success-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
        padding: 0 20px !important;
        box-sizing: border-box;
    }

    .btn-primary, .btn-outline {
        width: 100% !important;
        justify-content: center !important;
        height: 50px !important;
        margin: 0 !important;
    }

    /* 3. Create a safety gap for the Advertisement */
    #success-view {
        padding-bottom: 120px !important;
    }
    

}