/* ========================================
   CSS Custom Properties for Responsive Layout
   ======================================== */
:root {
    /* Layout dimensions */
    --header-height: 70px;
    --sidebar-width: 200px;
    --container-gap: 20px;
    --container-padding: 20px;

    /* Toolbar spacing */
    --toolbar-gap: 8px;
    --toolbar-btn-padding: 8px 12px;
    --toolbar-font-size: 14px;

    /* Zoom controls */
    --zoom-btn-size: 35px;
    --zoom-position-right: 38px;
    --zoom-position-bottom: 20px;

    /* Text settings panel */
    --text-panel-width: min(520px, 90vw);

    /* Typography scale */
    --font-size-h1: 24px;
    --font-size-base: 14px;
    --font-size-small: 13px;

    /* Spacing multiplier - adjusted by density detection */
    --density-multiplier: 1;
}

/* ========================================
   JavaScript-driven density classes
   These are applied by state.js based on display detection
   ======================================== */
:root.density-high {
    /* High-DPI / Retina displays - slightly more compact */
    --density-multiplier: 0.95;
}

:root.density-medium {
    /* Medium-DPI (some Windows laptops at 125-150% scaling) */
    --density-multiplier: 0.98;
}

:root.density-spacious {
    /* Standard DPI with large viewport (1080p+) - more breathing room */
    --density-multiplier: 1.1;
    --container-gap: 24px;
    --container-padding: 24px;
    --toolbar-gap: 10px;
}

:root.density-compact {
    /* Small viewport (1366px laptops) - tighter spacing */
    --density-multiplier: 0.9;
    --container-gap: 14px;
    --container-padding: 14px;
    --toolbar-gap: 5px;
}

/* ========================================
   Media query fallbacks (for when JS hasn't loaded)
   ======================================== */
/* High-DPI / Retina displays - slightly more compact */
@media (min-resolution: 2dppx),
(-webkit-min-device-pixel-ratio: 2) {
    :root:not(.density-high):not(.density-medium):not(.density-spacious):not(.density-compact) {
        --density-multiplier: 0.95;
    }
}

/* Standard density displays - more breathing room */
@media (max-resolution: 1.5dppx) and (min-width: 1920px) {
    :root:not(.density-high):not(.density-medium):not(.density-spacious):not(.density-compact) {
        --density-multiplier: 1.1;
        --container-gap: 24px;
        --container-padding: 24px;
        --toolbar-gap: 10px;
    }
}

.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
    vertical-align: middle;
    user-select: none;
}

.tool-btn .material-symbols-outlined {
    font-size: 24px;
}

.upload-icon .material-symbols-outlined {
    font-size: 64px;
}

h3 .material-symbols-outlined {
    font-size: 20px;
    vertical-align: middle;
    margin-right: 4px;
}

.btn .material-symbols-outlined {
    font-size: 18px;
}

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

body {
    font-family: Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #E0F2FE 0%, #F3F4F6 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-height);
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header h1 {
    color: #2563EB;
    font-size: var(--font-size-h1);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

/* Horizontal Toolbar */
.horizontal-toolbar {
    display: flex;
    gap: var(--toolbar-gap);
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
    container-type: inline-size;
    container-name: toolbar;
}

.toolbar-dropdown {
    position: relative;
}

.toolbar-dropdown-btn {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: var(--toolbar-btn-padding);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--toolbar-font-size);
    font-weight: 600;
    transition: all 0.3s ease;
    color: #333;
    position: relative;
}

.toolbar-dropdown-btn:hover {
    border-color: #2563EB;
    background: #f0f7ff;
}

.toolbar-dropdown-btn:active {
    transform: translateY(3px);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    background: #e0efff;
}

.toolbar-dropdown-btn .material-symbols-outlined {
    font-size: 20px;
}

.toolbar-dropdown-btn .dropdown-arrow {
    font-size: 18px;
    transition: transform 0.3s ease;
}

/* Active indicator badge */
.toolbar-dropdown-btn .active-indicator {
    display: none;
    margin-left: auto;
    padding: 2px 8px;
    background: #2563EB;
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-dropdown-btn.has-selection .active-indicator {
    display: block;
}

/* Color indicator swatch */
.toolbar-dropdown-btn .color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ddd;
    margin-left: auto;
}

.toolbar-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.toolbar-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.35), 0 16px 32px -16px rgba(37, 99, 235, 0.2);
    padding: 15px;
    min-width: 250px;
    z-index: 1001;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    will-change: opacity, transform;
}

.toolbar-dropdown.active .toolbar-dropdown-content {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header hamburger menu - align to right edge */
#headerMenu {
    left: auto;
    right: 0;
}

/* Center icon+text inside header dropdown buttons */
#headerMenu .btn {
    justify-content: flex-start;
    /* Align to left */
    text-align: left;
    background: transparent;
    /* Remove background */
    color: #333;
    /* Dark text */
    box-shadow: none;
    /* Remove shadow */
    border: none;
    /* Remove border if any */
    padding: 12px 16px;
    /* Adjust padding */
    width: 100%;
}

