/* Custom Styles for PDF Constructor */

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

/* Mobile-First Responsive Design */
.container-fluid {
    padding-left: 8px;
    padding-right: 8px;
}

@media (min-width: 768px) {
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Header Styling */
.navbar-brand {
    font-weight: bold;
    font-size: 1.2rem;
}

@media (min-width: 768px) {
    .navbar-brand {
        font-size: 1.5rem;
    }
}

/* Mobile-Friendly Toast Container */
.toast-container {
    top: 60px !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-width: none !important;
}

@media (min-width: 768px) {
    .toast-container {
        top: 20px !important;
        right: 20px !important;
        left: auto !important;
        width: 350px !important;
        max-width: 350px !important;
    }
}

/* Improved Toast Styles */
.toast {
    margin-bottom: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: none;
    min-width: 280px;
}

@media (max-width: 767px) {
    .toast {
        min-width: auto;
        width: 100%;
    }
}

.toast-header {
    border-bottom: none;
    padding: 12px 16px 8px;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
}

.toast-body {
    padding: 8px 16px 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Success Toast */
.toast.bg-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

/* Error Toast */
.toast.bg-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%) !important;
}

/* Warning Toast */
.toast.bg-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
}

/* Info Toast */
.toast.bg-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%) !important;
}

/* Card Styling */
.card {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 12px;
    margin-bottom: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 768px) {
    .card {
        margin-bottom: 20px;
    }
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
    padding: 12px 16px;
    font-size: 0.95rem;
}

@media (min-width: 768px) {
    .card-header {
        padding: 16px 20px;
        font-size: 1rem;
    }
}

/* Action Cards */
.action-card {
    border-left: 4px solid;
    overflow: hidden;
}

.remove-card { 
    border-left-color: #dc3545; 
    background: linear-gradient(135deg, #fff 0%, #ffebee 100%);
}

.edit-card { 
    border-left-color: #17a2b8; 
    background: linear-gradient(135deg, #fff 0%, #e0f7fa 100%);
}

.download-card { 
    border-left-color: #28a745; 
    background: linear-gradient(135deg, #fff 0%, #e8f5e8 100%);
}

.action-card .card-header {
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.action-card .btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.action-card .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Main Viewer Card */
.main-viewer {
    min-height: 500px;
}

@media (min-width: 768px) {
    .main-viewer {
        min-height: 600px;
    }
}

/* PDF Preview Area */
#pdfPreview {
    min-height: 400px;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 10px;
    overflow: auto;
    max-height: 60vh;
}

@media (min-width: 768px) {
    #pdfPreview {
        min-height: 600px;
        padding: 20px;
        max-height: 80vh;
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 500px;
    border: 4px dashed #007bff;
    border-radius: 24px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e3f2fd 100%);
    text-align: center;
    padding: 40px 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.empty-state::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.08) 0%, transparent 70%);
    animation: pulse-bg 4s ease-in-out infinite;
}

@keyframes pulse-bg {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.5; }
    50% { transform: scale(1.1) rotate(180deg); opacity: 0.8; }
}

.empty-state.drag-over {
    border-color: #28a745;
    border-width: 6px;
    background: linear-gradient(135deg, #f8fff8 0%, #d4edda 100%);
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(40, 167, 69, 0.3);
}

.upload-icon-container {
    position: relative;
    z-index: 2;
    margin-bottom: 20px;
}

.upload-icon {
    position: relative;
    z-index: 3;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.upload-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    z-index: 1;
}

.upload-circle {
    position: absolute;
    border: 2px solid rgba(0, 123, 255, 0.2);
    border-radius: 50%;
    animation: ripple 2s linear infinite;
}

.upload-circle:nth-child(1) {
    width: 80px;
    height: 80px;
    top: 20px;
    left: 20px;
    animation-delay: 0s;
}

.upload-circle:nth-child(2) {
    width: 100px;
    height: 100px;
    top: 10px;
    left: 10px;
    animation-delay: 0.5s;
}

.upload-circle:nth-child(3) {
    width: 120px;
    height: 120px;
    top: 0;
    left: 0;
    animation-delay: 1s;
}

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Big Upload Button */
.btn-upload-large {
    font-size: 1.5rem !important;
    padding: 20px 40px !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    min-width: 280px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
    border: none !important;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease !important;
    z-index: 2;
}

.btn-upload-large::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-upload-large:hover::before {
    left: 100%;
}

.btn-upload-large:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 15px 40px rgba(0, 123, 255, 0.4) !important;
}

.btn-upload-large:active {
    transform: translateY(-1px) scale(1.02) !important;
}

