/* Sejda-like Merge CSS Refined */

/* Main Container */
.merge-main-container {
    background-color: #f8fafc;
    /* Professional light slate bg */
    min-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
}

/* Upload View - Centered & Clean */
.merge-upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    background: white;
    position: relative;
    overflow: hidden;
}

/* Background Pattern - Sejda Style */
.merge-upload-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/static/assets/bg-pattern-editor-sejda.svg');
    background-size: cover;
    opacity: 0.7;
    z-index: 0;
}

.merge-upload-card {
    text-align: center;
    max-width: 650px;
    width: 100%;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.merge-hero-title {
    font-size: 2.5rem;
    color: #2d3748;
    margin-bottom: 12px;
    font-weight: 600;
}

.merge-hero-subtitle {
    font-size: 1.1rem;
    color: #2563eb;
    margin-bottom: 40px;
    line-height: 1.6;
}

/* Features Section (Restored from Old Design) */
.merge-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin-top: 20px;
    width: 100%;
    max-width: 1000px;
    position: relative;
    z-index: 1;
}

.merge-feature-item {
    background: white;
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid #f1f5f9;
}

.merge-feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.merge-feature-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary);
    /* Defaults to blue if var not set, or fall back */
    color: #2563eb;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 24px;
}

.merge-feature-item h4 {
    color: #0f172a;
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 1.1rem;
}

.merge-feature-item p {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Wavy Separator */
.wave-separator {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
    line-height: 0;
    z-index: 1;
}

.wave-separator img {
    width: 100%;
    height: 120px;
    display: block;
}

/* Helper Texts */
.upload-helper-text {
    color: #a0aec0;
    font-size: 0.9rem;
    margin-top: 16px;
    margin-bottom: 8px;
}

.upload-privacy-text {
    color: #718096;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.upload-policy-links {
    font-size: 0.8rem;
    color: #a0aec0;
}

.upload-policy-links a {
    color: #2563eb;
    text-decoration: underline;
}

/* Responsive Features */
@media (max-width: 768px) {
    .merge-features {
        grid-template-columns: 1fr;
    }
}

/* View Switcher Mock (in upload view) */
.view-switcher-mock {
    display: inline-flex;
    margin-bottom: 24px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #e2e8f0;
}

.view-switcher-mock span {
    padding: 8px 20px;
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.view-switcher-mock span.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-weight: 600;
}

/* Upload Button */
.btn-upload-merge {
    background-color: #2563eb;
    /* Primary Blue */
    color: white;
    font-size: 18px;
    padding: 16px 48px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2), 0 2px 4px -1px rgba(37, 99, 235, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-upload-merge:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.25);
}

.btn-upload-merge:active {
    transform: translateY(1px);
}

/* Workspace Header - Compact */
.workspace-header {
    text-align: center;
    padding: 20px 20px 10px;
    /* Reduced vertical padding */
    background: white;
}

.workspace-title {
    font-size: 1.8rem;
    /* Slightly smaller */
    color: #333;
    margin-bottom: 4px;
    /* Tighter spacing */
    font-weight: 700;
}

.workspace-subtitle {
    color: #888;
    margin-bottom: 16px;
    /* Reduced space before controls */
    font-size: 1rem;
}

.workspace-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: relative;
    max-width: 900px;
    margin: 0 auto;
}

/* View Toggle - Sejda Segmented Style */
.view-toggle {
    display: inline-flex;
    background: white;
    border: 1px solid #c7c7c7;
    border-radius: 4px;
    overflow: hidden;
    /* For proper corner radiuses */
    padding: 0;
}

.toggle-btn {
    border: none;
    background: white;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 1px solid #c7c7c7;
    border-radius: 0;
    /* Remove individual radius */
}

.toggle-btn:last-child {
    border-right: none;
}

.toggle-btn:hover {
    background: #f9f9f9;
}

.toggle-btn.active {
    background: #e6f7ef;
    /* Sejda Light Green bg */
    color: #009d57;
    /* Sejda Green text */
    font-weight: 700;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.05);
}


.zoom-control {
    position: absolute;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #888;
    background: transparent;
    border: none;
    padding: 0;
}

/* Media query for small screens to stack controls */
@media (max-width: 768px) {
    .workspace-controls {
        flex-direction: column;
        gap: 15px;
    }

    .zoom-control {
        position: static;
    }
}


