/* Modern Color Palette */
:root {
    /* New Palette Colors */
    --coffee-bean: #220901;
    --dark-garnet: #621708;
    --oxblood: #941b0c;
    --rusty-spice: #bc3908;
    --orange: #f6aa1c;
    
    /* Semantic Color Mappings */
    --primary-color: var(--rusty-spice);
    --primary-hover: var(--oxblood);
    --secondary-color: var(--dark-garnet);
    --success-color: #10b981;
    --danger-color: var(--oxblood);
    --warning-color: var(--orange);
    
    /* Background & Text Colors - Cleaner, more minimal */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    /* Shadows - Softer, more subtle */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 8px 16px 0 rgba(0, 0, 0, 0.12);
}

/* Modern Body Styling */
body {
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* Navbar Styling */
.navbar {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.navbar-brand {
    font-size: 1.25rem;
    color: var(--primary-color) !important;
}

/* Floating Save Button */
#save-doc-btn.visible {
    transform: translateY(0) !important;
}

#save-doc-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
}

/* Active Tool Button in Navbar */
.navbar .btn.active {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

.navbar .btn.active svg,
.navbar .btn.active i {
    color: white !important;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    box-shadow: var(--shadow-sm);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fef5f0 0%, #fdebe0 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fdebe0 0%, #fce1d0 100%);
    box-shadow: var(--shadow-lg);
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-content svg,
.upload-content i {
    color: #6c757d;
}

.signature-gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    align-items: start;
    align-content: start;
    padding: 0.5rem;
}

.signature-item {
    position: relative;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: auto;
    align-self: start;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.signature-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.signature-item.selected {
    border-color: var(--success-color);
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), var(--shadow-md);
}

.signature-item img {
    width: 100%;
    height: auto;
    display: block;
}

.signature-item .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--dark-garnet) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.signature-item:hover .delete-btn {
    opacity: 1;
    transform: scale(1.1);
}

.signature-item .delete-btn:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.pdf-container {
    position: relative;
    min-height: 600px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: auto;
    padding: 1rem;
    text-align: center;
}

.pdf-container:hover .pdf-navigation {
    opacity: 1;
    visibility: visible;
}

.pdf-navigation {
    position: absolute;
    left: 50%;
    z-index: 10;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.2s ease, visibility 0.2s ease;
    opacity: 0.85;
    visibility: visible;
    transform: translateX(-50%);
}

.pdf-navigation-top {
    top: 16px;
}

.pdf-navigation-bottom {
    bottom: 16px;
}

.pdf-navigation:hover {
    opacity: 1;
}

.pdf-navigation button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.pdf-navigation button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pdf-navigation button:active {
    transform: translateY(0);
}

.pdf-navigation .btn-sm {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
}

/* Compact toolbar buttons in PDF navigation */
.pdf-navigation .toolbar-btn {
    min-width: 60px;
    width: auto;
    height: auto;
    padding: 0.4rem 0.6rem;
}

.pdf-navigation .toolbar-btn svg,
.pdf-navigation .toolbar-btn i {
    width: 18px;
    height: 18px;
    margin: 0;
}

.pdf-navigation .toolbar-btn span {
    display: inline-block;
    font-size: 10px;
    margin-top: 2px;
}

.pdf-navigation .toolbar-group {
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.pdf-navigation .toolbar-label {
    margin-bottom: 2px;
    white-space: nowrap;
    font-size: 10px;
    line-height: 1.2;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 600px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    background: var(--bg-primary);
    border: 2px dashed var(--border-color);
}

.pdf-placeholder:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.01);
    box-shadow: var(--shadow-sm);
}

.pdf-placeholder:hover svg,
.pdf-placeholder:hover i {
    color: var(--primary-color);
    transform: scale(1.15) rotate(5deg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-placeholder-text {
    font-weight: 500;
    transition: all 0.3s ease;
}

.pdf-placeholder:hover .pdf-placeholder-text {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.pdf-placeholder svg,
.pdf-placeholder i {
    color: #6c757d;
    transition: all 0.3s ease;
}

#pdf-canvas {
    display: block;
    margin: 20px auto;
    box-shadow: var(--shadow-xl);
    max-width: 100%;
    height: auto;
    background: white;
    border-radius: 8px;
    border: 2px solid #000000;
}

.signature-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.signature-hover-preview {
    position: absolute;
    border: 2px dashed var(--primary-color);
    pointer-events: none;
    background: rgba(188, 57, 8, 0.08);
    opacity: 0.8;
    z-index: 10;
    display: none;
    box-shadow: var(--shadow-md);
    border-radius: 8px;
}

.signature-hover-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.7;
}

.signature-skeleton-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--primary-color);
    gap: 8px;
}

