
/* PDF Merge Tool - RED THEME */
:root {
    /* Colors - RED THEME */
    --xee-bg-primary: transparent;
    --xee-bg-secondary: rgba(0, 0, 0, 0.02);
    --xee-bg-tertiary: rgba(0, 0, 0, 0.05);
    --xee-bg-card: rgba(0, 0, 0, 0.03);
    --xee-border: rgba(0, 0, 0, 0.1);
    --xee-border-light: rgba(0, 0, 0, 0.15);
    
    /* Red Theme */
    --xee-red: #DC2626;
    --xee-red-glow: rgba(220, 38, 38, 0.3);
    --xee-red-light: rgba(220, 38, 38, 0.08);
    
    /* Text */
    --xee-text-primary: #000000;
    --xee-text-secondary: rgba(0, 0, 0, 0.8);
    --xee-text-tertiary: rgba(0, 0, 0, 0.6);
    --xee-text-muted: rgba(0, 0, 0, 0.4);
    
    /* Gradients - RED */
    --xee-gradient-primary: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    
    /* Border Radius */
    --xee-radius: 16px;
    --xee-radius-lg: 20px;
    --xee-radius-xl: 24px;
}

/* Base Container */
.pdf-merge-tool {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--xee-text-primary);
    background: transparent;
    position: relative;
}

/* Upload Title */
.upload-title {
    text-align: center;
    margin-bottom: 40px;
    padding: 0 20px;
}

.upload-title h1 {
    font-size: 3rem;
    font-weight: 800;
    margin: 0 0 16px 0;
    background: var(--xee-gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--xee-red);
    line-height: 1.1;
}

.upload-title p {
    font-size: 1.2rem;
    color: var(--xee-text-secondary);
    margin: 0;
    font-weight: 500;
}

/* Upload Section */
.upload-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.upload-section.hidden {
    display: none;
}

.upload-container {
    width: 100%;
    max-width: 500px;
    padding: 40px 24px;
}

.upload-card {
    background: var(--xee-bg-card);
    border: 1px solid var(--xee-border);
    border-radius: var(--xee-radius-xl);
    padding: 48px 40px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.upload-area {
    border: 2px dashed var(--xee-border);
    border-radius: var(--xee-radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    background: var(--xee-bg-tertiary);
    position: relative;
    margin-bottom: 32px;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--xee-red);
    background: var(--xee-red-light);
}

.upload-area.dragover {
    border-color: var(--xee-red);
    background: var(--xee-red-light);
}

.upload-content svg {
    color: var(--xee-red);
    margin-bottom: 16px;
}

.upload-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--xee-text-primary);
}

.upload-content p {
    color: var(--xee-text-tertiary);
    margin: 0;
    font-size: 0.9rem;
}

#pdf-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Workspace */
.workspace {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
    background: transparent;
}

.workspace.hidden {
    display: none;
}

/* Desktop Layout */
.desktop-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Left Panel */
.left-panel {
    flex: 3.9;
    display: flex;
    flex-direction: column;
    background: transparent;
    border-right: 1px solid var(--xee-border);
}

/* Right Panel */
.right-panel {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    background: transparent;
}

/* Panel Header */
.panel-header {
    background: var(--xee-bg-card);
    padding: 24px;
    border-bottom: 1px solid var(--xee-border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--xee-text-primary);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.file-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--xee-text-tertiary);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--xee-border);
    border-radius: 8px;
    background: var(--xee-bg-tertiary);
    color: var(--xee-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.action-btn:hover {
    border-color: var(--xee-red);
    color: var(--xee-text-primary);
    background: var(--xee-red-light);
}

.action-btn.danger {
    color: var(--xee-red);
    border-color: var(--xee-red);
}

/* Preview Content */
.preview-content {
    flex: 1;
    padding: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* PDF Preview Container - FIXED LAYOUT */
.pdf-preview-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    align-content: flex-start;
    overflow-y: auto;
    padding: 4px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--xee-text-tertiary);
}

.empty-icon {
    margin-bottom: 20px;
    color: var(--xee-border);
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--xee-text-secondary);
}

.empty-state p {
    margin: 0 0 20px 0;
    color: var(--xee-text-tertiary);
}