.btn-upload-large i {
    font-size: 1.8rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Upload Features */
.upload-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    z-index: 2;
    position: relative;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.feature-item i {
    font-size: 1.1rem;
}

@media (max-width: 767px) {
    .empty-state {
        height: 400px;
        padding: 30px 15px;
        border-radius: 16px;
    }
    
    .btn-upload-large {
        font-size: 1.2rem !important;
        padding: 16px 32px !important;
        min-width: 240px;
    }
    
    .upload-features {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .upload-icon i {
        font-size: 4rem !important;
    }
}

/* PDF Canvas Styling */
.pdf-page {
    margin: 10px auto;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    position: relative;
    background: white;
}

.pdf-page canvas {
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.page-number {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* PDF Pages Grid Layout - Mobile First */
.pdf-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    padding: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

@media (min-width: 576px) {
    .pdf-pages-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 18px;
        padding: 15px;
    }
}

@media (min-width: 768px) {
    .pdf-pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
        padding: 20px;
        max-height: 70vh;
    }
}

.pdf-page {
    position: relative;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .pdf-page {
        padding: 10px;
    }
}

.pdf-page:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
}

.pdf-page:hover:not(.dragging) {
    animation: subtle-pulse 2s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% { transform: translateY(-5px) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); }
}

.pdf-page.selected {
    border-color: #007bff;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.3);
    transform: translateY(-2px);
}

.pdf-page.selected::before {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4);
    border: 3px solid white;
    animation: checkmark-appear 0.3s ease-out;
}

