/* ==========================================================================
   WordPress PDF Merger Stylesheet
   ========================================================================== */

/* Design Tokens & Theme Variables */
.pdf-merger-container-wrapper {
    --pm-font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --pm-font-headings: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Colors */
    --pm-bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --pm-card-bg: #ffffff;
    --pm-card-border: #e5e7eb;
    --pm-glass-bg: #f8fafc;
    --pm-glass-border: #cbd5e1;
    --pm-glass-hover: #f1f5f9;
    
    --pm-text-primary: #111827;
    --pm-text-secondary: #6b7280;
    --pm-text-muted: #9ca3af;
    
    /* Accents & States */
    --pm-accent-primary: #2271b1; /* WordPress primary blue */
    --pm-accent-secondary: #135e96;
    --pm-accent-gradient: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    --pm-accent-hover-gradient: linear-gradient(135deg, #135e96 0%, #0d4b78 100%);
    
    --pm-success: #10b981;
    --pm-success-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    
    --pm-warning: #f59e0b;
    --pm-danger: #ef4444;
    --pm-danger-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    
    /* System */
    --pm-radius-lg: 18px;
    --pm-radius-md: 12px;
    --pm-radius-sm: 8px;
    --pm-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
    --pm-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --pm-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout */
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    font-family: var(--pm-font-primary);
    color: var(--pm-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

/* Ensure box-sizing for all internal elements */
.pdf-merger-container-wrapper *,
.pdf-merger-container-wrapper *::before,
.pdf-merger-container-wrapper *::after {
    box-sizing: border-box;
}

/* For WordPress Admin styling isolation */
.pdf-merger-admin-wrap {
    margin: 20px 20px 20px 0;
}
.pdf-merger-admin-wrap h1 {
    font-family: var(--pm-font-headings) !important;
    font-weight: 700 !important;
    color: #1e293b;
}

/* ==========================================================================
   Card Layout (Glassmorphism)
   ========================================================================== */
.pdf-merger-card {
    background: var(--pm-bg-gradient);
    border: 1px solid var(--pm-card-border);
    border-radius: var(--pm-radius-lg);
    box-shadow: var(--pm-shadow-lg);
    overflow: hidden;
    position: relative;
}

/* Glowing Top Border Effect */
.pdf-merger-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--pm-accent-gradient);
    z-index: 10;
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.pdf-merger-header {
    display: flex;
    align-items: center;
    padding: 30px 40px;
    background: #f8fafc;
    border-bottom: 1px solid var(--pm-glass-border);
    gap: 24px;
}

.header-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--pm-radius-md);
    background: var(--pm-accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    box-shadow: 0 0 20px rgba(34, 113, 177, 0.2);
    flex-shrink: 0;
}

.header-text h2 {
    font-family: var(--pm-font-headings);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--pm-text-primary);
    line-height: 1.2;
}

.header-text p {
    font-size: 14px;
    color: var(--pm-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ==========================================================================
   Body & Form Elements
   ========================================================================== */
.pdf-merger-body {
    padding: 40px;
}

/* Dropzone styling */
.pdf-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--pm-radius-md);
    background: var(--pm-glass-bg);
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--pm-transition);
    position: relative;
    overflow: hidden;
}

.pdf-dropzone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--pm-accent-gradient);
    opacity: 0;
    transition: var(--pm-transition);
    z-index: 1;
}

.dropzone-content {
    position: relative;
    z-index: 2;
    transition: var(--pm-transition);
}

.pdf-dropzone:hover {
    border-color: var(--pm-accent-primary);
    background: rgba(34, 113, 177, 0.03);
    box-shadow: 0 0 25px rgba(34, 113, 177, 0.1);
}

.pdf-dropzone.dragover {
    border-color: var(--pm-accent-secondary);
    background: rgba(19, 94, 150, 0.05);
    transform: scale(0.99);
}

.pdf-dropzone.dragover .dropzone-content {
    transform: scale(1.03);
}

