/* Bangla PDF Editor - Main Styles */

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

:root {
    --primary-color: #2563eb;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #ea580c;
    --info-color: #0891b2;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-dark: #1f2937;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'SolaimanLipi', 'Kalpurush';
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin-bottom: 60px; /* FIX: Add space for fixed status bar at bottom */
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    position: relative;
}

/* Toolbar */
.toolbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 50;
}

.toolbar-separator {
    color: #ccc;
    padding: 0 4px;
    user-select: none;
    font-weight: 300;
    align-self: center;
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#zoomLevel, #pageInfo {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #525659;
    padding: 2rem;
    padding-top: 6rem; /* FIX: Increased padding to prevent sticky toolbar from blocking PDF content (was 3rem) */
    padding-bottom: 5rem; /* FIX: Add extra bottom padding to prevent HUD from blocking PDF content */
    text-align: center;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    text-align: left;
}

#pdfCanvas {
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: none;
    max-width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

#textOverlay {
    /* Allow clicks when in add text mode */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    z-index: 10;
    overflow: visible;
}

.text-box {
    position: absolute;
    border: 2px solid transparent;
    cursor: pointer;
    pointer-events: all;
    transition: border-color 0.2s;
    min-width: 20px;
    min-height: 20px;
}

.text-box:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.text-box.selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.text-box-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    cursor: move;
    top: -10px;
    left: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.text-box-handle::before {
    content: '⋮⋮';
}

.text-box-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    margin-bottom: 8px;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.6;
}

.text-box:hover .text-box-tooltip {
    display: block;
    animation: tooltipFadeIn 0.2s ease-in;
}

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

.text-box-tooltip strong {
    color: #B0BEC5;
    font-weight: 500;
}