.signature-skeleton-content svg,
.signature-skeleton-content i {
    opacity: 0.6;
}

.signature-skeleton-content span {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.7;
}

.signature-on-pdf {
    position: absolute;
    border: 2px dashed var(--primary-color);
    cursor: move;
    pointer-events: all;
    background: transparent;
    border-radius: 8px;
}

.signature-on-pdf img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.signature-on-pdf .resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border: 2px solid white;
    border-radius: 50%;
    bottom: -7px;
    right: -7px;
    cursor: nwse-resize;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.signature-on-pdf .resize-handle:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.signature-on-pdf.selected {
    border-color: var(--success-color);
    background: transparent;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), var(--shadow-md);
}

.signature-on-pdf .delete-signature-btn {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--dark-garnet) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.signature-on-pdf .delete-signature-btn:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-lg);
}

.text-on-pdf {
    position: absolute;
    border: 2px dashed var(--primary-color);
    cursor: move;
    pointer-events: all;
    background: rgba(255, 255, 255, 0.98);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-wrap: break-word;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.text-on-pdf .resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border: 2px solid white;
    border-radius: 50%;
    bottom: -7px;
    right: -7px;
    cursor: nwse-resize;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.text-on-pdf .resize-handle:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.text-on-pdf .delete-signature-btn {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--dark-garnet) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.text-on-pdf .delete-signature-btn:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-lg);
}

.check-on-pdf {
    position: absolute;
    border: 2px dashed var(--success-color);
    cursor: move;
    pointer-events: all;
    background: rgba(255, 255, 255, 0.98);
    color: var(--success-color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.check-on-pdf .resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    border: 2px solid white;
    border-radius: 50%;
    bottom: -7px;
    right: -7px;
    cursor: nwse-resize;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.check-on-pdf .resize-handle:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.check-on-pdf .delete-signature-btn {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--dark-garnet) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.check-on-pdf .delete-signature-btn:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-lg);
}

.toolbar-btn.active {
    background: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

.toolbar-btn.active:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: var(--shadow-md) !important;
}

.card {
    box-shadow: var(--shadow-md);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-primary);
}

.card-header {
    background: var(--bg-primary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.card-body {
    display: flex;
    flex-direction: column;
}

#page-info {
    font-weight: 500;
    color: var(--text-primary);
}

/* Wizard Styles */
.wizard-step {
    min-height: 400px;
}

.wizard-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    box-shadow: var(--shadow-sm);
}

.wizard-upload-area:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fef5f0 0%, #fdebe0 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.wizard-upload-area.dragover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fdebe0 0%, #fce1d0 100%);
    box-shadow: var(--shadow-lg);
    transform: scale(1.02);
}

.wizard-upload-content {
    pointer-events: none;
}

.wizard-upload-content svg,
.wizard-upload-content i {
    color: #6c757d;
}

.wizard-preview-container {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 400px;
    overflow: auto;
}

.wizard-preview-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.wizard-crop-container {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    max-height: 500px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 300px;
    box-shadow: var(--shadow-md);
}

.wizard-crop-container img {
    max-width: 100%;
    max-height: 500px;
    display: block;
}

/* Cropper.js container styling */
.wizard-crop-container .cropper-container {
    max-height: 500px;
}

.wizard-crop-container .cropper-canvas {
    max-height: 500px;
}

/* Ensure Cropper.js is responsive */
.wizard-crop-container .cropper-wrap-box {
    max-height: 500px;
}

.wizard-crop-selection {
    position: absolute;
    border: 2px dashed var(--primary-color);
    background: rgba(188, 57, 8, 0.1);
    cursor: move;
    pointer-events: all;
    box-shadow: var(--shadow-md);
    z-index: 20;
    border-radius: 8px;
}

.wizard-crop-selection-temporary {
    background: rgba(188, 57, 8, 0.05);
    z-index: 15;
}

