/* CSS Variables */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-color: #ffffff;
    --surface-color: #f9fafb;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa;
        --primary-hover: #3b82f6;
        --bg-color: #111827;
        --surface-color: #1f2937;
        --border-color: #374151;
        --text-color: #f9fafb;
        --text-secondary: #d1d5db;
        --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    }
}

/* PDF Editor Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Upload Section */
.upload-section {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--surface-color));
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
}

header h1 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 3rem;
    font-weight: 700;
}

header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.tutorial-button {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    margin-bottom: 2rem;
}

.tutorial-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

/* Usage Documentation Styles */
.usage-documentation {
    margin-bottom: 3rem;
    text-align: left;
}

.usage-toggle {
    background: linear-gradient(135deg, var(--surface-color), var(--bg-color));
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 2rem;
    width: 100%;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.usage-toggle:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.usage-toggle::after {
    content: '▼';
    transition: transform 0.3s ease;
    margin-left: 0.5rem;
}

.usage-toggle.active::after {
    transform: rotate(180deg);
}

.usage-content {
    margin-top: 1.5rem;
    background: var(--surface-color);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.usage-section {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.usage-section:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.usage-section h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.usage-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-size: 0.9rem;
}

.tools-guide {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tools-guide h3 {
    color: var(--text-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.tool-list {
    display: grid;
    gap: 0.75rem;
}

.tool-item {
    padding: 0.75rem;
    background: var(--surface-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

.tool-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tool-item strong {
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 0.5rem;
}

.tool-item span {
    color: var(--text-secondary);
    line-height: 1.5;
}

.features-list {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--surface-color));
    border-radius: 12px;
    border: 1px solid var(--primary-color);
}

.features-list h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.features-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.features-list li {
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.95rem;
}

.features-list li::before {
    content: '⭐';
    position: absolute;
    left: 0;
    top: 0;
}

.features-list li:last-child {
    margin-bottom: 0;
}

/* Quick Start Card */
.quick-start {
    margin-bottom: 2rem;
}

.quick-start-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(var(--primary-color-rgb), 0.3);
}

.quick-start-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
    font-weight: 700;
}

.quick-start-card p {
    margin: 0;
    opacity: 0.9;
    font-size: 1rem;
}

/* Help Button */
.help-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    height: 44px;
    white-space: nowrap;
}

.help-btn .help-text {
    font-size: 0.875rem;
    font-weight: 500;
}

.help-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.help-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Floating Window Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    pointer-events: none; /* Allow clicks through the overlay */
}

.modal-content {
    position: absolute;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 600px;
    height: 400px;
    min-width: 400px;
    min-height: 300px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: windowSlideIn 0.3s ease-out;
    pointer-events: auto; /* Allow clicks on the window */
    resize: both; /* Make window resizable */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes windowSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-header {
    background: var(--surface-color);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move; /* Indicate draggable */
    user-select: none;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.modal-body {
    padding: 0;
    height: calc(100% - 60px); /* Account for header */
    overflow-y: auto;
    background: var(--bg-color);
}

/* Tutorial Tabs */
.tutorial-tabs {
    display: flex;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.tutorial-tab {
    background: none;
    border: none;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    border-bottom: 3px solid transparent;
}

.tutorial-tab:hover {
    color: var(--text-color);
    background-color: var(--bg-color);
}

.tutorial-tab.active {
    color: var(--primary-color);
    background-color: var(--bg-color);
    border-bottom-color: var(--primary-color);
}

.tutorial-content {
    padding: 2rem;
}

.tutorial-panel {
    display: none;
}

.tutorial-panel.active {
    display: block;
}

.tutorial-panel h3 {
    color: var(--text-color);
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

/* Tutorial Steps */
.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

.step-number {
    background: var(--primary-color);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.step-content h4 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.step-content p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.tool-guide-item {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.tool-guide-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.tool-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

.tool-guide-item h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.tool-guide-item p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Tips List */
.tips-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: 12px;
    border-left: 4px solid #10b981;
}

.tip-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.tip-item strong {
    color: var(--text-color);
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

.tip-item p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1rem 1.5rem;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .tutorial-tabs {
        flex-direction: column;
    }
    
    .tutorial-tab {
        padding: 0.75rem 1rem;
        text-align: left;
    }
    
    .tutorial-content {
        padding: 1.5rem;
    }
    
    .tutorial-step {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .tip-item {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    transform: scale(1.02);
}

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

.upload-icon {
    width: 5rem;
    height: 5rem;
    fill: var(--primary-color);
    margin-bottom: 1.5rem;
}

.upload-area h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.upload-area p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.supported-formats {
    font-size: 0.9rem !important;
    color: var(--text-secondary) !important;
}

/* Editor Section */
.editor-section {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
}

/* Toolbar */
.toolbar {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

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

.toolbar-separator {
    width: 1px;
    height: 2rem;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

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

.tool-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--text-color);
}

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

.tool-btn:hover svg {
    fill: white;
}

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

.tool-btn.active svg {
    fill: white;
}

.zoom-level {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-color);
}

.page-info input[type="number"] {
    width: 50px;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--text-color);
    text-align: center;
}

.save-btn,
.download-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn:hover,
.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Property Panel */
.property-panel {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.property-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.property-group label {
    color: var(--text-color);
    font-weight: 600;
    min-width: 80px;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.color-presets {
    display: flex;
    gap: 0.25rem;
}

.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.color-preset:hover {
    border-color: var(--text-color);
    transform: scale(1.1);
}

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

input[type="range"] {
    width: 100px;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.property-group span {
    min-width: 50px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
}

/* PDF Viewer */
.pdf-viewer {
    flex: 1;
    overflow: auto;
    background-color: var(--surface-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

.pdf-container {
    position: relative;
    background-color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

#pdf-canvas,
#annotation-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

#pdf-canvas {
    z-index: 1;
}

#annotation-canvas {
    z-index: 2;
    pointer-events: none;
}

#annotation-canvas.active {
    pointer-events: all;
}

/* Text Input Overlay */
.text-input-overlay {
    position: absolute;
    z-index: 3;
    background: transparent;
    border: 2px dashed var(--primary-color);
    outline: none;
    resize: none;
    font-family: Arial, sans-serif;
    line-height: 1.2;
    padding: 2px;
    min-width: 100px;
    min-height: 20px;
}

/* Selected Element */
.selected-element {
    border: 2px solid var(--primary-color) !important;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

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

.loading-overlay p {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
}

/* Reset Button */
.reset-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .toolbar {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .toolbar-group {
        gap: 0.25rem;
        padding: 0;
    }
    
    .property-panel {
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .pdf-viewer {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .toolbar {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .property-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .property-group {
        justify-content: space-between;
    }
    
    .pdf-viewer {
        padding: 0.5rem;
    }
    
    .reset-btn {
        bottom: 1rem;
        right: 1rem;
        padding: 0.75rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-icon {
        width: 3rem;
        height: 3rem;
    }
    
    .toolbar-group {
        flex-wrap: wrap;
    }
    
    .tool-btn {
        width: 32px;
        height: 32px;
    }
    
    .tool-btn svg {
        width: 16px;
        height: 16px;
    }
}