/* Highlight the detected font name in tooltip - shows original font even if commercial */
.text-box-tooltip .detected-font-name {
    color: #2196F3;
    font-weight: 600;
    background: rgba(33, 150, 243, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Loading Message */
.message {
    text-align: center;
    color: #e5e7eb;
}

.message h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.message p {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

/* Edit Panel */
.edit-panel {
    position: fixed;
    top: 5rem;
    right: 2rem;
    width: 340px;
    background: var(--bg-primary);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 100;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

.edit-panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
    color: white;
}

.edit-panel-header h4 {
    color: white;
}

.edit-panel-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.edit-panel-body {
    padding: 1.5rem;
}

.edit-panel-actions {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.edit-panel-actions .btn {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.edit-panel-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

#editTextArea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'SolaimanLipi', 'Kalpurush', sans-serif;
    font-size: 0.875rem;
    resize: vertical;
}

#fontSelect {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
}

#fontSize {
    width: 100px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#textColor {
    width: 60px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.style-buttons, .align-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-style {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-style:hover {
    background: var(--bg-secondary);
}

.btn-style.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Left Panel - Thumbnails */
.left-panel {
    width: 200px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
}

.left-panel h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.thumbnail-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.thumbnail {
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    padding: 0.5rem;
}

.thumbnail:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

.thumbnail-label {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Status Bar */
.status-bar {
    background: var(--bg-dark);
    color: #e5e7eb;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

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

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #0e7490;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
}

.btn-sm:hover {
    background: var(--bg-secondary);
}

.full-width {
    width: 100%;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Generic modal class */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Higher than all other elements */
}

/* When JavaScript sets display to flex, show it */
.modal[style*="display: flex"],
.modal[style*="display:flex"] {
    display: flex !important;
}

/* Note: Modal display is controlled ENTIRELY by inline styles in JavaScript */
/* No CSS display rules to avoid conflicts */

/* Show modal when active */
.modal-overlay.active,
.modal.active {
    display: flex !important;
}

/* Allow inline styles to override - MUST come after .modal base class */
.modal[style*="display: flex"],
.modal[style*="display:flex"],
.modal[style*="display: flex !important"],
.modal[style*="display:flex!important"],
.modal[style*="display: flex !important;"],
.modal[style*="display:flex !important;"] {
    display: flex !important;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Sejda-Style Floating Toolbar (2 Rows) */
.sejda-toolbar {
    position: absolute;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    font-size: 13px;
    max-width: calc(100vw - 240px); /* Account for sidebars */
}

.sejda-toolbar-2rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sejda-toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

.sejda-toolbar-row:first-child {
    border-bottom: 1px solid #e5e7eb;
}

.sejda-toolbar-row::-webkit-scrollbar {
    height: 4px;
}

.sejda-toolbar-row::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.sejda-toolbar-row::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.sejda-toolbar-row::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Text input (inline edit) */
.sejda-text-input {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    width: 180px;
    height: 28px;
}

.sejda-text-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Select dropdown */
.sejda-select {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    width: 110px;
    height: 28px;
}

.sejda-select:hover {
    border-color: #9ca3af;
}

.sejda-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Font size group */
.sejda-size-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px;
}

.sejda-input-size {
    width: 40px;
    padding: 4px;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 12px;
}

.sejda-input-size:focus {
    outline: none;
}

/* Icon buttons */
.sejda-btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #374151;
    transition: all 0.15s;
}

.sejda-btn-icon:hover {
    background: #f3f4f6;
}

.sejda-btn-icon:active {
    background: #e5e7eb;
}

/* Color picker */
.sejda-color-picker {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    background: white;
}

.sejda-color-picker:hover {
    border-color: #9ca3af;
}

/* Style buttons */
.sejda-style-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sejda-style-btn:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.sejda-style-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Divider */
.sejda-divider {
    width: 1px;
    height: 24px;
    background: #e5e7eb;
}

/* Positioning controls with value display (inline) */
.sejda-positioning-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sejda-pos-control {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #f9fafb;
    padding: 2px 6px;
    border-radius: 4px;
}

.sejda-pos-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    min-width: 14px;
}

.sejda-pos-btn-inline {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sejda-pos-btn-inline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.sejda-pos-btn-inline:active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.sejda-pos-display {
    min-width: 30px;
    padding: 3px 6px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
}

/* Action buttons */
.sejda-btn-success {
    width: 32px;
    height: 28px;
    padding: 0;
    border: none;
    background: #10b981;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sejda-btn-success:hover {
    background: #059669;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.sejda-btn-cancel {
    width: 32px;
    height: 28px;
    padding: 0;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sejda-btn-cancel:hover {
    background: #dc2626;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

/* More panel (extended options) */
.sejda-more-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 400px;
}

.sejda-more-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Textarea */
.sejda-textarea-wrapper {
    width: 100%;
}

.sejda-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

.sejda-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Positioning grid */
.sejda-positioning-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sejda-pos-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f9fafb;
    padding: 6px 8px;
    border-radius: 4px;
}

.sejda-pos-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    min-width: 24px;
}

.sejda-pos-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
}

.sejda-pos-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.sejda-pos-input {
    width: 50px;
    padding: 4px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    font-size: 11px;
    background: white;
}

/* Presets */
.sejda-presets {
    display: flex;
    gap: 6px;
}

.sejda-preset-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    transition: all 0.15s;
}

.sejda-preset-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.sejda-preset-btn:active {
    background: #e5e7eb;
}

/* Utility Classes */
.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .left-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .edit-panel {
        width: 280px;
    }
}

/* Hide left sidebar - all tools now in toolbar - DISABLED to show drawing toolbar */
/*
.sidebar,
.tool-panel {
    display: none;
}
*/

/* Make main content full width - DISABLED to show sidebar */
/*
.main-content,
.pdf-container,
#app {
    margin-left: 0 !important;
    width: 100% !important;
}
*/

/* Adjust layout for full width */
.app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px); /* Account for menu + ribbon */
}

.content-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.pdf-viewer-area {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #e5e5e5;
}