#headerMenu .btn:hover {
    background: #f3f4f6;
    /* Light gray hover */
    transform: none;
    /* Disable transform on hover */
    box-shadow: none;
}

#headerMenu .btn .material-symbols-outlined {
    margin-right: 12px;
    color: #5f6368;
    /* Icon color */
    font-size: 20px;
}

#headerMenu .btn-logout {
    color: #d93025 !important;
    /* Red text for logout */
}

#headerMenu .btn-logout .material-symbols-outlined {
    color: #d93025 !important;
    /* Red icon for logout */
}

/* Center icon+text inside toolbar dropdown buttons (e.g., Actions, bubble settings) */
.toolbar-dropdown-content .btn {
    justify-content: center;
    text-align: center;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.dropdown-setting {
    margin-bottom: 15px;
}

.dropdown-setting:last-child {
    margin-bottom: 0;
}

.dropdown-setting label {
    display: block;
    color: #555;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 600;
}

.dropdown-setting input[type="range"],
.dropdown-setting input[type="number"],
.dropdown-setting select {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.dropdown-setting input[type="number"] {
    margin-bottom: 8px;
}


.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 1px rgba(102, 126, 234, 0.2);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(56, 239, 125, 0.4);
}

.btn-success:active {
    transform: translateY(2px);
    box-shadow: 0 1px 1px rgba(56, 239, 125, 0.2);
}

.btn-info {
    background: #2563EB;
    color: white;
}

.btn-info:hover {
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.btn-info:active {
    transform: translateY(2px);
    box-shadow: 0 1px 1px rgba(37, 99, 235, 0.2);
}

#helpButton {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: #2563EB !important;
    min-width: auto;
}

#helpButton:hover {
    transform: none !important;
    opacity: 0.7;
}

#helpButton .material-symbols-outlined {
    font-size: 28px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.3);
}

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