.dropzone-icon {
    margin-bottom: 16px;
    color: var(--pm-accent-primary);
    transition: var(--pm-transition);
}

.pdf-dropzone:hover .dropzone-icon {
    transform: translateY(-5px);
}

.pdf-dropzone h3 {
    font-family: var(--pm-font-headings);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--pm-text-primary);
}

.pdf-dropzone p {
    font-size: 13px;
    color: var(--pm-text-secondary);
    margin: 0;
}

/* Bounce Animation */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.animate-bounce {
    animation: bounce 2s infinite ease-in-out;
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.pdf-merger-alert {
    background: #fee2e2;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--pm-radius-sm);
    padding: 12px 16px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #991b1b;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

.alert-icon {
    font-size: 16px;
    color: var(--pm-danger);
    flex-shrink: 0;
}

.alert-message {
    flex-grow: 1;
}

.alert-close {
    background: none;
    border: none;
    color: var(--pm-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: var(--pm-transition);
}

.alert-close:hover {
    color: var(--pm-text-primary);
}

/* ==========================================================================
   Files List View
   ========================================================================== */
.pdf-file-list-container {
    margin-top: 30px;
    animation: fadeIn 0.4s ease;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.list-header h4 {
    font-family: var(--pm-font-headings);
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--pm-text-primary);
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--pm-text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--pm-radius-sm);
    transition: var(--pm-transition);
}

.btn-clear:hover {
    color: var(--pm-danger);
    background: rgba(239, 68, 68, 0.08);
}

.pdf-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* File Card Item */
.pdf-file-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--pm-glass-bg);
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-md);
    transition: var(--pm-transition);
    position: relative;
    user-select: none;
}

.pdf-file-item:hover {
    border-color: var(--pm-glass-border);
    background: var(--pm-glass-hover);
}

.file-item-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 16px;
}

/* Dragging state styled by SortableJS */
.pdf-file-item.sortable-ghost {
    opacity: 0.4;
    border-style: dashed;
    border-color: var(--pm-accent-primary);
    background: rgba(34, 113, 177, 0.05);
}

.pdf-file-item.sortable-chosen {
    border-color: var(--pm-accent-primary);
    box-shadow: var(--pm-shadow-sm);
}

.drag-handle {
    cursor: grab;
    color: var(--pm-text-muted);
    font-size: 16px;
    padding: 4px;
    transition: var(--pm-transition);
}

.drag-handle:hover {
    color: var(--pm-text-secondary);
}

.drag-handle:active {
    cursor: grabbing;
}

.file-icon {
    font-size: 22px;
    color: #ef4444; /* Standard PDF color representation */
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-thumbnail-wrapper {
    width: 24px;
    height: 28px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--pm-glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    flex-shrink: 0;
}

.file-image-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-details {
    flex-grow: 1;
    min-width: 0; /* Ensures text-overflow ellipsis works inside flexbox */
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--pm-text-primary);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--pm-text-secondary);
    display: flex;
    gap: 12px;
    align-items: center;
}

.meta-divider {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: var(--pm-text-muted);
}

.file-remove {
    background: transparent;
    border: none;
    color: var(--pm-text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--pm-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--pm-transition);
}