.wizard-crop-selection .crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    pointer-events: all;
    z-index: 30;
}

.wizard-crop-selection .crop-handle:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--dark-garnet) 100%);
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: var(--shadow-lg);
}

/* Corner handles */
.wizard-crop-selection .crop-handle-nw { top: 0; left: 0; cursor: nwse-resize; }
.wizard-crop-selection .crop-handle-ne { top: 0; left: 100%; cursor: nesw-resize; }
.wizard-crop-selection .crop-handle-sw { top: 100%; left: 0; cursor: nesw-resize; }
.wizard-crop-selection .crop-handle-se { top: 100%; left: 100%; cursor: nwse-resize; }

/* Side handles */
.wizard-crop-selection .crop-handle-n { top: 0; left: 50%; cursor: ns-resize; }
.wizard-crop-selection .crop-handle-s { top: 100%; left: 50%; cursor: ns-resize; }
.wizard-crop-selection .crop-handle-e { top: 50%; left: 100%; cursor: ew-resize; }
.wizard-crop-selection .crop-handle-w { top: 50%; left: 0; cursor: ew-resize; }

/* Delete button */
.wizard-crop-selection .crop-delete-btn {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--dark-garnet) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    padding: 0;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    z-index: 30;
    pointer-events: all;
}

.wizard-crop-selection .crop-delete-btn:hover {
    background: linear-gradient(135deg, var(--dark-garnet) 0%, var(--coffee-bean) 100%);
    transform: scale(1.15);
    box-shadow: var(--shadow-lg);
}

/* Tooltip */
.crop-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.3s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.signature-item .edit-btn {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.signature-item:hover .edit-btn {
    opacity: 1;
    transform: scale(1.1);
}

.signature-item .edit-btn:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.signature-item .edit-btn svg,
.signature-item .edit-btn i {
    width: 12px;
    height: 12px;
}

.signature-item .metadata-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.9) 100%);
    color: white;
    font-size: 10px;
    padding: 4px 6px;
    border-radius: 6px;
    text-align: center;
    backdrop-filter: blur(8px);
    font-weight: 600;
}