.container {
    flex: 1;
    display: flex;
    gap: var(--container-gap);
    padding: 0 var(--container-padding) var(--container-padding) var(--container-padding);
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

/* Hide old vertical toolbar */
.toolbar {
    display: none !important;
}


.toolbar-section {
    margin-bottom: 25px;
}

.toolbar-section h3 {
    color: #333;
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2563EB;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.toolbar-section h3:hover {
    color: #2563EB;
}

.toolbar-section.collapsed .section-content {
    display: none;
}

.toolbar-section .section-content {
    display: block;
}

.collapse-icon {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.toolbar-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.tool-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.tool-btn {
    aspect-ratio: 1;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.15), 0 4px 8px -4px rgba(0, 0, 0, 0.1);
}

.tool-btn:hover {
    border-color: #2563EB;
    transform: scale(1.05);
}

.tool-btn:active {
    transform: scale(0.88);
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
}

.tool-btn.active {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    border-color: #2563EB;
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    color: #555;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 600;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #2563EB;
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.color-preset {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: #333;
}

.color-preset:active {
    transform: scale(0.8);
}

.color-preset.active {
    border: 3px solid #2563EB;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
    transform: scale(1.05);
}

.canvas-container {
    background: transparent;
    border-radius: 20px;
    padding: 20px;
    box-shadow: none;
    /* Removed shadow from container */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    /* Enable vertical scrolling */
    overflow-x: auto;
    /* Enable horizontal scrolling for zoomed docs */
    flex: 1;
    height: calc(100vh - 80px);
    /* Fixed height to allow scrolling within */
    min-height: 0;
    /* Allow shrinking */
}

/* Space-drag panning (hand tool feel) */
.canvas-container.pan-ready {
    cursor: grab;
}

.canvas-container.pan-active {
    cursor: grabbing;
}

.canvas-container.pan-ready .pdf-canvas,
.canvas-container.pan-ready .annotation-canvas {
    cursor: grab !important;
}

.canvas-container.pan-active .pdf-canvas,
.canvas-container.pan-active .annotation-canvas {
    cursor: grabbing !important;
}

.page-container {
    position: relative;
    margin-bottom: 30px;
    /* Space between pages */
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.35), 0 16px 32px -16px rgba(37, 99, 235, 0.2);
    /* Marketing "Most Popular" card style shadow */
    background: white;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
    min-height: 100px;
}



.page-container:last-child {
    margin-bottom: 100px;
    /* Extra space at bottom */
}

#canvasSection {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.pdf-canvas,
.annotation-canvas {
    display: block;
    margin: 0 auto;
}

.annotation-canvas {
    pointer-events: auto;
}

/* Upload Card - Premium Redesign */
.upload-area {
    width: 100%;
    max-width: 680px;
    padding: 80px 40px;
    background: #FFFFFF;
    border-radius: 24px;
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.35), 0 16px 32px -16px rgba(37, 99, 235, 0.2);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 2px dashed rgba(37, 99, 235, 0.2);
    /* Subtle dashed border initially */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.upload-area:hover {
    transform: translateY(-5px);
    box-shadow: 0 40px 80px -12px rgba(37, 99, 235, 0.45);
    border-color: rgba(37, 99, 235, 0.5);
}

.upload-area:active {
    transform: translateY(0);
    box-shadow: 0 10px 20px -12px rgba(37, 99, 235, 0.25);
    transition-duration: 0.1s;
}

.upload-area.dragover {
    transform: scale(1.02);
    box-shadow: 0 48px 96px -10px rgba(37, 99, 235, 0.55);
    border-color: #2563EB;
    background: #F8FAFF;
}

.upload-icon {
    font-size: 64px;
    color: #2563EB;
    margin-bottom: 0;
    /* Spacing handled by flex gap */
    background: rgba(37, 99, 235, 0.1);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
    transform: scale(1.1) rotate(5deg);
    background: rgba(37, 99, 235, 0.15);
}

.upload-icon .material-symbols-outlined {
    font-size: 48px;
    /* Adjusted icon size inside the circle */
}

.upload-area h2 {
    color: #1F2937;
    /* Dark grey */
    margin-bottom: 5px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.upload-area p {
    color: #6B7280;
    /* Light grey */
    font-family: Helvetica, Arial, sans-serif;
    font-size: 18px;
    font-weight: 500;
    max-width: 400px;
    line-height: 1.5;
}

#fileInput {
    display: none;
}

.canvas-wrapper {
    position: relative;
    margin: 0;
    /* Remove margin to prevent cutoff */
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    overflow: visible;
    /* Changed from hidden to visible */
}

.canvas-wrapper.page-slide-up {
    animation: pageSlideUp 0.5s ease-in-out;
}

.canvas-wrapper.page-slide-down {
    animation: pageSlideDown 0.5s ease-in-out;
}

@keyframes pageSlideUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    10% {
        transform: translateY(-20%);
        opacity: 0.8;
    }

    25% {
        transform: translateY(-50%);
        opacity: 0.5;
    }

    40% {
        transform: translateY(-80%);
        opacity: 0.2;
    }

    50% {
        transform: translateY(-100%);
        opacity: 0;
    }

    51% {
        transform: translateY(100%);
        opacity: 0;
    }

    60% {
        transform: translateY(80%);
        opacity: 0.2;
    }

    75% {
        transform: translateY(50%);
        opacity: 0.5;
    }

    90% {
        transform: translateY(20%);
        opacity: 0.8;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pageSlideDown {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    10% {
        transform: translateY(20%);
        opacity: 0.8;
    }

    25% {
        transform: translateY(50%);
        opacity: 0.5;
    }

    40% {
        transform: translateY(80%);
        opacity: 0.2;
    }

    50% {
        transform: translateY(100%);
        opacity: 0;
    }

    51% {
        transform: translateY(-100%);
        opacity: 0;
    }

    60% {
        transform: translateY(-80%);
        opacity: 0.2;
    }

    75% {
        transform: translateY(-50%);
        opacity: 0.5;
    }

    90% {
        transform: translateY(-20%);
        opacity: 0.8;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

#pdfCanvas,
#annotationCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#annotationCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

/* Removed Page Thumbnails and Zoom Controls styles as they are no longer used in sidebar */
.zoom-controls-fixed {
    position: fixed;
    bottom: clamp(12px, 2vh, 24px);
    right: clamp(20px, 3vw, 50px);
    background: rgba(255, 255, 255, 0.9);
    padding: clamp(8px, 1vw, 12px);
    border-radius: 50px;
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.45), 0 16px 32px -16px rgba(37, 99, 235, 0.3);
    display: flex;
    gap: clamp(6px, 1vw, 12px);
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.zoom-controls-fixed button {
    width: var(--zoom-btn-size);
    height: var(--zoom-btn-size);
    border-radius: 60%;
    border: none;
    background: #2563EB;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 18px 36px -12px rgba(37, 99, 235, 0.6);
    transition: transform 0.2s;
}

.zoom-controls-fixed button:hover {
    transform: scale(1.1);
    box-shadow: 0 24px 48px -12px rgba(37, 99, 235, 0.75);
}

#zoomOutBtn:hover {
    transform: scale(0.9);
}

.zoom-controls-fixed .zoom-level {
    font-weight: bold;
    min-width: clamp(50px, 5vw, 70px);
    text-align: center;
    font-size: clamp(12px, 1vw, 16px);
}

.hidden {
    display: none !important;
}

.inline-text-input {
    position: absolute;
    display: block;
    /* Because line 922 display: block is invoked, line 923 is ignored. */
    vertical-align: top;
    border: 2px solid #666;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px 16px;
    font-family: Arial;
    font-size: 16px;
    outline: none;
    min-width: 200px;
    min-height: 40px;
    height: auto;
    box-shadow: 0 18px 36px -18px rgba(37, 99, 235, 0.38);
    z-index: 1000;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    border-radius: 0;
}

.inline-text-input:focus {
    border-color: #2563EB;
    box-shadow: 0 22px 44px -18px rgba(37, 99, 235, 0.5);
}

/* PDF Text Edit Mode - visual indicator */
.inline-text-input.pdf-text-edit {
    border-color: #059669;
    background: rgba(236, 253, 245, 0.7);
}

.inline-text-input.pdf-text-edit:focus {
    border-color: #059669;
    box-shadow: 0 22px 44px -18px rgba(5, 150, 105, 0.5);
}

.text-input-wrapper.pdf-text-edit-wrapper .text-box-drag-handle {
    background: linear-gradient(to bottom, #a7f3d0 0%, #6ee7b7 50%, #34d399 100%);
    border: 1px solid #059669;
}

.text-input-wrapper.pdf-text-edit-wrapper .text-box-drag-handle:hover {
    background: linear-gradient(to bottom, #6ee7b7 0%, #34d399 50%, #10b981 100%);
}

.text-input-wrapper.pdf-text-edit-wrapper .text-box-drag-handle::before,
.text-input-wrapper.pdf-text-edit-wrapper .text-box-drag-handle::after {
    background: #065f46;
}

/* Text box wrapper with corner bracket design */
.text-input-wrapper {
    position: relative;
}

.text-input-wrapper::before,
.text-input-wrapper::after {
    content: '';
    position: absolute;
    pointer-events: none;
    z-index: 1001;
}

/* Corner brackets - removed */
.text-input-wrapper::before {
    display: none;
}

/* Drag handle - 3D grey rectangle with lines at top center */
.text-box-drag-handle {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 14px;
    cursor: move;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    background: linear-gradient(to bottom, #bfdbfe 0%, #60a5fa 50%, #3b82f6 100%);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border: 1px solid #2563EB;
}

.text-box-drag-handle::before,
.text-box-drag-handle::after {
    content: '';
    width: 24px;
    height: 2px;
    background: #1e3a8a;
    border-radius: 1px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.text-box-drag-handle:hover {
    background: linear-gradient(to bottom, #93c5fd 0%, #3b82f6 50%, #2563eb 100%);
}

.text-box-drag-handle:hover::before,
.text-box-drag-handle:hover::after {
    background: #1e40af;
}

/* Resize handle - bottom right corner (smaller) */
.text-input-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    z-index: 1002;
    background: linear-gradient(135deg, transparent 50%, #666 50%);
    border-bottom-right-radius: 2px;
}

.text-input-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, #000 50%);
}

.text-input-resize-handle::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 5px;
    height: 5px;
    background-image:
        linear-gradient(to bottom right, transparent 40%, #fff 40%, #fff 45%, transparent 45%),
        linear-gradient(to bottom right, transparent 60%, #fff 60%, #fff 65%, transparent 65%);
}

/* Floating Text Settings Panel */
.text-settings-panel {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.35), 0 16px 32px -16px rgba(37, 99, 235, 0.2);
    z-index: 10000;
    width: var(--text-panel-width);
    max-width: 90vw;
    font-family: Helvetica, Arial, sans-serif;
}

.text-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f8f8;
    border-radius: 8px 8px 0 0;
}

.text-settings-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.text-settings-header-actions {
    display: flex;
    gap: 6px;
}

.text-settings-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    background: transparent;
}

.text-settings-action-btn .material-symbols-outlined {
    font-size: 18px;
}

.text-settings-action-btn.confirm {
    color: #2563EB;
}

.text-settings-action-btn.confirm:hover {
    background: #e3f2fd;
}

.text-settings-action-btn.cancel {
    color: #666;
}

.text-settings-action-btn.cancel:hover {
    background: #f5f5f5;
}

.text-settings-body {
    padding: 10px 12px;
}

.text-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.text-settings-row:last-child {
    margin-bottom: 0;
}

.text-settings-row select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.text-settings-row select:focus {
    outline: none;
    border-color: #2563EB;
}

.text-settings-row select.font-select {
    flex: 1;
    min-width: 140px;
}

.text-settings-row select.size-select {
    width: 70px;
}

.text-settings-style-group {
    display: flex;
    gap: 4px;
}

.text-settings-style-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.text-settings-style-btn:hover {
    background: #f5f5f5;
    border-color: #2563EB;
}

.text-settings-style-btn.active {
    background: #2563EB;
    border-color: #2563EB;
    color: white;
}

.text-settings-style-btn .material-symbols-outlined {
    font-size: 18px;
}

.text-settings-color-input {
    width: 36px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    background: white;
}

.text-settings-align-group {
    display: flex;
    gap: 4px;
}

.text-settings-footer {
    padding: 6px 12px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
}

.text-settings-char-count {
    font-size: 11px;
    color: #999;
}

.text-settings-color-dropdown {
    position: relative;
}

.text-settings-color-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.text-settings-color-button:hover {
    background: #f5f5f5;
    border-color: #2563EB;
}

.text-settings-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #ddd;
}

.text-settings-dropdown-arrow {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.text-settings-color-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 1000;
    min-width: 380px;
}

.text-settings-color-dropdown-content.show {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.text-settings-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.text-settings-color-item:hover {
    background: #f5f5f5;
}

.text-settings-color-item.active {
    background: #e3f2fd;
}

.text-settings-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.text-settings-color-item:hover .text-settings-color-swatch {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.text-settings-color-item.active .text-settings-color-swatch {
    box-shadow: 0 0 0 3px #2563EB;
    transform: scale(1.05);
}

.text-settings-color-label {
    font-size: 10px;
    color: #666;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.text-box-resizable {
    position: absolute;
    border: 2px dashed #2563EB;
    background: rgba(37, 99, 235, 0.1);
    min-width: 100px;
    min-height: 50px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
    z-index: 1000;
    cursor: nwse-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-box-resizable::after {
    content: 'Click to start typing';
    color: #2563EB;
    font-size: 14px;
    pointer-events: none;
}

.text-box-resizable.typing::after {
    display: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* ========================================
   4K and Ultra-wide displays (2560px+)
   ======================================== */
@media (min-width: 2560px) {
    :root {
        --header-height: 80px;
        --sidebar-width: 250px;
        --container-gap: 30px;
        --container-padding: 30px;
        --toolbar-gap: 12px;
        --font-size-h1: 28px;
        --zoom-btn-size: 48px;
    }

    .header h1 {
        font-size: var(--font-size-h1);
    }

    .toolbar-dropdown-btn {
        padding: 10px 16px;
        font-size: 15px;
    }

    .page-thumbnails {
        width: var(--sidebar-width);
    }
}

/* ========================================
   Standard 1080p displays (1920px)
   ======================================== */
@media (min-width: 1600px) and (max-width: 2559px) {
    :root {
        --container-gap: 22px;
        --container-padding: 22px;
        --toolbar-gap: 9px;
    }
}

/* ========================================
   1440px displays (MacBook Pro 15", some externals)
   ======================================== */
@media (max-width: 1440px) and (min-width: 1367px) {
    :root {
        --sidebar-width: 180px;
        --container-gap: 18px;
        --container-padding: 18px;
    }

    .page-thumbnails {
        width: var(--sidebar-width);
    }
}

/* ========================================
   1366px displays (common Windows laptops)
   ======================================== */
@media (max-width: 1366px) and (min-width: 1201px) {
    :root {
        --header-height: 65px;
        --sidebar-width: 160px;
        --container-gap: 15px;
        --container-padding: 15px;
        --toolbar-gap: 6px;
        --font-size-h1: 22px;
    }

    .header h1 {
        font-size: var(--font-size-h1);
    }

    .toolbar-dropdown-btn {
        padding: 7px 10px;
        font-size: 13px;
    }

    .page-thumbnails {
        width: var(--sidebar-width);
    }

    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   1200px and below
   ======================================== */
@media (max-width: 1200px) {
    :root {
        --header-height: 65px;
        --sidebar-width: 150px;
        --toolbar-gap: 6px;
        --font-size-h1: 20px;
    }

    .header h1 {
        font-size: var(--font-size-h1);
    }

    .horizontal-toolbar {
        gap: var(--toolbar-gap);
    }

    .toolbar-dropdown-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

    .toolbar-dropdown-btn span:not(.material-symbols-outlined) {
        display: none;
    }

    .toolbar-dropdown-btn .material-symbols-outlined {
        font-size: 24px;
    }

    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   Container Queries for Toolbar (Progressive Enhancement)
   ======================================== */
@container toolbar (max-width: 600px) {
    .toolbar-dropdown-btn span:not(.material-symbols-outlined) {
        display: none;
    }
}

@container toolbar (max-width: 400px) {
    .toolbar-dropdown-btn {
        padding: 6px 8px;
    }

    .toolbar-dropdown-btn .dropdown-arrow {
        display: none;
    }
}

/* ========================================
   1024px and below (tablets, small laptops)
   ======================================== */
@media (max-width: 1024px) {
    :root {
        --header-height: 120px;
    }

    body {
        padding-top: var(--header-height);
    }

    .header {
        flex-direction: column;
        align-items: center;
        padding: 8px 10px;
    }

    .horizontal-toolbar {
        width: 100%;
        justify-content: center;
        order: 2;
        margin-top: 8px;
    }

    .header-actions {
        order: 3;
        margin-top: 8px;
    }

    .container {
        flex-direction: column;
    }

    .canvas-container {
        max-height: calc(100vh - var(--header-height) - 20px);
        padding: 10px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 140px;
        --font-size-h1: 18px;
        --text-panel-width: min(400px, 95vw);
    }

    body {
        padding-top: var(--header-height);
    }

    .header h1 {
        font-size: var(--font-size-h1);
    }

    .toolbar-dropdown-content {
        min-width: 200px;
    }

    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .canvas-container {
        max-height: calc(100vh - var(--header-height) - 20px);
        padding: 5px;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 180px;
        --toolbar-gap: 4px;
        --text-panel-width: min(320px, 98vw);
    }

    body {
        padding-top: var(--header-height);
    }

    .horizontal-toolbar {
        gap: var(--toolbar-gap);
    }

    .toolbar-dropdown-btn {
        padding: 6px 8px;
    }

    .toolbar-dropdown-btn .dropdown-arrow {
        display: none;
    }

    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.annotation-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 10px;
}

.annotation-item {
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.annotation-item button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.annotation-item button:hover {
    background: #c82333;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #000000;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1D4ED8;
}

.page-thumbnails {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    width: 200px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    height: fit-content;
    max-height: 850px;
    overflow-y: auto;
    overflow-x: hidden;
    position: sticky;
    top: 20px;
}

.page-thumbnails h3 {
    color: #333;
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2563EB;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thumbnail-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 5px;
}

.thumbnail-container.drag-over {
    background: rgba(37, 99, 235, 0.1);
    border: 2px dashed #2563EB;
    border-radius: 8px;
    padding: 10px;
}

.thumbnail-item {
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.thumbnail-item.active {
    border-color: #2563EB;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.5);
}

.thumbnail-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.thumbnail-canvas {
    width: 100%;
    display: block;
}

.thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(74, 144, 226, 0.9);
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.remove-page-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    z-index: 10;
}

.thumbnail-item:hover .remove-page-btn {
    display: flex;
}

.remove-page-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

@media (max-width: 1400px) {
    .page-thumbnails {
        width: 150px;
    }
}

@media (max-width: 1024px) {
    .page-thumbnails {
        display: none;
    }
}

/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #E0F2FE 0%, #F3F4F6 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-icon {
    font-size: 80px;
    color: #2563EB;
    animation: bounceIn 1.5s ease-out;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 36px;
    color: #2563EB;
    font-weight: 600;
    opacity: 0;
    animation: materialize 1s ease-out 0.8s forwards;
}

@keyframes bounceIn {
    0% {
        transform: translateY(-100px) scale(0.3);
        opacity: 0;
    }

    50% {
        transform: translateY(10px) scale(1.1);
        opacity: 1;
    }

    70% {
        transform: translateY(-5px) scale(0.95);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes materialize {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dropdownBounce {
    0% {
        transform: translateY(-15px) scale(0.9);
        opacity: 0;
    }

    50% {
        transform: translateY(3px) scale(1.02);
        opacity: 1;
    }

    70% {
        transform: translateY(-2px) scale(0.98);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes dropdownSlide {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-content h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 22px;
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content p {
    text-align: center;
    color: #666;
    line-height: 1.5;
    margin: 15px 0 25px 0;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 25px;
}

.modal-content h3 {
    margin: 0 0 20px 0;
    color: #2563EB;
    font-size: 24px;
    text-align: center;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.filename-input {
    width: calc(100% - 50px);
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.file-extension {
    margin-left: 10px;
    color: #666;
    font-weight: 600;
}

.compress-option {
    margin-top: 16px;
}

.compress-option .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    color: #555;
    font-size: 14px;
}

.compress-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.quality-options {
    margin-top: 16px;
}

.quality-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.quality-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-label:hover {
    background: #f8f9fa;
    border-color: #ccc;
}

.radio-label:has(input:checked) {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.radio-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.radio-text strong {
    font-size: 14px;
    color: #333;
}

.radio-text small {
    font-size: 12px;
    color: #666;
}

.file-size-estimate {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-size-estimate .estimate-label {
    color: #666;
    font-size: 13px;
}

.file-size-estimate .estimate-value {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Pages Modal Styles */
.pages-modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    margin: 5% auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.close-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.pages-modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.pages-modal-actions {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.pages-modal-actions .btn {
    margin: 0 auto;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.3s;
    min-height: 200px;
}

.pages-grid.drag-over {
    border-color: #2563EB;
    background-color: rgba(37, 99, 235, 0.05);
}

.page-modal-item {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.page-modal-item:hover {
    border-color: #2563EB;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.page-modal-item.active {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.page-modal-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.page-modal-item.landscape {
    grid-column: span 2;
}

.page-modal-canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-modal-label {
    padding: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    background: #f8f9fa;
}

.page-modal-item:hover .page-modal-actions,
.page-modal-item:hover .page-modal-actions-left {
    opacity: 1;
}

.page-modal-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.page-modal-actions-left {
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.page-modal-action-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, transform 0.2s;
}

.page-modal-action-btn:hover {
    transform: scale(1.1);
}

.page-modal-action-btn .material-symbols-outlined {
    font-size: 16px;
}

.rotate-page-modal-btn {
    background: rgba(74, 144, 226, 0.9);
}

.rotate-page-modal-btn:hover {
    background: #4a90e2;
}

.remove-page-modal-btn {
    background: rgba(220, 53, 69, 0.9);
}

.remove-page-modal-btn:hover {
    background: #dc3545;
}

.pages-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
}

/* Help Modal Styles */
.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-logout {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-logout:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-leave {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
}

.btn-leave:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.help-modal-content {
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    margin: 3% auto;
}

.help-modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px 5px;
}

.help-modal-body::-webkit-scrollbar {
    width: 8px;
}

.help-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.help-modal-body::-webkit-scrollbar-thumb {
    background: #2563EB;
    border-radius: 4px;
}

.help-modal-body::-webkit-scrollbar-thumb:hover {
    background: #357abd;
}

.help-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #2563EB;
}

.help-section h4 {
    color: #2563EB;
    margin-bottom: 12px;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section h4 .material-symbols-outlined {
    font-size: 24px;
}

.help-section p {
    color: #333;
    line-height: 1.6;
    margin-bottom: 10px;
    text-align: left;
}

.help-section ul {
    margin-left: 20px;
    margin-top: 10px;
}

.help-section ul li {
    color: #333;
    line-height: 1.8;
    margin-bottom: 10px;
    text-align: left;
}

.help-section ul li strong {
    color: #2563EB;
    font-weight: 600;
}

.help-modal-content .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.help-modal-content .modal-header h3 .material-symbols-outlined {
    font-size: 28px;
}

/* Tool icons in help menu */
.help-modal-body .tool-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 18px;
    color: #666;
    vertical-align: middle;
}

/* Cut tool styling */
.annotation-canvas.cut-mode {
    cursor: crosshair !important;
}

.annotation-canvas.cut-placing {
    cursor: move !important;
}

/* Cut content preview styling */
.cut-preview {
    position: absolute;
    pointer-events: none;
    border: 2px dashed #0066ff;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

/* Zoom loading overlay */
.zoom-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
}

.zoom-loading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.zoom-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #14b8a6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.zoom-loading-text {
    margin-top: 16px;
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Paywall Modal Styles */
.paywall-modal-content {
    max-width: 420px;
    padding: 32px;
    position: relative;
}

.paywall-modal-content .close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
}

.paywall-header {
    text-align: center;
    margin-bottom: 24px;
}

.paywall-icon {
    font-size: 48px;
    color: #4a90e2;
    margin-bottom: 12px;
}

.paywall-header h2 {
    font-size: 24px;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.paywall-subtitle {
    color: #666;
    font-size: 14px;
}

.paywall-privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #e8f5e9;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;
    font-size: 12px;
    color: #2e7d32;
}

.paywall-privacy .material-symbols-outlined {
    font-size: 18px;
}

.paywall-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.paywall-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: #f5f5f5;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.paywall-tab.active {
    background: #4a90e2;
    color: white;
}

.paywall-tab:hover:not(.active) {
    background: #eee;
}

.paywall-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.paywall-form.hidden {
    display: none;
}

.paywall-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}

.paywall-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.paywall-btn {
    width: 100%;
    background: #4a90e2;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin-top: 8px;
}

.paywall-btn:hover {
    background: #357abd;
    transform: translateY(-1px);
}

.paywall-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.paywall-link {
    background: none;
    border: none;
    color: #4a90e2;
    font-size: 13px;
    cursor: pointer;
    padding: 8px;
    text-align: center;
}

.paywall-link:hover {
    text-decoration: underline;
}

.paywall-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.paywall-loading {
    text-align: center;
    padding: 40px 20px;
}

.paywall-loading.hidden {
    display: none;
}

.paywall-loading .spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a90e2;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.paywall-loading p {
    color: #666;
    font-size: 14px;
}

.paywall-footer {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-top: 20px;
}

/* Manage Account Modal Styles */
.manage-account-modal {
    max-width: 600px;
    padding: 0;
}

/* Tweak header for Manage Account modal: center title, remove left icon, and align close button padding */
.manage-account-modal .modal-header {
    padding: 24px;
    position: relative;
    justify-content: center;
    /* ensure header items center baseline */
}

.manage-account-modal .modal-header h3 {
    margin: 0;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
}

.manage-account-modal .modal-header .close-btn {
    position: absolute;
    right: 24px;
    top: 24px;
}

/* Center the account status badges inside the account card */
.manage-account-modal .account-status-badge {
    display: flex;
    width: fit-content;
    margin: 0 auto 20px auto;
}

.account-modal-body {
    padding: 24px;
    text-align: left;
}

.account-loading {
    text-align: center;
    padding: 40px 20px;
}

.account-loading .spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a90e2;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.account-loading p {
    color: #666;
    font-size: 14px;
}

.account-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px;
}

.account-card.company-account {
    border-color: #4caf50;
    background: linear-gradient(135deg, #f1f8e9 0%, #ffffff 100%);
}

.account-card.no-subscription {
    border-color: #ff9800;
}

.account-card.no-account,
.account-card.error-state {
    border-color: #f44336;
}

.account-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
}

.account-status-badge.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.account-status-badge.canceled {
    background: #fff3e0;
    color: #e65100;
}

.account-status-badge.inactive {
    background: #ffebee;
    color: #c62828;
}

.account-status-badge .material-symbols-outlined {
    font-size: 20px;
}

.account-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.account-detail:last-of-type {
    border-bottom: none;
}

.account-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.account-value {
    font-size: 14px;
    color: #333;
    font-weight: 600;
    text-align: right;
}

.account-value.status-active,
.account-value.status-canceled,
.account-value.status-inactive {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.active {
    background: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.status-dot.canceled {
    background: #ff9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.status-dot.inactive {
    background: #f44336;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}

.account-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.account-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.account-note .material-symbols-outlined {
    font-size: 18px;
    color: #999;
    flex-shrink: 0;
    margin-top: 1px;
}

.subscription-prompt {
    text-align: center;
    margin-top: 20px;
}

.subscription-prompt h4 {
    color: #333;
    font-size: 18px;
    margin-bottom: 8px;
}

.subscription-price {
    font-size: 32px;
    font-weight: 700;
    color: #4a90e2;
    margin: 16px 0;
}

.subscription-features {
    list-style: none;
    padding: 0;
    margin: 20px auto;
    text-align: left;
    display: inline-block;
}

.subscription-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #333;
    font-size: 14px;
}

.subscription-features li .material-symbols-outlined {
    color: #4caf50;
    font-size: 20px;
    flex-shrink: 0;
}



/* PDF Text Layer for text selection */
.text-layer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    line-height: 1.0;
    z-index: 1;
}

.text-layer>span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    line-height: 1.0;
}

.text-layer br {
    display: none;
}

.text-layer ::selection {
    background: rgba(0, 100, 255, 0.45);
}

.text-layer ::-moz-selection {
    background: rgba(0, 100, 255, 0.45);
}


/* Text Snapping Button Glow */
.text-settings-style-btn.snap-enabled {
    background: #2563EB;
    border-color: #2563EB;
    color: white;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
}

/* Text Snapping Button Base Style */
.text-settings-style-btn.snap-btn {
    width: auto;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 16px;
    position: relative;
}

/* Slow pulse animation keyframes */
@keyframes snap-pulse-blue {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
    }

    50% {
        box-shadow: 0 0 16px rgba(37, 99, 235, 0.7);
    }
}

@keyframes snap-pulse-orange {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 16px rgba(255, 152, 0, 0.7);
    }
}

/* Snap detected - blue pulse (button stays blue) */
.text-settings-style-btn.snap-btn.snap-detected {
    animation: snap-pulse-blue 1.5s ease-in-out infinite;
}

/* No snap detected - orange pulse but button stays blue */
.text-settings-style-btn.snap-btn.snap-not-detected {
    animation: snap-pulse-orange 1.5s ease-in-out infinite;
    background: #2563EB;
    border-color: #2563EB;
    color: white;
}

/* Bounce and Fall Transition Animation */
@keyframes bounceFallTransition {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    40% {
        transform: translateY(-40px) scale(1.02);
        opacity: 1;
    }

    100% {
        transform: translateY(120vh) scale(1);
        opacity: 0;
    }
}

.drop-animate .upload-area {
    animation: bounceFallTransition 0.8s ease-in-out forwards;
    pointer-events: none;
}

/* Adsterra Social Bar Positioning (Force Bottom Left) */
/* Target both div and iframe elements with the Adsterra container pattern */
#container-0d40fe21ae55d9dddf7762ef3d72e02f58878,
div[id^="container-0d40fe21ae55d9dddf7762ef3d72e02f"],
iframe[id^="container-0d40fe21ae55d9dddf7762ef3d72e02f"],
iframe[class^="container-0d40fe21ae55d9dddf7762ef3d72e02f"],
div[id^="container-"][style*="position: fixed"],
iframe[id^="container-"][style*="position: fixed"],
div[class*="adsterra"],
div[id*="adsterra"],
iframe[class*="adsterra"],
iframe[id*="adsterra"] {
    top: auto !important;
    right: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    inset: auto auto 0 0 !important;
    margin: 0 !important;
    position: fixed !important;
    z-index: 2147483647 !important;
}

/* Additional catch-all for Adsterra social bar widget */
div[style*="position: fixed"][style*="z-index: 2147483647"],
iframe[style*="position: fixed"][style*="z-index: 2147483647"] {
    top: auto !important;
    right: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    inset: auto auto 0 0 !important;
    margin: 0 !important;
}

/* Text Recognition Notification */
.text-recognition-notification {
    position: fixed;
    top: 80px;
    /* Below header */
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    z-index: 1000;
    min-width: 300px;
    max-width: 90vw;
    border-left: 4px solid var(--primary-color);
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-content .material-symbols-outlined {
    color: var(--primary-color);
    font-size: 24px;
}

.notification-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.notification-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-main);
}

.notification-progress {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.progress-bar-container {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.notification-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

.notification-close .material-symbols-outlined {
    font-size: 18px;
    color: inherit;
}

/* OCR Text Layer */
.text-layer.ocr-layer span {
    background: transparent;
}

.text-layer.ocr-layer span::selection {
    background: rgba(52, 152, 219, 0.3);
    color: transparent;
}