.file-remove:hover {
    color: var(--pm-danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   Action Bar (Settings and Merge Button)
   ========================================================================== */
.pdf-action-bar {
    margin-top: 35px;
    padding-top: 30px;
    border-top: 1px solid var(--pm-glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    animation: fadeIn 0.4s ease;
}

.output-settings {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    flex-grow: 1;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.output-settings label {
    font-size: 14px;
    font-weight: 500;
    color: var(--pm-text-secondary);
    white-space: nowrap;
}

.filename-input-wrapper,
.select-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    overflow: hidden;
    transition: var(--pm-transition);
    width: 100%;
}

.filename-input-wrapper {
    max-width: 250px;
}

.select-input-wrapper {
    max-width: 280px;
}

.filename-input-wrapper:focus-within,
.select-input-wrapper:focus-within {
    border-color: var(--pm-accent-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

.filename-input-wrapper input {
    background: transparent !important;
    border: none !important;
    color: var(--pm-text-primary) !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    width: 100% !important;
    outline: none !important;
    box-shadow: none !important;
}

.select-input-wrapper select {
    background: #ffffff !important;
    border: none !important;
    color: var(--pm-text-primary) !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    width: 100% !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer;
}

.file-extension {
    background: #f1f5f9;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--pm-text-secondary);
    border-left: 1px solid var(--pm-glass-border);
    user-select: none;
}

/* Elegant Primary Button */
.btn-merge {
    background: var(--pm-accent-gradient);
    color: #ffffff;
    border: none;
    border-radius: var(--pm-radius-sm);
    padding: 12px 28px;
    font-family: var(--pm-font-headings);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--pm-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(34, 113, 177, 0.25);
    min-width: 160px;
}

.btn-merge:hover {
    background: var(--pm-accent-hover-gradient);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 113, 177, 0.35);
}

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

.btn-merge:disabled {
    background: var(--pm-text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.6;
}

/* ==========================================================================
   Progress Section
   ========================================================================== */
.pdf-progress-container {
    margin-top: 35px;
    padding-top: 30px;
    border-top: 1px solid var(--pm-glass-border);
    animation: fadeIn 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--pm-text-secondary);
}

.progress-bar-bg {
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--pm-accent-gradient);
    border-radius: 4px;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 10px var(--pm-accent-primary);
}

/* ==========================================================================
   Result / Download Card
   ========================================================================== */
.pdf-result-card {
    margin-top: 35px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--pm-radius-md);
    padding: 24px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-icon {
    font-size: 32px;
    color: var(--pm-success);
    flex-shrink: 0;
    animation: pulseGlow 2s infinite;
}

.result-text {
    flex-grow: 1;
}

.result-text h3 {
    font-family: var(--pm-font-headings);
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #166534;
}

.result-text p {
    font-size: 13px;
    color: var(--pm-text-secondary);
    margin: 0;
}

.result-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.btn-download {
    background: var(--pm-success-gradient);
    color: #ffffff !important;
    text-decoration: none !important;
    border: none;
    border-radius: var(--pm-radius-sm);
    padding: 10px 20px;
    font-family: var(--pm-font-headings);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    transition: var(--pm-transition);
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-preview {
    background: #ffffff;
    color: var(--pm-text-primary);
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    padding: 10px 20px;
    font-family: var(--pm-font-headings);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--pm-transition);
}

.btn-preview:hover {
    background: var(--pm-glass-hover);
    border-color: var(--pm-accent-primary);
}

/* ==========================================================================
   Preview Modal
   ========================================================================== */
.pdf-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--pm-card-border);
    border-radius: var(--pm-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 1000px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    animation: modalSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--pm-card-border);
}

.modal-header h3 {
    font-family: var(--pm-font-headings);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--pm-text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--pm-text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: var(--pm-transition);
}

.modal-close:hover {
    color: var(--pm-text-primary);
}

.modal-body {
    flex-grow: 1;
    background: #f8fafc;
    padding: 0;
    position: relative;
}

.modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.96) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
    50% { text-shadow: 0 0 20px rgba(16, 185, 129, 0.6); }
}

/* ==========================================================================
   Media Queries & Responsiveness
   ========================================================================== */
@media (max-width: 600px) {
    .pdf-merger-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        gap: 16px;
    }
    
    .pdf-merger-body {
        padding: 20px;
    }
    
    .pdf-dropzone {
        padding: 30px 10px;
    }
    
    .pdf-file-item {
        padding: 10px 14px;
        gap: 10px;
    }
    
    .pdf-action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .output-settings {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .settings-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .filename-input-wrapper,
    .select-input-wrapper {
        max-width: 100%;
    }
    
    .btn-merge {
        width: 100%;
    }
    
    .pdf-result-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
    }
    
    .result-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-download, .btn-preview {
        width: 100%;
        justify-content: center;
    }
    
    .pdf-preview-modal {
        padding: 10px;
    }
}