/* Sejda Action Toolbar (Blue Outline Buttons) */
.workspace-actions-bar {
    background: #f0f0f0;
    /* Light grey stripe behind buttons */
    padding: 15px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.sejda-btn-group {
    display: inline-flex;
    gap: -1px;
    /* Overlap borders */
}

.btn-sejda-action {
    background: white;
    border: 1px solid #6fa1e0;
    /* Sejda Blue outline */
    color: #4b89dc;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

/* Rounded corners for group */
.btn-sejda-action:first-child {
    border-radius: 4px 0 0 4px;
}

.btn-sejda-action:last-child {
    border-radius: 0 4px 4px 0;
}

.btn-sejda-action:not(:first-child):not(:last-child) {
    border-radius: 0;
    border-left: none;
}

.btn-sejda-action:hover {
    background: #e6f2ff;
    z-index: 1;
    /* Bring to front on hover */
}

/* Grid Layout - Strict Sejda Replication */
/* Target both potential classes to ensure grid works */
.file-list-container,
.grid-view-files,
.grid-view-pages {
    padding: 50px;
    display: grid;
    /* Strict min-width to ensure multiple columns on desktop */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 40px;
    align-items: start;
    justify-content: center;
    min-height: 600px;
    background-color: #f7f7f7;
    /* Sejda-like workspace grey */
    max-width: 1400px;
    /* Limit max width so cards don't stretch too much */
    margin: 0 auto;
}

/* Dynamic sizing override if JS sets it - cleaner variable usage */
.file-list-container[style*="--card-size"],
.grid-view-files[style*="--card-size"],
.grid-view-pages[style*="--card-size"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr));
}

/* Card Styling - Compact Sejda Style */
.card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    /* Reduced from 12px to give more room to image */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Height scales with width (aspect ratio approx 1.4 for A4 feel) */
    height: calc(var(--card-size, 220px) * 1.4);
    position: relative;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
    border-color: #94a3b8;
    z-index: 10;
}

.card:active {
    cursor: grabbing;
}

/* Thumbnail Area - Dynamic Height */
/* Thumbnail Area - Dynamic Height */
.card img.card-thumb {
    width: 100%;
    /* Force full width */
    height: auto;
    /* Allow auto height based on flex */
    min-height: 0;
    /* Critical for flex shrinking */
    flex-grow: 1;
    object-fit: contain;
    /* Ensure it fits but fills as much as possible */
    margin-bottom: 0px;
    /* Remove margin as label handles padding */
    background: white;
    /* Removed individual border/shadow to look cleaner at scale */
}

.card-icon {
    /* Scale icon size */
    font-size: calc(var(--card-size, 220px) * 0.4);
    /* Larger icon */
    color: #ef4444;
    /* PDF Red */
    margin: auto 0;
    /* Center vertically in available space */
    opacity: 0.9;
}

.card-info {
    margin-top: auto;
    width: 100%;
    text-align: center;
    flex-shrink: 0;
    z-index: 2;
    background: #fffbeb;
    /* Light yellow background */
    border-top: 1px solid #fef3c7;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 48px;
    /* Increased slightly for two lines */
    justify-content: center;
}

.doc-name {
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.page-num {
    font-size: 10px;
    color: #9ca3af;
    font-weight: 500;
}

.card-name {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

/* Remove Button - Stylish Floating Action */
.btn-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    border: 3px solid white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .btn-remove {
    opacity: 1;
    transform: scale(1);
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}


/* Bottom Bar - Floating with Blur */
/* Bottom Bar - Floating with Blur (Compacted) */
.bottom-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px;
    /* Reduced from 20px */
    text-align: center;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    /* Reduced gap */
}

.btn-merge-huge {
    background: #10b981;
    /* Emerald Green */
    color: white;
    font-size: 16px;
    /* Reduced from 18px */
    font-weight: 600;
    padding: 10px 40px;
    /* Reduced from 14px 48px */
    border: none;
    border-radius: 8px;
    /* Slightly tighter radius */
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-merge-huge:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

.btn-merge-huge:active {
    transform: translateY(0);
}

.btn-merge-huge:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.options-link {
    font-size: 14px;
    color: #64748b;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}

.options-link:hover {
    color: #2563eb;
    text-decoration: underline;
}