/* Professional PDF Editor Styling */

@keyframes blob {
    0% {
        transform: translate(0px, 0px) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.animate-blob {
    animation: blob 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

.animate-slide-down {
    animation: slide-down 0.3s ease-out;
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

.animate-scale-in {
    animation: scale-in 0.2s ease-out;
}

/* Professional Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Dark scrollbar for sidebar */
aside::-webkit-scrollbar-track {
    background: #1f1f1f;
}

aside::-webkit-scrollbar-thumb {
    background: #4a4a4a;
}

aside::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Tool Link Active State */
.tool-link.active {
    background-color: #3b3b3b;
    color: white;
}

.tool-link.active svg {
    color: #818cf8;
}

.tool-link.active span {
    color: white;
}

/* Tool Tab Active State */
.tool-tab.active {
    color: #4f46e5 !important;
    border-bottom-color: #4f46e5 !important;
    background-color: rgba(99, 102, 241, 0.05);
    font-weight: 700;
}

.tool-tab.active:hover {
    color: #4338ca !important;
    border-bottom-color: #4338ca !important;
}

/* Hide scrollbar utility */
.scrollbar-hide {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

/* Smooth horizontal scrolling for mobile */
@media (max-width: 768px) {
    .tool-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    /* Ensure tabs container has smooth scrolling */
    .tool-tab-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Add padding to first and last tab for better mobile UX */
    .tool-tab:first-child {
        padding-left: 1rem;
    }
    
    .tool-tab:last-child {
        padding-right: 1rem;
    }
}

/* PDF Thumbnail Styling */
.pdf-thumbnail {
    position: relative;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.pdf-thumbnail:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.pdf-thumbnail.selected {
    border: 3px solid #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.pdf-thumbnail canvas,
.pdf-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px 8px 0 0;
}

/* Selection Overlay */
.selection-overlay {
    position: absolute;
    inset: 0;
    background: rgba(79, 70, 229, 0.2);
    border: 3px solid #4f46e5;
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
}

.selection-overlay.hidden {
    display: none;
}

/* File Item in Sidebar */
.file-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
    cursor: move;
}

.file-item:hover {
    border-color: #4f46e5;
    background: #f5f3ff;
    transform: translateX(4px);
}

.file-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

/* Page Badge */
.page-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* File Info Badge */
.file-info-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(79, 70, 229, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    backdrop-filter: blur(4px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dropzone States */
#dropzone-box.drag-over {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    transform: scale(1.02);
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Button Hover Effects */
button:not(:disabled):hover {
    transform: translateY(-1px);
}

button:not(:disabled):active {
    transform: translateY(0);
}

/* Professional Input Styling */
input[type="radio"]:checked {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

/* Tool Panel Transitions */
.tool-panel {
    animation: fade-in 0.3s ease-out;
}

/* PDF Grid Item Animations */
#pdf-grid > div {
    animation: scale-in 0.3s ease-out;
}

/* Processing Overlay */
#sidebar-processing {
    backdrop-filter: blur(8px);
}

/* File Count Badge Animation */
#file-count-badge {
    animation: scale-in 0.2s ease-out;
}

/* Professional Shadows */
.shadow-professional {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-professional-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Hide Scrollbar but Keep Functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Professional Card Hover */
.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Status Indicators */
.status-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.status-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.status-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Professional Focus States */
*:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Smooth Transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* PDF Viewer Canvas */
#pdf-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Mobile-Specific Styles */

/* Touch-Friendly Targets */
@media (max-width: 768px) {
    button, a, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve touch feedback */
    button:active, a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    /* Tool links in sidebar - larger touch targets */
    .tool-link {
        min-height: 48px !important;
        padding: 12px 16px !important;
    }
    
    /* File input improvements for mobile */
    input[type="file"] {
        font-size: 16px !important;
        width: 100% !important;
    }
    
    /* Ensure file input is accessible on mobile */
    #fileInput {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        overflow: hidden;
    }
    
    /* Better spacing for empty state on mobile */
    #dropzone-box {
        padding: 2rem 1rem !important;
    }
    
    /* Improve button spacing on mobile */
    #dropzone-box button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Touch manipulation for better mobile performance */
    .touch-manipulation {
        touch-action: manipulation;
    }
    
    /* Prevent double-tap zoom on buttons */
    button, a, .tool-link {
        touch-action: manipulation;
    }
    
    /* PDF Grid Responsive */
    #pdf-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    /* Mobile Sidebar Styles */
    #mobile-sidebar {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile Menu Button */
    #mobile-menu-btn {
        touch-action: manipulation;
    }
    
    /* Tool Panel Mobile Styles */
    .tool-panel {
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Improve text readability on mobile */
    body {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Better spacing for mobile */
    .file-item {
        padding: 16px;
        margin-bottom: 12px;
    }
    
    /* PDF Thumbnail Mobile */
    .pdf-thumbnail {
        touch-action: manipulation;
    }
    
    .pdf-thumbnail:active {
        transform: scale(0.98);
    }
    
    /* Header adjustments */
    header {
        position: sticky;
        top: 0;
        z-index: 30;
    }
    
    /* Camera Modal Mobile */
    #camera-modal > div {
        max-height: 95vh;
        margin: 0.5rem;
    }
    
    /* Prevent text selection on buttons */
    button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Tablet Adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    #pdf-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Mobile Sidebar Animation */
#mobile-sidebar {
    will-change: transform;
}

/* Safe Area Insets for Notched Devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Mobile Overlay */
#mobile-overlay {
    transition: opacity 0.3s ease-in-out;
}

/* Camera Preview Mobile Optimizations */
@media (max-width: 768px) {
    #camera-preview, #captured-image {
        max-height: 50vh;
    }
    
    #camera-modal .flex {
        flex-direction: column;
    }
    
    #camera-modal button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Improve scrolling on mobile */
@media (max-width: 768px) {
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent pull-to-refresh on workspace */
    #workspace-area {
        overscroll-behavior: contain;
    }
}

/* Touch-friendly form inputs */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 12px;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #pdf-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
}

/* Print Styles */
@media print {
    aside,
    header,
    #action-btn,
    .tool-panel {
        display: none !important;
    }
}