/* ==========================================================================
   SVG Icons Support
   ========================================================================== */
.pm-icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    display: inline-block;
    vertical-align: middle;
}

.dropzone-icon {
    width: 48px;
    height: 48px;
}

.header-icon .pm-icon {
    width: 32px;
    height: 32px;
}

.btn-clear .pm-icon,
.btn-merge .pm-icon,
.btn-download .pm-icon,
.btn-preview .pm-icon {
    margin-right: 6px;
}

.file-remove .pm-icon {
    width: 14px;
    height: 14px;
}

.alert-icon {
    width: 18px;
    height: 18px;
    color: var(--pm-danger);
}

.result-icon .pm-icon {
    width: 36px;
    height: 36px;
}

.pm-spin {
    animation: pm-spin 1.2s infinite linear;
}

@keyframes pm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Page Level Customization Drawer & Controls
   ========================================================================== */
.btn-manage-pages {
    background: transparent !important;
    border: none !important;
    color: var(--pm-accent-primary) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    box-shadow: none !important;
    transition: var(--pm-transition);
}

.btn-manage-pages:hover {
    color: var(--pm-accent-secondary) !important;
    text-decoration: underline !important;
}

.btn-manage-pages svg {
    transition: transform 0.2s ease;
}

.btn-manage-pages.expanded svg {
    transform: rotate(180deg);
}

.pdf-pages-drawer {
    border-top: 1px dashed var(--pm-glass-border);
    padding: 20px;
    background: rgba(0, 0, 0, 0.01);
}

.pdf-pages-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.pdf-page-card {
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    user-select: none;
}

.page-card-inner {
    width: 80px;
    height: 110px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--pm-radius-sm);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.page-card-inner:hover {
    border-color: var(--pm-accent-primary);
    box-shadow: 0 4px 10px rgba(34, 113, 177, 0.15);
}

.page-card-inner:active {
    cursor: grabbing;
}

.page-drag-handle {
    position: absolute;
    top: 4px;
    left: 4px;
    color: var(--pm-text-muted);
    font-size: 10px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.page-drag-handle:hover {
    color: var(--pm-text-secondary);
}

.page-number-badge {
    font-size: 14px;
    font-weight: 700;
    color: var(--pm-text-primary);
    user-select: none;
    z-index: 2;
    background: rgba(255, 255, 255, 0.85);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-image-thumbnail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    opacity: 0.65;
    pointer-events: none;
}

.page-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.btn-page-rotate,
.btn-page-delete {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: var(--pm-text-secondary) !important;
    border-radius: var(--pm-radius-sm) !important;
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    box-shadow: none !important;
    transition: var(--pm-transition);
}

.btn-page-rotate:hover {
    color: var(--pm-accent-primary) !important;
    border-color: var(--pm-accent-primary) !important;
    background: rgba(34, 113, 177, 0.03) !important;
}

.btn-page-delete:hover {
    color: var(--pm-danger) !important;
    border-color: var(--pm-danger) !important;
    background: #fee2e2 !important;
}

.btn-page-rotate svg,
.btn-page-delete svg {
    width: 12px;
    height: 12px;
}

/* Page dragging state */
.page-sortable-ghost {
    opacity: 0.3;
    border-style: dashed;
}

/* ==========================================================================
   Interactive "Why Choose" Section
   ========================================================================== */
.pm-why-choose-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--pm-card-border);
    font-family: var(--pm-font-primary);
}

.pm-why-header {
    text-align: center;
    margin-bottom: 45px;
}

.pm-why-header h2 {
    font-family: var(--pm-font-headings);
    font-size: 28px;
    font-weight: 800;
    color: var(--pm-text-primary);
    margin: 0 0 10px 0;
    letter-spacing: -0.5px;
}