@keyframes checkmark-appear {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.pdf-page.selected-for-removal {
    border-color: #dc3545;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.3);
    transform: translateY(-2px);
}

.pdf-page.selected-for-removal::before {
    content: '✗';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    border: 3px solid white;
    animation: checkmark-appear 0.3s ease-out;
}

/* Drag and Drop Styling - Mobile Friendly */
.pdf-page[draggable="true"] {
    cursor: grab;
    position: relative;
    touch-action: none; /* Better mobile support */
}

.pdf-page[draggable="true"]:active {
    cursor: grabbing;
}

/* Hover tooltip - responsive for mobile */
.pdf-page[draggable="true"]:hover::before {
    content: "🖱️ Click & Drag to Move";
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.6rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

@media (max-width: 767px) {
    .pdf-page[draggable="true"]:hover::before {
        content: "👆 Drag to Move";
        font-size: 0.55rem;
        top: -30px;
    }
}

@media (min-width: 768px) {
    .pdf-page[draggable="true"]:hover::before {
        font-size: 0.7rem;
    }
}

.pdf-page[draggable="true"]:hover::after {
    content: "⋮⋮";
    position: absolute;
    top: 8px;
    right: 8px;
    color: #007bff;
    font-size: 1.5rem;
    line-height: 0.6;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

/* Add a drag handle in bottom right corner */
.pdf-page[draggable="true"]::after {
    content: "↗";
    position: absolute;
    bottom: 8px;
    right: 8px;
    color: #6c757d;
    font-size: 1.2rem;
    opacity: 0.6;
    pointer-events: none;
    transition: all 0.3s ease;
}

.pdf-page[draggable="true"]:hover::after {
    content: "✋ DRAG";
    bottom: 8px;
    right: 8px;
    top: auto;
    color: #007bff;
    font-size: 0.7rem;
    font-weight: bold;
    opacity: 1;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid #007bff;
}

.pdf-page.dragging {
    opacity: 0.6;
    transform: rotate(3deg) scale(0.95);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border-color: #007bff;
}

.pdf-page.drag-over {
    border-color: #28a745 !important;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.4) !important;
}

.pdf-page.drag-over::before {
    content: "📍 Drop Here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    z-index: 1001;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pdf-page canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.page-label {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #007bff;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 10;
}

.pdf-page.selected .page-label {
    background: #28a745;
}

.pdf-page.selected-for-removal .page-label {
    background: #dc3545;
}

/* Remove Pages Panel Styling */
#selectedPagesForRemoval {
    min-height: 60px;
    max-height: 120px;
    overflow-y: auto;
}

.selected-page-tag {
    display: inline-block;
    background: #dc3545;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 2px;
    cursor: pointer;
}

.selected-page-tag:hover {
    background: #c82333;
}

/* Enhanced Card Styling */
.card {
    border-radius: 15px;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.card-header {
    border-radius: 15px 15px 0 0 !important;
    border-bottom: none;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Button Enhancements */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
}

.btn-success {
    background: linear-gradient(45deg, #28a745, #1e7e34);
}

.btn-danger {
    background: linear-gradient(45deg, #dc3545, #c82333);
}

.btn-warning {
    background: linear-gradient(45deg, #ffc107, #e0a800);
    color: #212529;
}

.btn-info {
    background: linear-gradient(45deg, #17a2b8, #138496);
}

.btn-secondary {
    background: linear-gradient(45deg, #6c757d, #545b62);
}

/* Form Controls */
.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Alert Styling */
.alert-info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    border: none;
    border-radius: 10px;
    color: #0c5460;
}

/* Empty State */
.empty-state {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px dashed #ced4da;
    border-radius: 15px;
    padding: 3rem;
    margin: 1rem;
    text-align: center;
}

.empty-state:hover {
    border-color: #007bff;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}

/* Utility Classes */
.min-h-40 {
    min-height: 40px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pdf-pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 15px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
    
    .btn-lg {
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
    }
}

@media (max-width: 576px) {
    .pdf-pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
        padding: 10px;
    }
}

/* Form Controls */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Input Groups */
.input-group .btn {
    border-radius: 0 6px 6px 0;
}

.input-group .form-control {
    border-radius: 6px 0 0 6px;
}

/* File Input Styling */
.form-control[type="file"] {
    padding: 0.375rem 0.75rem;
}

.form-control[type="file"]::-webkit-file-upload-button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    margin-right: 0.75rem;
    cursor: pointer;
}

/* PDF Info Styling */
#pdfInfo {
    font-size: 0.9rem;
}

#pdfInfo .info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid #e9ecef;
}

#pdfInfo .info-label {
    font-weight: 600;
    color: #495057;
}

#pdfInfo .info-value {
    color: #6c757d;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #007bff;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Messages */
.toast {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0 10px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    #pdfPreview {
        min-height: 400px;
        padding: 10px;
    }
    
    .empty-state {
        height: 300px;
    }
    
    .empty-state i {
        font-size: 3rem !important;
    }
    
    .empty-state h4 {
        font-size: 1.2rem;
    }
}

/* Zoom Controls */
.zoom-controls {
    position: sticky;
    top: 10px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 10px;
}

/* Page Manipulation Indicators */
.page-selected {
    border: 3px solid #007bff !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25) !important;
}

.page-hover {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.page-hover:hover {
    transform: scale(1.02);
}

/* Drag and Drop Styling */
.drag-over {
    border: 2px dashed #007bff !important;
    background-color: rgba(0, 123, 255, 0.1) !important;
}

.drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
}

.drop-zone.drag-over {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

/* Progress Bar */
.progress {
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.3s ease;
}

/* Success/Error States */
.is-valid {
    border-color: #28a745;
}

.is-invalid {
    border-color: #dc3545;
}

/* Mobile-Friendly Form Controls */
.form-control, .form-select {
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-control-sm, .form-select-sm {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
}

@media (max-width: 767px) {
    .form-control, .form-select {
        font-size: 1rem; /* Better for mobile input */
        min-height: 44px; /* Touch-friendly */
    }
    
    .form-control-sm, .form-select-sm {
        font-size: 0.9rem;
        min-height: 38px;
    }
}

/* Enhanced Button Styles */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (max-width: 767px) {
    .btn {
        min-height: 44px; /* Touch-friendly on mobile */
        font-size: 0.9rem;
    }
    
    .btn-lg {
        min-height: 50px;
        font-size: 1rem;
    }
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

/* Loading States */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Mobile Navigation Improvements */
@media (max-width: 767px) {
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-text {
        font-size: 0.8rem;
    }
}

/* Responsive Alert Boxes */
.alert {
    border-radius: 8px;
    border: none;
    font-size: 0.85rem;
}

@media (max-width: 767px) {
    .alert {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
}

.valid-feedback {
    display: block;
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Enhanced Navigation */
.navbar {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
}

.navbar-brand i {
    color: #ffc107;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Enhanced Main Viewer */
.main-viewer {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: none;
    overflow: hidden;
}

.main-viewer .card-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Enhanced Badges and Tags */
.badge {
    font-size: 0.8rem;
    padding: 0.4em 0.8em;
    border-radius: 12px;
    text-shadow: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.badge:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Loading Spinner Enhancement */
.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-spinner-large {
    width: 5rem;
    height: 5rem;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.upload-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

/* Shake Animation for Errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

/* Enhanced Button Groups */
.btn-group .btn {
    border-radius: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-group .btn:first-child {
    border-radius: 8px 0 0 8px;
}

.btn-group .btn:last-child {
    border-radius: 0 8px 8px 0;
}

.btn-group .btn:only-child {
    border-radius: 8px;
}

/* Enhanced Page Number Labels */
.page-label {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    border: 2px solid white;
    z-index: 5;
    text-align: center;
    min-width: 80px;
}

.page-label .page-number {
    display: block;
    font-weight: 700;
}

.page-label .page-size {
    display: block;
    font-size: 0.6rem;
    opacity: 0.8;
    margin-top: 2px;
}

/* Click Overlay for Instructions */
.click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 123, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 8px;
    z-index: 2;
}

.pdf-page:hover .click-overlay {
    opacity: 1;
}

.click-instruction {
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.click-instruction i {
    font-size: 1rem;
}
