/* ==================== GLOBAL STYLES ==================== */

:root {
    --primary-color: #3b82f6;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== APP CONTAINER ==================== */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== HEADER ==================== */

.app-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 2rem 1rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* ==================== MAIN CONTENT ==================== */

.main-content {
    flex: 1;
    padding: 2rem 1rem;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==================== UPLOAD SECTION ==================== */

.upload-section {
    background: var(--bg-primary);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.drop-zone {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    cursor: pointer;
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    transition: var(--transition);
    background: var(--bg-secondary);
    margin: 1.5rem;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.02);
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.drop-zone h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.browse-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    transition: var(--transition);
    padding: 0;
}

.browse-btn:hover {
    color: var(--primary-dark);
    text-decoration-thickness: 2px;
}

.browse-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

.drop-zone small {
    display: block;
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.file-input {
    display: none;
}

.upload-progress {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    width: 0%;
    transition: width 0.3s ease;
}

.upload-progress p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ==================== FILES SECTION ==================== */

.files-section {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.files-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.file-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
}

.files-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.files-list::-webkit-scrollbar {
    width: 6px;
}

.files-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.files-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.files-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
    padding: 2rem 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    cursor: move;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.file-item:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.file-item.drag-disabled {
    cursor: default;
    opacity: 0.5;
    pointer-events: none;
}

.file-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.file-index {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.file-thumbnail {
    width: 60px;
    height: 80px;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.75rem;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

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

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

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    margin-bottom: 0.25rem;
}

.file-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.file-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.file-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.05);
}

.file-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.file-btn.preview-btn:hover {
    background: var(--primary-light);
}

.file-btn.remove-btn:hover {
    color: var(--error-color);
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.file-btn svg {
    width: 16px;
    height: 16px;
}

/* ==================== ACTION BUTTONS ==================== */

.action-buttons {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:not(:disabled):active {
    transform: translateY(0);
}

.btn-primary:focus {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:not(:disabled):hover {
    border-color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.btn-secondary:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success:focus {
    outline: 2px solid #059669;
    outline-offset: 2px;
}

.btn svg {
    width: 20px;
    height: 20px;
}

/* ==================== RIGHT PANEL ==================== */

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-section,
.download-section {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-section h3,
.download-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-align: center;
}

.preview-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 0.9rem;
}

.preview-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-file-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    flex: 1;
}

.preview-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preview-close-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.preview-close-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.preview-canvas {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    overflow: auto;
    min-height: 300px;
}

.preview-canvas canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    object-fit: contain;
}

.preview-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.preview-page-indicator {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 80px;
    text-align: center;
}

.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    min-height: 400px;
    position: relative;
    overflow: auto;
}

.preview-container canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
}

/* ==================== DOWNLOAD SECTION ==================== */

.download-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border-left: 4px solid var(--success-color);
}

.download-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.download-info p strong {
    color: var(--text-primary);
}

.download-controls {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

.download-name-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
}

.download-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ==================== MODAL ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.modal-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-action-btn:hover {
    color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.1);
}

.modal-action-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.modal-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.page-indicator {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 80px;
    text-align: center;
}

/* ==================== LOADING SPINNER ==================== */

.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-content p {
    color: white;
    font-size: 1rem;
    font-weight: 500;
}

/* ==================== TOAST NOTIFICATIONS ==================== */

.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1.5rem 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 1rem;
    }

    .content-wrapper {
        gap: 1rem;
    }

    .drop-zone {
        min-height: 150px;
        padding: 1.5rem;
    }

    .upload-icon {
        width: 36px;
        height: 36px;
    }

    .drop-zone h2 {
        font-size: 1rem;
    }

    .file-item {
        flex-wrap: wrap;
    }

    .file-thumbnail {
        width: 50px;
        height: 70px;
    }

    .file-meta {
        gap: 0.75rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        max-height: 95dvh;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-wrap: wrap;
    }

    .preview-container {
        min-height: 300px;
    }

    .preview-container canvas {
        max-height: 300px;
    }

    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    .download-name-input {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.8rem;
    }

    .main-content {
        padding: 0.75rem;
    }

    .files-section,
    .upload-section,
    .preview-section,
    .download-section {
        padding: 1rem;
    }

    .drop-zone {
        margin: 1rem;
    }

    .file-item {
        padding: 0.75rem;
    }

    .file-index {
        width: 28px;
        height: 28px;
    }

    .file-thumbnail {
        width: 40px;
        height: 60px;
    }

    .file-actions {
        gap: 0.25rem;
    }

    .file-btn {
        width: 28px;
        height: 28px;
    }

    .file-btn svg {
        width: 14px;
        height: 14px;
    }

    .file-meta {
        gap: 0.5rem;
    }

    .file-name {
        font-size: 0.85rem;
    }

    .file-meta {
        font-size: 0.7rem;
    }

    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .modal-content {
        border-radius: 0.75rem;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .page-indicator {
        min-width: 60px;
        font-size: 0.85rem;
    }

    .download-controls {
        gap: 0.5rem;
    }

    .download-name-input {
        font-size: 16px;
        padding: 0.65rem 0.75rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* ==================== FOOTER STYLES ==================== */

.app-footer {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #9ca3af;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    line-height: 1.6;
}

.app-footer p {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    body {
        background: white;
    }

    .app-header,
    .action-buttons,
    .modal,
    .loading-spinner,
    .toast-container {
        display: none;
    }
}