.pm-why-subtitle {
    font-size: 16px;
    font-weight: 600;
    color: var(--pm-accent-primary);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pm-why-intro {
    font-size: 15px;
    line-height: 1.6;
    color: var(--pm-text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* Responsive Grid */
.pm-why-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-top: 30px;
}

/* Grid Card */
.pm-feature-card {
    background: var(--pm-card-bg);
    border: 1px solid var(--pm-card-border);
    border-radius: var(--pm-radius-lg);
    padding: 35px;
    box-shadow: var(--pm-shadow-lg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 30px;
    transition: var(--pm-transition);
    position: relative;
    overflow: hidden;
}

.pm-feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--pm-glass-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.02);
}

.pm-feature-card.pm-full-width {
    grid-column: span 2;
    flex-direction: row;
    align-items: center;
}

.pm-feature-card.pm-full-width .pm-card-content {
    flex: 1 1 50%;
}

.pm-feature-card.pm-full-width .pm-card-widget {
    flex: 1 1 50%;
    margin-top: 0;
}

/* Badge styling */
.pm-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 20px;
    width: fit-content;
}

.pm-badge-icon {
    width: 14px;
    height: 14px;
}

.security-badge { background: rgba(34, 113, 177, 0.08); color: var(--pm-accent-primary); }
.free-badge { background: rgba(16, 185, 129, 0.08); color: var(--pm-success); }
.custom-badge { background: rgba(245, 158, 11, 0.08); color: var(--pm-warning); }
.format-badge { background: rgba(99, 102, 241, 0.08); color: #6366f1; }
.speed-badge { background: rgba(139, 92, 246, 0.08); color: #8b5cf6; }

.pm-feature-card h3 {
    font-family: var(--pm-font-headings);
    font-size: 18px;
    font-weight: 700;
    color: var(--pm-text-primary);
    margin: 0 0 20px 0;
    line-height: 1.4;
}

/* Feature Lists */
.pm-features-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pm-features-list > li {
    font-size: 14px;
    line-height: 1.6;
    color: var(--pm-text-secondary);
    position: relative;
    padding-left: 24px !important;
}

.pm-features-list > li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--pm-success);
    font-weight: 800;
    font-size: 15px;
}

.pm-features-list > li strong {
    color: var(--pm-text-primary);
    display: inline-block;
    margin-right: 4px;
}

.pm-sub-list {
    list-style: circle !important;
    padding-left: 20px !important;
    margin: 6px 0 0 0 !important;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-sub-list li {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--pm-text-secondary);
}

/* ==========================================================================
   Widget Area Styles
   ========================================================================== */
.pm-card-widget {
    background: #f8fafc;
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.pm-card-widget h4 {
    font-family: var(--pm-font-headings);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--pm-text-primary);
}

/* Widget 1: Privacy Flow */
.pm-privacy-widget {
    min-height: 250px;
    justify-content: space-between;
}

.pm-privacy-widget .widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}



/* Widget 2: Watermark Slider */
.watermark-comparison-container {
    width: 100%;
    height: 160px;
    background: #ffffff;
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    position: relative;
    overflow: hidden;
    box-shadow: var(--pm-shadow-sm);
    user-select: none;
}

.watermark-side {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.watermark-side.before-side {
    z-index: 1;
}

.watermark-side.after-side {
    z-index: 2;
    width: 50%; /* Controlled by script */
    border-right: 1px solid transparent; /* Just helper, handle acts as border */
    overflow: hidden;
}

.pdf-mock-page {
    width: 200px;
    height: 130px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Ensure mock-pages stay aligned absolutely */
.before-side .pdf-mock-page { z-index: 10; }
.after-side .pdf-mock-page { z-index: 20; width: 200px; } /* Must fix width so content doesn't scale with wrapper */

.mock-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mock-lines .line {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
}

.mock-lines .line.title {
    width: 60px;
    height: 10px;
    background: #94a3b8;
    margin-bottom: 8px;
}

.mock-lines .line.long { width: 100%; }
.mock-lines .line.short { width: 70%; }

.watermark-overlay {
    position: absolute;
    inset: 0;
    background: rgba(239, 68, 68, 0.03);
    color: rgba(239, 68, 68, 0.25);
    font-size: 9px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transform: rotate(-15deg);
    pointer-events: none;
    letter-spacing: 0.5px;
    padding: 10px;
    border: 2px dashed rgba(239, 68, 68, 0.15);
    border-radius: 4px;
    margin: 4px;
}

.clean-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #065f46;
    font-size: 8px;
    font-weight: 700;
    padding: 4px;
    text-align: center;
    border-radius: 4px;
}

.watermark-slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%; /* Controlled by script */
    width: 2px;
    background: var(--pm-accent-primary);
    z-index: 30;
    cursor: ew-resize;
}