/* PDF Preview Cards - FIXED SIZING */
.pdf-preview-card {
    background: var(--xee-bg-card);
    border: 1px solid var(--xee-border);
    border-radius: var(--xee-radius);
    padding: 16px;
    transition: all 0.3s ease;
    position: relative;
    cursor: grab;
    display: flex;
    flex-direction: column;
    height: 320px; /* Fixed height */
    max-width: 220px;
    margin: 0 auto;
    width: 100%;
}

.pdf-preview-card:active {
    cursor: grabbing;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--xee-text-primary);
    margin: 0 0 4px 0;
    word-break: break-word;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.7rem;
    color: var(--xee-text-tertiary);
    margin: 0;
}

.preview-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.preview-btn {
    background: var(--xee-bg-tertiary);
    border: 1px solid var(--xee-border);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--xee-text-tertiary);
}

.preview-btn:hover {
    border-color: var(--xee-red);
    color: var(--xee-text-primary);
}

/* PDF Canvas Container - FIXED DIMENSIONS */
.pdf-canvas-container {
    background: var(--xee-bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    margin-bottom: 8px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px; /* Fixed minimum height */
    border: 1px solid var(--xee-border);
}

/* PDF Canvas - FIXED STYLING */
.pdf-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background: white;
    display: block !important;
}

.canvas-placeholder {
    width: 100%;
    height: 100%;
    background: var(--xee-bg-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--xee-text-tertiary);
    font-size: 0.7rem;
    text-align: center;
    padding: 10px;
}

.preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--xee-text-tertiary);
    flex-shrink: 0;
    margin-top: 8px;
}

/* Tools Content */
.tools-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tool-section {
    background: var(--xee-bg-card);
    border-radius: var(--xee-radius);
    padding: 20px;
    border: 2px solid var(--xee-red);
    backdrop-filter: blur(20px);
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--xee-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.order-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--xee-bg-tertiary);
    border: 1px solid var(--xee-border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--xee-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.order-btn:hover {
    border-color: var(--xee-red);
    color: var(--xee-text-primary);
    background: var(--xee-red-light);
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--xee-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-item:last-child {
    border-bottom: none;
}

.option-item:hover {
    background: var(--xee-red-light);
    margin: 0 -16px;
    padding: 12px 16px;
    border-radius: 8px;
}

.option-info {
    flex: 1;
    min-width: 0;
    padding-right: 16px;
}

.option-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--xee-text-primary);
    margin-bottom: 2px;
}

.option-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--xee-text-tertiary);
    line-height: 1.3;
}

.option-control {
    position: relative;
    flex-shrink: 0;
}

.option-control input[type="checkbox"] {
    opacity: 0;
    position: absolute;
}

.checkmark {
    width: 44px;
    height: 24px;
    background: var(--xee-bg-tertiary);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    border: 1px solid var(--xee-border);
}

.checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--xee-text-tertiary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.option-control input[type="checkbox"]:checked + .checkmark {
    background: var(--xee-red);
    border-color: var(--xee-red);
}

.option-control input[type="checkbox"]:checked + .checkmark::after {
    background: #ffffff;
    transform: translateX(20px);
}

.file-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--xee-border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-size: 0.9rem;
    color: var(--xee-text-secondary);
}

.summary-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--xee-text-primary);
}

