:root {
    /* Theme Variables */
    --bg-primary: #f5f7fb;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary: #f97316; /* Amber/Orange theme for Merge to differentiate */
    --primary-light: #ffedd5;
    --primary-dark: #ea580c;
    --accent: #d97706;
    --border: #e2e8f0;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0b0f19;
    --bg-card: #151d30;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #f97316;
    --primary-light: #2c2117;
    --primary-dark: #ea580c;
    --accent: #f59e0b;
    --border: #1e293b;
    --shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

header {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.theme-toggle {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.6rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    color: var(--text-primary);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }

/* Ad rails layout */
.ad-rail-left, .ad-rail-right {
    display: none;
    position: fixed;
    top: 140px;
    width: 160px;
    height: 600px;
    z-index: 99;
}
.ad-rail-left { left: calc(50% - 700px - 180px); }
.ad-rail-right { right: calc(50% - 700px - 180px); }
@media (min-width: 1720px) {
    .ad-rail-left, .ad-rail-right { display: block; }
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem 3rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.ad-container::before {
    content: 'ADVERTISEMENT';
    font-size: 0.6rem;
    color: var(--text-secondary);
    position: absolute;
    top: 2px;
    letter-spacing: 0.1em;
}

.ad-top { padding-top: 15px; min-height: 105px; width: 100%; }
.ad-bottom { padding-top: 15px; min-height: 105px; margin-top: 2rem; width: 100%; }

/* Grid Layout */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 992px) {
    .layout-grid {
        grid-template-columns: 380px 1fr;
    }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
}

.card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Page Header styling */
.page-header-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0;
}
.page-header {
    display: flex; align-items: flex-start; gap: 1.25rem;
    padding: 1.5rem 0 0.5rem;
}
.page-header h1 { 
    margin-bottom: 0.25rem; 
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
}
.page-header .subtitle {
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.alert-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: var(--text-primary);
}
.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: var(--text-primary);
}

/* Dropzone Styles */
.dropzone {
    border: 2.5px dashed var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(249, 115, 22, 0.03);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.08);
}

.dropzone-icon {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
    transition: var(--transition);
    opacity: 0.8;
}

.dropzone:hover .dropzone-icon {
    transform: translateY(-5px) scale(1.05);
    color: var(--primary);
    opacity: 1;
}

.dropzone h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.file-input {
    display: none;
}

/* File Queue Styles */
.file-queue {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.file-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.file-item.dragging {
    opacity: 0.5;
    border-style: dashed;
    border-color: var(--primary);
}

.file-item.drag-over {
    border: 1px dashed var(--primary);
    background: var(--primary-light);
}

.file-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 0.25rem;
}
.drag-handle:active {
    cursor: grabbing;
}

.file-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.15rem;
}

.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-pdf { background: #fee2e2; color: #ef4444; }
.badge-image { background: #e0e7ff; color: #6366f1; }
.badge-docx { background: #e0f2fe; color: #0284c7; }
.badge-locked { background: var(--warning-light); color: var(--warning); display: flex; align-items: center; gap: 4px; }
.badge-unlocked { background: var(--success-light); color: var(--success); display: flex; align-items: center; gap: 4px; }

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Password unlock inline prompt */
.password-prompt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.25rem;
}

.password-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
}
.password-input:focus {
    border-color: var(--primary);
}

.btn-unlock {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-unlock:hover {
    background: var(--primary-dark);
}

/* PDF Page Selector panel */
.page-selector-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    transition: var(--transition);
}

.page-selector-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-selector-panel {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.page-range-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.page-range-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}
.page-range-input:focus {
    border-color: var(--primary);
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.75rem;
    max-height: 250px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.thumbnail-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.thumbnail-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1.414; /* A4 Ratio */
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.thumbnail-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.thumbnail-placeholder svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    animation: pulse 1.5s infinite;
}

.thumbnail-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    z-index: 2;
    pointer-events: none;
    opacity: 0.8;
}

.thumbnail-card:hover .thumbnail-wrapper {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.thumbnail-card:hover .thumbnail-overlay {
    opacity: 1;
}

.thumbnail-card.selected .thumbnail-wrapper {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.thumbnail-card.selected .thumbnail-overlay {
    opacity: 0;
}

.thumbnail-card.selected .thumbnail-checkbox {
    opacity: 1;
}

.thumbnail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.thumbnail-card.selected .thumbnail-label {
    color: var(--primary);
}

/* Page controls panel */
.options-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.options-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.select-control {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}
.select-control:focus {
    border-color: var(--primary);
}

.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.toggle-option {
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    text-align: center;
}

.toggle-option.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Buttons and Loader */
.btn-merge {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 1rem;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-merge:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}

.btn-merge:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.progress-container {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-track {
    height: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

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

.empty-queue-msg {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.empty-queue-msg svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* SEO content */
.seo-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-top: 1.5rem;
}
.seo-section h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}
.seo-section ol, .seo-section ul {
    padding-left: 1.25rem;
    margin-bottom: 1rem;
}
.seo-section li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.seo-section p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.seo-section p:last-child {
    margin-bottom: 0;
}

/* Footer layout */
footer {
    border-top: 1px solid var(--border);
    padding: 2.5rem 2rem;
    margin-top: 2rem;
    background: var(--bg-card);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.current-time-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

[data-theme="light"] .current-time-badge {
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 8px;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .footer-info {
        flex-direction: column;
        gap: 8px;
    }
}