.watermark-slider-handle .handle-bar {
    position: absolute;
    inset: 0;
}

.watermark-slider-handle .handle-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--pm-accent-primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(34, 113, 177, 0.35);
    transition: background 0.2s ease, transform 0.2s ease;
    border: 2px solid #ffffff;
}

.watermark-slider-handle:hover .handle-button {
    background: var(--pm-accent-secondary);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Widget 3: Rotation Sandbox */
.rotator-sandbox {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.sandbox-page {
    width: 100px;
    height: 140px;
    background: #ffffff;
    border: 1.5px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    box-shadow: var(--pm-shadow-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease, border-color 0.2s ease;
}

.sandbox-page:hover {
    border-color: var(--pm-accent-primary);
}

.sandbox-page .page-num {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--pm-text-muted);
}

.page-content-mock {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.page-content-mock .mock-arrow {
    font-size: 20px;
    transition: transform 0.4s ease;
}

.page-content-mock .mock-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--pm-text-secondary);
}

.page-actions {
    display: flex;
    justify-content: center;
}

.page-actions .action-btn {
    border: 1px solid var(--pm-glass-border);
    background: #ffffff;
    font-size: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    transition: var(--pm-transition);
}

.action-btn.btn-rotate:hover {
    border-color: var(--pm-accent-primary);
    background: rgba(34, 113, 177, 0.05);
    transform: rotate(45deg);
}

.action-btn.btn-delete:hover {
    border-color: var(--pm-danger);
    background: #fee2e2;
}

.pm-reset-btn {
    align-self: center;
    border: 1px solid var(--pm-glass-border);
    background: #ffffff;
    color: var(--pm-text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--pm-radius-sm);
    cursor: pointer;
    box-shadow: none !important;
    transition: var(--pm-transition);
}

.pm-reset-btn:hover {
    border-color: var(--pm-accent-primary);
    color: var(--pm-accent-primary);
}

/* Widget 4: Alignment Demonstrator */
.alignment-controls {
    display: flex;
    background: #ffffff;
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    overflow: hidden;
}

.align-btn {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pm-text-secondary);
    cursor: pointer;
    box-shadow: none !important;
    transition: var(--pm-transition);
}

.align-btn:not(:last-child) {
    border-right: 1px solid var(--pm-glass-border);
}

.align-btn.active {
    background: var(--pm-accent-primary);
    color: #ffffff;
}

.alignment-preview-box {
    height: 120px;
    background: #ffffff;
    border: 1px solid var(--pm-glass-border);
    border-radius: var(--pm-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px;
    overflow: hidden;
    position: relative;
}

.preview-page {
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: 3px;
    box-shadow: var(--pm-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), height 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
    height: 100px;
    position: relative;
}

.preview-page .preview-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--pm-text-secondary);
    white-space: nowrap;
    text-align: center;
}

/* Initial "Original" sizing states */
.preview-page.first-page { width: 70px; height: 90px; border-color: var(--pm-accent-primary); }
.preview-page.wide-page { width: 110px; height: 65px; }
.preview-page.narrow-page { width: 60px; height: 85px; }