/* Merge Button */
.merge-btn {
    width: 100%;
    background: var(--xee-gradient-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--xee-radius-lg);
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.merge-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.merge-btn:disabled {
    background: var(--xee-bg-tertiary);
    color: var(--xee-text-muted);
    cursor: not-allowed;
    transform: none;
}

.file-badge {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Mobile Toggle Button */
.mobile-toggle-btn {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    color: var(--xee-red);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mobile-toggle-btn:hover {
    background: var(--xee-red-light);
}

/* Mobile Panel Container */
.mobile-panel-container {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.mobile-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: transparent;
}

.mobile-panel.preview-panel {
    transform: translateX(0);
}

.mobile-panel.tools-panel {
    transform: translateX(100%);
}

.mobile-panel-container.preview-active .preview-panel {
    transform: translateX(0);
}

.mobile-panel-container.preview-active .tools-panel {
    transform: translateX(100%);
}

.mobile-panel-container.tools-active .preview-panel {
    transform: translateX(-100%);
}

.mobile-panel-container.tools-active .tools-panel {
    transform: translateX(0);
}

/* Fixed Merge Button Container */
.fixed-merge-container {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--xee-bg-card);
    border-top: 1px solid var(--xee-border);
    padding: 16px 20px;
    z-index: 1000;
    backdrop-filter: blur(20px);
}

/* DRAG AND DROP STYLING - FIXED */
.sortable-ghost {
    opacity: 0.4;
    background: var(--xee-red-light);
}

.sortable-chosen {
    transform: rotate(3deg);
}

.sortable-drag {
    opacity: 0.8;
    background: var(--xee-red-light);
    border-color: var(--xee-red);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.3);
}

.pdf-preview-card.dragging {
    transform: scale(0.95);
    border-color: var(--xee-red);
}

/* Body classes for drag state */
body.dragging-active {
    overflow: hidden !important;
    -webkit-overflow-scrolling: auto !important;
}

body.dragging-active * {
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* Overlay Styles */
.processing-overlay,
.result-overlay,
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.processing-overlay.hidden,
.result-overlay.hidden,
.error-overlay.hidden {
    display: none;
}

.processing-content,
.result-content,
.error-content {
    background: var(--xee-bg-card);
    border-radius: var(--xee-radius-xl);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--xee-border);
    backdrop-filter: blur(20px);
}

.processing-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--xee-border);
    border-top: 3px solid var(--xee-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-container {
    background: var(--xee-bg-tertiary);
    border-radius: var(--xee-radius);
    padding: 20px;
    border: 1px solid var(--xee-border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.progress-step {
    color: var(--xee-text-secondary);
}

.progress-percent {
    font-weight: 600;
    color: var(--xee-red);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--xee-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: var(--xee-gradient-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: var(--xee-border);
    z-index: 1;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 2;
    flex: 1;
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--xee-bg-tertiary);
    border: 2px solid var(--xee-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--xee-text-muted);
    transition: all 0.3s ease;
}

.step.active .step-icon {
    background: var(--xee-red);
    border-color: var(--xee-red);
    color: #ffffff;
}

.step span {
    font-size: 0.8rem;
    color: var(--xee-text-muted);
    font-weight: 500;
}

.step.active span {
    color: var(--xee-red);
}

/* Toast */
.action-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--xee-bg-card);
    border: 1px solid var(--xee-border);
    border-radius: var(--xee-radius);
    padding: 12px 20px;
    color: var(--xee-text-primary);
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .pdf-merge-tool {
        min-height: 100vh;
        max-height: none;
        height: auto;
    }

    .upload-section {
        position: relative;
        height: auto;
        min-height: 100vh;
        padding: 20px 0;
    }

    .upload-container {
        padding: 20px 16px;
    }

    .upload-title h1 {
        font-size: 2.2rem;
    }

    .upload-card {
        padding: 30px 20px;
    }

    .upload-area {
        padding: 30px 16px;
    }

    /* Hide desktop layout on mobile */
    .desktop-layout {
        display: none !important;
    }

    /* Show mobile elements */
    .mobile-toggle-btn {
        display: block;
    }

    .mobile-panel-container {
        display: flex;
    }

    .fixed-merge-container {
        display: block;
    }

    .workspace {
        height: 100vh;
        flex-direction: column;
    }

    /* Mobile PDF Preview - Single Column */
    .pdf-preview-container {
        display: flex !important;
        flex-direction: column;
        gap: 16px;
        overflow-y: auto;
        height: 100%;
        padding: 4px;
    }

    .pdf-preview-card {
        height: 300px;
        max-width: 100%;
        margin: 0;
    }

    .pdf-canvas-container {
        min-height: 160px;
    }

    .mobile-panel .panel-header {
        padding: 16px;
    }

    .mobile-panel .preview-content {
        padding: 12px;
    }

    .mobile-panel .tools-content {
        padding: 16px;
    }

    .mobile-panel .tool-section {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .upload-title h1 {
        font-size: 1.8rem;
    }

    .upload-card {
        padding: 20px 16px;
    }

    .pdf-preview-card {
        padding: 12px;
        height: 280px;
    }
}

/* Desktop Styles */
@media (min-width: 769px) {
    .pdf-merge-tool {
        height: 80vh;
        min-height: 600px;
        max-height: 800px;
    }

    .desktop-layout {
        display: flex;
    }

    .mobile-toggle-btn,
    .mobile-panel-container,
    .fixed-merge-container {
        display: none !important;
    }
}