/* Force hide sidebar - DISABLED to allow drawing toolbar to show */
/* 
aside.sidebar {
    display: none;
}
*/

/* Hide sidebar completely - using ribbon interface instead */
.sidebar {
    display: none;
}

aside.left-panel {
    display: none;
}

/* Adjust main content to use full width without sidebar */
.main-container {
    margin-left: 0 !important;
}

.pdf-container {
    margin-left: 0 !important;
    width: 100% !important;
}

/* Full width layout without sidebar - DISABLED */
/*
.app-body {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}
*/

.container {
    max-width: 100% !important;
    padding: 0 20px !important;
}

/* Adjust for menu + ribbon height */
body {
    padding-top: 0;
}

.pdf-viewer {
    margin-top: 10px;
}

/* Hide old duplicate header and toolbar */
.app-header {
    display: none;
}

header.app-header {
    display: none;
}

/* Toolbar inside workspace is visible */
.workspace .toolbar {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 4px 8px;
    background: var(--toolbar-bg, #f5f5f5);
    border-bottom: 1px solid #ddd;
    min-height: 36px;
}

/* Show NEW toolbar elements */
.toolbar-container {
    display: block !important;
}

.toolbar-container .toolbar-group {
    display: flex !important;
}

/* Ensure clean layout with only new menu/ribbon */
#app {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.main-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Adjust PDF viewer to start right after ribbon */
.pdf-container {
    margin-top: 10px !important;
}

/* Progress Bar Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.progress-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    min-width: 400px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.progress-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.progress-container h3 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.progress-container p {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-percent {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Autosave Indicator Styles */
.autosave-indicator {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.autosave-indicator.saving {
    background: #fef3c7;
    color: #92400e;
    animation: pulse 1.5s infinite;
}

.autosave-indicator.saved {
    background: #d1fae5;
    color: #065f46;
}

.autosave-indicator.unsaved {
    background: #fee2e2;
    color: #991b1b;
}

.autosave-indicator.error {
    background: #fecaca;
    color: #7f1d1d;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Enhanced Upload Progress Bar */
.progress-bar {
    position: relative;
    overflow: visible;
}

.progress-fill {
    transition: width 0.3s ease;
    position: relative;
}

.progress-percent {
    font-weight: bold;
    font-size: 1.2rem;
}

#progressMessage {
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Upload speed indicator */
.upload-speed {
    color: #10b981;
    font-weight: 600;
}

.time-remaining {
    color: #f59e0b;
    font-weight: 600;
}

/* ============================================
   TOAST NOTIFICATION SYSTEM
   ============================================ */

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 420px;
}

/* Individual Toast */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    transform: translateX(120%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
    position: relative;
    overflow: hidden;
}

/* Toast Show Animation */
.toast-show {
    transform: translateX(0);
    opacity: 1;
}

/* Toast Hide Animation */
.toast-hide {
    transform: translateX(120%);
    opacity: 0;
}

/* Toast Icon */
.toast-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    line-height: 1.4;
    word-wrap: break-word;
}

.toast-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.3;
}

/* Toast Close Button */
.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: #f3f4f6;
    color: #4b5563;
}