/* "Match First Page" states */
.alignment-preview-box.state-match .preview-page {
    width: 70px; /* Match width of page 1 */
}
.alignment-preview-box.state-match .preview-page.first-page { height: 90px; }
.alignment-preview-box.state-match .preview-page.wide-page { height: 42px; } /* Proportional scaling */
.alignment-preview-box.state-match .preview-page.narrow-page { height: 99px; }

/* "Normalize A4" states */
.alignment-preview-box.state-normalize .preview-page {
    width: 70px;
    height: 98px; /* A4 aspect ratio scaled down */
}

.alignment-caption {
    font-size: 11px;
    line-height: 1.4;
    color: var(--pm-text-secondary);
    text-align: center;
    background: #ffffff;
    padding: 8px;
    border-radius: var(--pm-radius-sm);
    border: 1px solid var(--pm-glass-border);
}

/* Widget 5: Speed battle */
.pm-speed-widget {
    min-height: 200px;
    justify-content: space-between;
}

.pm-speed-widget .widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.pm-run-speed-btn {
    background: var(--pm-accent-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--pm-radius-sm);
    padding: 8px 16px;
    font-family: var(--pm-font-headings);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(34, 113, 177, 0.2);
    transition: var(--pm-transition);
}

.pm-run-speed-btn:hover {
    background: var(--pm-accent-secondary);
    transform: translateY(-1px);
}

.pm-run-speed-btn:active {
    transform: translateY(0);
}

.speed-bars-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 10px 0;
}

.speed-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.speed-row .bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--pm-text-secondary);
}

.speed-row .tool-name {
    color: var(--pm-text-primary);
}

.speed-row .time-label {
    font-weight: 700;
}

.speed-row .bar-track {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.speed-row .bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: none; /* Controlled manually by animation scripts */
}

.bar-fill.fill-local {
    background: var(--pm-success-gradient);
}

.bar-fill.fill-cloud {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.cloud-status-indicator {
    position: absolute;
    right: 0;
    top: -16px;
    font-size: 9px;
    font-weight: 700;
    color: var(--pm-warning);
    text-transform: uppercase;
}

/* ==========================================================================
   Media Queries for the Interactive Section
   ========================================================================== */
@media (max-width: 820px) {
    .pm-feature-card.pm-full-width {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pm-feature-card.pm-full-width .pm-card-content,
    .pm-feature-card.pm-full-width .pm-card-widget {
        flex: 1 1 auto;
    }
}

@media (max-width: 680px) {
    .pm-why-grid {
        grid-template-columns: 1fr;
    }
    
    .pm-feature-card.pm-full-width {
        grid-column: span 1;
    }
    
    .pm-why-header h2 {
        font-size: 24px;
    }
    
    .pm-why-subtitle {
        font-size: 14px;
    }
    
    .pm-why-intro {
        font-size: 14px;
    }
}

/* Full-screen Drag Overlay */
.pdf-page-drag-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pdf-page-drag-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.pdf-page-drag-overlay .overlay-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
    border: 3px dashed rgba(255, 255, 255, 0.3);
    border-radius: var(--pm-radius-lg);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pdf-page-drag-overlay.active .overlay-content {
    transform: scale(1);
    border-color: var(--pm-accent-primary);
}

.overlay-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 24px;
    color: var(--pm-accent-primary);
}

.pdf-page-drag-overlay h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.pdf-page-drag-overlay p {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Inline Image Optimization Selector */
.image-optimize-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.optimize-label {
    color: var(--pm-text-secondary);
    font-weight: 500;
}

.image-optimize-select {
    background: #ffffff !important;
    border: 1px solid var(--pm-glass-border) !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    padding: 2px 6px !important;
    color: var(--pm-text-primary) !important;
    cursor: pointer !important;
    outline: none !important;
    transition: var(--pm-transition);
}

.image-optimize-select:hover {
    border-color: var(--pm-accent-primary) !important;
}

.image-optimize-select:focus {
    border-color: var(--pm-accent-primary) !important;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15) !important;
}


