/* Image to PDF Converter - Modern Clean UI */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
}

/* Upload Section */
.upload-section {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.upload-area {
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: 20px;
    padding: 3rem 4rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 500px;
    width: 100%;
}

.upload-area:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    transform: translateY(-2px);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    transform: scale(1.02);
}

.upload-area.drag-over * {
    color: white !important;
}

.upload-icon-wrapper {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: white;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.upload-area h3 {
    color: var(--gray-800);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--gray-500);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.upload-formats {
    display: inline-block;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
}

/* Workspace */
.workspace {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px);
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    gap: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-count {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
}

.page-count i {
    color: var(--primary);
    margin-right: 0.25rem;
}

.btn-add {
    width: 32px;
    height: 32px;
    border: 2px dashed var(--gray-300);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--gray-50);
}

.nav-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 0.85rem;
    color: var(--gray-600);
    min-width: 50px;
    text-align: center;
}

.btn-settings {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-settings:hover,
.btn-settings.active {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-download {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-download:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Settings Dropdown */
.settings-dropdown {
    display: none;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem;
    gap: 1.5rem;
    flex-wrap: wrap;
    animation: slideDown 0.2s ease;
}

.settings-dropdown.show {
    display: flex;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-item label {
    font-size: 0.8rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.settings-item label i {
    color: var(--primary);
}

.settings-item select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-item select:hover,
.settings-item select:focus {
    border-color: var(--primary);
    outline: none;
}

/* Main Area */
.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Thumbnails Sidebar */
.thumbnails-sidebar {
    width: 100px;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
    max-height: calc(100vh - 200px);
}

.thumbnails-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.thumb-item {
    position: relative;
    background: white;
    border-radius: 6px;
    padding: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.thumb-item:hover {
    border-color: var(--gray-300);
}

.thumb-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.thumb-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.thumb-img {
    width: 100%;
    height: 70px;
    object-fit: contain;
    border-radius: 3px;
    background: var(--gray-100);
    display: block;
}

.thumb-number {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 18px;
    height: 18px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    position: relative;
    overflow: hidden;
}

.preview-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: auto;
}

.preview-page {
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    max-width: 500px;
    height: auto;
    max-height: 500px;
    aspect-ratio: 1;
    padding: 1rem;
}

.preview-page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 2px;
}

.preview-empty {
    color: var(--gray-400);
    font-size: 0.95rem;
    padding: 3rem;
}

/* Quick Edit Bar */
.quick-edit-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-top: 1px solid var(--gray-200);
}

.edit-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: 10px;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.edit-btn:hover {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.edit-btn:last-child {
    color: var(--danger);
}

.edit-btn:last-child:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

.edit-divider {
    width: 1px;
    height: 24px;
    background: var(--gray-200);
    margin: 0 0.25rem;
}

/* Crop Modal */
.crop-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.crop-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.crop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.crop-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crop-header h4 i {
    color: var(--primary);
}

.crop-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.crop-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.crop-canvas-wrapper {
    position: relative;
    background: var(--gray-900);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: 60vh;
    overflow: hidden;
}

#cropCanvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--primary);
    background: rgba(99, 102, 241, 0.1);
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.crop-handle.tl { top: -8px; left: -8px; cursor: nw-resize; }
.crop-handle.tr { top: -8px; right: -8px; cursor: ne-resize; }
.crop-handle.bl { bottom: -8px; left: -8px; cursor: sw-resize; }
.crop-handle.br { bottom: -8px; right: -8px; cursor: se-resize; }

.crop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
}

.btn-cancel {
    padding: 0.6rem 1.25rem;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 8px;
    color: var(--gray-600);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--gray-50);
}

.btn-apply {
    padding: 0.6rem 1.25rem;
    border: none;
    background: var(--primary);
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-apply:hover {
    background: var(--primary-dark);
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 0.85rem;
    z-index: 99999;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow);
    max-width: 300px;
    line-height: 1.3;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: #f59e0b; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 900px) {
    .thumbnails-sidebar {
        width: 100px;
    }
}

@media (max-width: 768px) {
    .upload-area {
        padding: 2rem;
    }
    
    .upload-icon-wrapper {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .upload-area h3 {
        font-size: 1.25rem;
    }
    
    .top-bar {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .top-bar-left {
        order: 1;
    }
    
    .top-bar-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .top-bar-right {
        order: 2;
    }
    
    .btn-download span {
        display: none;
    }
    
    .btn-download {
        padding: 0.6rem 0.8rem;
    }
    
    .main-area {
        flex-direction: column;
    }
    
    .thumbnails-sidebar {
        width: 100%;
        height: auto;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .thumbnails-list {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    .thumb-item {
        flex-shrink: 0;
        width: 70px;
    }
    
    .preview-wrapper {
        padding: 1rem;
    }
    
    .quick-edit-bar {
        flex-wrap: wrap;
    }
    
    .edit-btn {
        width: 36px;
        height: 36px;
    }
    
    .settings-dropdown {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .settings-item {
        width: 100%;
        justify-content: space-between;
    }
    
    .settings-item select {
        flex: 1;
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .upload-section {
        min-height: 50vh;
        padding: 1rem;
    }
    
    .page-count {
        font-size: 0.8rem;
    }
    
    .thumb-item {
        width: 60px;
    }
    
    .crop-modal-content {
        border-radius: 12px;
    }
    
    .crop-canvas-wrapper {
        padding: 1rem;
        min-height: 200px;
    }
}