/* Toast Action Button */
.toast-action {
    margin-top: 8px;
    padding: 6px 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.toast-action:hover {
    background: #2563eb;
}

/* Toast Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    animation: toast-progress-shrink linear forwards;
}

@keyframes toast-progress-shrink {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Toast Types */
.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-success .toast-progress {
    background: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-error .toast-progress {
    background: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-warning .toast-progress {
    background: #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-info .toast-progress {
    background: #3b82f6;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    .toast {
        background: #1f2937;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    }
    
    .toast-message {
        color: #f9fafb;
    }
    
    .toast-subtitle {
        color: #9ca3af;
    }
    
    .toast-close {
        color: #6b7280;
    }
    
    .toast-close:hover {
        background: #374151;
        color: #d1d5db;
    }
}

/* ============================================
   DARK MODE SYSTEM
   ============================================ */

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dark-mode-toggle:active {
    transform: scale(0.95);
}

/* Smooth transitions for theme switch */
html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body, .app-container, .app-header, .app-sidebar, .edit-panel, 
.modal, .status-bar, .toolbar, .canvas-container {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================================
   DARK MODE THEME
   ============================================ */

.dark-mode {
    /* Dark Mode Color Variables */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
    --border-light: #4b5563;
    
    /* Keep accent colors vibrant */
    --primary-color: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
}

/* Dark Mode Body */
.dark-mode body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Dark Mode Header */
.dark-mode .app-header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark-mode .app-header h1,
.dark-mode .app-header .title {
    color: var(--text-primary);
}

/* Dark Mode Sidebar */
.dark-mode .app-sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border-color);
}

/* Dark Mode Toolbar */
.dark-mode .toolbar {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

.dark-mode .toolbar button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.dark-mode .toolbar button:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

/* Dark Mode Canvas/PDF Viewer */
.dark-mode .canvas-container {
    background: var(--bg-tertiary);
}

.dark-mode #pdfCanvas {
    background: var(--bg-secondary);
}

/* Dark Mode Edit Panel */
.dark-mode .edit-panel {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.dark-mode .edit-panel-header {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
}

.dark-mode .edit-panel-body {
    background: var(--bg-secondary);
}

/* Dark Mode Inputs */
.dark-mode input,
.dark-mode textarea,
.dark-mode select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.dark-mode input:focus,
.dark-mode textarea:focus,
.dark-mode select:focus {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

.dark-mode input::placeholder,
.dark-mode textarea::placeholder {
    color: var(--text-tertiary);
}

/* Dark Mode Buttons */
.dark-mode button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.dark-mode button:hover:not(:disabled) {
    background: var(--bg-primary);
}

.dark-mode .btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.dark-mode .btn-primary:hover {
    background: #2563eb;
}

.dark-mode .btn-success {
    background: var(--success-color);
    color: white;
}

.dark-mode .btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Dark Mode Modals */
.dark-mode .modal {
    background: rgba(0, 0, 0, 0.8);
}

.dark-mode .modal-content {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-mode .modal-header {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
}

/* Dark Mode Status Bar */
.dark-mode .status-bar {
    background: var(--bg-secondary);
    border-top-color: var(--border-color);
}

.dark-mode #statusMessage {
    color: var(--text-secondary);
}

/* Dark Mode Progress Bar */
.dark-mode .progress-container {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-mode .progress-bar {
    background: var(--bg-tertiary);
}

/* Dark Mode Thumbnails */
.dark-mode .thumbnails {
    background: var(--bg-secondary);
}

.dark-mode .thumbnail {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.dark-mode .thumbnail:hover {
    border-color: var(--primary-color);
}

.dark-mode .thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Dark Mode Text Boxes */
.dark-mode .text-box {
    border-color: var(--border-light);
}

.dark-mode .text-box.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Dark Mode Scrollbars */
.dark-mode ::-webkit-scrollbar {
    background: var(--bg-tertiary);
}

.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Dark Mode Toast (already has support, enhance it) */
.dark-mode .toast {
    background: var(--bg-secondary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.dark-mode .toast-message {
    color: var(--text-primary);
}

.dark-mode .toast-subtitle {
    color: var(--text-secondary);
}

.dark-mode .toast-close {
    color: var(--text-tertiary);
}

.dark-mode .toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Dark Mode Autosave Indicator */
.dark-mode .autosave-indicator {
    color: var(--text-primary);
}

.dark-mode .autosave-indicator.saving {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.dark-mode .autosave-indicator.saved {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.dark-mode .autosave-indicator.unsaved {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Dark Mode Toggle Button in Dark Mode */
.dark-mode .dark-mode-toggle {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.dark-mode .dark-mode-toggle:hover {
    background: var(--bg-primary);
}

/* Dark Mode Forms and Labels */
.dark-mode label {
    color: var(--text-secondary);
}

.dark-mode .form-group {
    border-color: var(--border-color);
}

/* Dark Mode Dropdown */
.dark-mode select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Dark Mode Hr */
.dark-mode hr {
    border-color: var(--border-color);
}

/* Dark Mode Text Colors */
.dark-mode .text-muted {
    color: var(--text-tertiary);
}

.dark-mode .text-primary {
    color: var(--primary-color);
}

/* Dark Mode Links */
.dark-mode a {
    color: var(--primary-color);
}

.dark-mode a:hover {
    color: #60a5fa;
}

/* Mobile Adjustments for Dark Mode */
@media (max-width: 768px) {
    .dark-mode-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Prevent Flash of Light Mode */
html.dark-mode {
    background-color: #111827;
}

/* Logo Styles */
.header-logo {
    height: 35px;
    width: auto;
    margin-right: 0;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.header-logo:hover {
    transform: scale(1.05);
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-title h1 {
    margin: 0;
    display: inline-block;
    font-weight: 600;
}

.mobile-menu-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

/* Responsive logo sizing */
@media (max-width: 768px) {
    .header-logo {
        height: 28px;
    }
    
    .toolbar-title {
        gap: 10px;
    }
    
    .toolbar-title h1 {
        font-size: 1.1rem;
    }
    
    .mobile-menu-logo {
        max-width: 180px;
        border-radius: 8px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    }
}

@media (max-width: 480px) {
    .header-logo {
        height: 24px;
    }
    
    .toolbar-title {
        gap: 8px;
    }
    
    .toolbar-title h1 {
        font-size: 0.85rem;
        letter-spacing: 0.2px;
    }
}

/* Accessibility: Skip to content link - hidden by default, visible on focus */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 10000;
    background: var(--primary-color, #3b82f6);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
    outline: 2px solid white;
    outline-offset: -4px;
}

/* Force hide skip-to-content on all devices by default */
.skip-to-content {
    position: absolute !important;
    top: -100px !important;
    left: 0 !important;
    z-index: 10000 !important;
}

.skip-to-content:focus {
    top: 0 !important;
}


/* Crosshair Cursor Mode for Add Text */
.crosshair-mode {
    cursor: crosshair !important;
}

.crosshair-mode * {
    cursor: crosshair !important;
}

/* New Text Box Styles */
.new-text-box {
    position: absolute;
    border: 2px dashed #007bff;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px;
    min-width: 50px;
    min-height: 30px;
    cursor: move;
    z-index: 1000;
    box-sizing: border-box;
}

.new-text-box:hover {
    border-color: #0056b3;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.new-text-box.editing {
    border-color: #28a745;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.4);
}

.new-text-box-content {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    overflow: hidden;
}

/* Resize handles for new text boxes */
.new-text-box-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #007bff;
    border: 1px solid #fff;
    z-index: 1001;
}

.new-text-box-resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.new-text-box-resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.new-text-box-resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.new-text-box-resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}




#customPageNumber:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

#customPageNumber:enabled {
    background-color: white;
    border-color: #007bff;
}

/* Radio button enables input when selected */
input[name="pagePosition"][value="custom"]:checked ~ div input[type="number"] {
    border-color: #007bff;
}

/* Base Modal Styles for Add Page Modal */


}

/* Add Page Modal - Correct Display Logic */



/* =============================================================================
   ADD PAGE MODAL - Clean Implementation
   ============================================================================= */

/* Modal container - HIDDEN by default */

/* Only show when JS explicitly sets inline style */

/* Modal content styling */

/* Radio option hover effect */

/* Custom input enabled state */
#customPageNumber:enabled {
    background-color: white;
    border-color: #007bff;
}

#customPageNumber:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}