/* Toolbar Styles */
.toolbar {
    display: flex;
    gap: 1.5rem;
    padding: 0;
    flex-wrap: wrap;
    background: transparent;
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.toolbar-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toolbar-buttons {
    display: flex;
    gap: 0.25rem;
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 60px;
    color: var(--text-primary);
    box-shadow: none;
}

.toolbar-btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    color: var(--primary-color);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.toolbar-btn:disabled,
.toolbar-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

.toolbar-btn:disabled:hover,
.toolbar-btn.disabled:hover {
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

.toolbar-btn svg,
.toolbar-btn i {
    flex-shrink: 0;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.toolbar-btn:hover:not(:disabled) svg,
.toolbar-btn:hover:not(:disabled) i {
    color: var(--primary-color);
    transform: scale(1.1);
}

.toolbar-btn.active svg,
.toolbar-btn.active i {
    color: white;
}

.toolbar-btn span {
    font-size: 11px;
    font-weight: 500;
}

/* Signature Preview Modal */
.signature-preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.signature-preview-container img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Navigation Styles - Updated for overlay positioning */
#page-info-top,
#page-info-bottom {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Specific override for top navigation page info to match toolbar styling */
.pdf-navigation #page-info-top {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* Modern Modal Enhancements */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
}

.modal-header {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
}

.modal-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
}

/* Enhanced Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--dark-garnet) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline-primary {
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Smooth Scrollbar */
.signature-gallery::-webkit-scrollbar,
.pdf-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.signature-gallery::-webkit-scrollbar-track,
.pdf-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.signature-gallery::-webkit-scrollbar-thumb,
.pdf-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.signature-gallery::-webkit-scrollbar-thumb:hover,
.pdf-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

    /* Responsive Design */
    @media (max-width: 768px) {
        /* Increase body padding to allow scrolling past floating button */
        body {
            padding-bottom: 100px;
        }

        /* Force navbar to wrap */
        .navbar .container-fluid {
            justify-content: center;
        }

        .navbar-brand {
            margin-right: 0;
            margin-bottom: 0.5rem;
            width: 100%;
            justify-content: center;
        }

        /* PDF Navigation - Move out of canvas area */
        .pdf-navigation {
            position: relative;
            left: auto;
            transform: none;
            width: 100%;
            margin-bottom: 0;
            background: transparent;
            border: none;
            box-shadow: none;
            padding: 0.5rem 0;
        }

        .pdf-navigation-top {
            top: auto;
            border-bottom: 1px solid var(--border-color);
            background: var(--bg-primary);
            margin-bottom: 10px;
            border-radius: 12px 12px 0 0;
        }

        .pdf-navigation-bottom {
            bottom: auto;
            border-top: 1px solid var(--border-color);
            background: var(--bg-primary);
            margin-top: 10px;
            border-radius: 0 0 12px 12px;
        }
        
        /* Adjust PDF container for static nav */
        .pdf-container {
            padding: 0;
            display: flex;
            flex-direction: column;
        }
        
        #pdf-canvas {
            margin: 0 auto;
            order: 2;
        }

        .pdf-navigation-top {
            order: 1;
        }

        .pdf-navigation-bottom {
            order: 3;
        }

        .hero-header {
            padding: 1rem;
        border-radius: 0 0 1.5rem 1.5rem;
        margin-bottom: 1rem;
    }
    
    .hero-title {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .hero-toolbar {
        padding: 0.5rem;
        margin-top: 0;
        border-radius: 8px;
        width: 100%;
        overflow: hidden;
    }
    
    .toolbar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 5px; /* Space for scrollbar */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .toolbar::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Webkit */
    }
    
    .toolbar-group {
        flex-direction: row;
        align-items: center;
        min-width: auto;
        flex: 0 0 auto;
        padding-right: 0.75rem;
        margin-right: 0.75rem;
        border-right: 1px solid var(--border-color);
        gap: 0.5rem;
    }
    
    .toolbar-group:last-child {
        border-right: none;
        margin-right: 0;
        padding-right: 0;
    }
    
    .toolbar-label {
        display: none;
    }

    .toolbar-buttons {
        gap: 0.25rem;
    }
    
    .toolbar-btn {
        padding: 0.4rem;
        min-width: auto;
        width: 36px;
        height: 36px;
    }

    .toolbar-btn span {
        display: none;
    }

    .toolbar-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Signature Gallery Mobile - Horizontal Scroll */
    .signature-gallery {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 0.25rem;
        gap: 0.5rem;
        max-height: none;
        min-height: auto;
        -webkit-overflow-scrolling: touch;
        align-items: center;
    }
    
    .signature-item {
        flex: 0 0 auto;
        width: 70px;
        height: 70px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0.25rem;
    }
    
    .signature-item img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
    }

    /* Adjust Layout for Mobile */
    .main-content {
        padding: 0 0.5rem 1rem 0.5rem;
    }

    .col-md-2 {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .col-md-2 .card {
        margin-bottom: 0;
        height: auto !important; /* Prevent full height on mobile */
        border-radius: 8px;
    }

    .col-md-2 .card-header {
        padding: 0.25rem 0.5rem;
    }

    .col-md-2 .card-body {
        padding: 0.25rem;
    }
    
    .col-md-2 .toolbar-label {
        font-size: 0.7rem;
        margin-bottom: 0;
    }

    .col-md-2 .toolbar {
        gap: 0.5rem;
        align-items: center;
    }
}

@media (max-width: 576px) {
    .hero-header {
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
}

/* Additional Clean Styling */
.hero-toolbar .toolbar {
    justify-content: flex-start;
    gap: 1.5rem;
}

.hero-toolbar .toolbar-group {
    margin-bottom: 0;
}

.hero-toolbar .toolbar-label {
    color: #495057;
}

.hero-toolbar .toolbar-btn {
    background: white;
    border: 1px solid #dee2e6;
}

.hero-toolbar .toolbar-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.hero-toolbar .toolbar-btn.active {
    background: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

.hero-toolbar .toolbar-btn svg,
.hero-toolbar .toolbar-btn i {
    color: var(--primary-color);
}

.hero-toolbar .toolbar-btn.active svg,
.hero-toolbar .toolbar-btn.active i {
    color: white;
}

/* Cleaner button styles */
.btn-primary {
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Modal updates for cleaner look */
.modal-content {
    border: 1px solid var(--border-color);
}

.modal-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1rem 1.25rem;
}

.modal-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}
