/* ================================================
   PDF Editor - Premium Styles
   ================================================ */

:root {
    /* Colors */
    --color-bg-primary: #0a0a1a;
    --color-bg-secondary: #111127;
    --color-bg-card: rgba(17, 17, 39, 0.8);
    --color-bg-toolbar: rgba(17, 17, 39, 0.95);

    --color-text-primary: #f8fafc;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;

    --color-accent-primary: #6366f1;
    --color-accent-secondary: #8b5cf6;
    --color-accent-tertiary: #ec4899;

    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;

    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--color-text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color var(--transition-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width var(--transition-normal);
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Main Content */
.main-content {
    min-height: 100vh;
}

/* Upload Section */
.upload-section {
    padding: 8rem 1.5rem 4rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 100px;
    font-size: 0.875rem;
    color: var(--color-accent-primary);
    margin-bottom: 1.5rem;
}

.badge-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

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

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.hero-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.title-line {
    display: block;
    color: var(--color-text-primary);
}

.title-gradient {
    display: block;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

/* Upload Card */
.upload-card {
    background: var(--color-bg-card);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    backdrop-filter: blur(20px);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.dropzone {
    position: relative;
    padding: 3rem 2rem;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.dropzone:hover {
    transform: translateY(-2px);
}

.dropzone.drag-over .dropzone-border {
    border-color: var(--color-accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.dropzone-border {
    position: absolute;
    inset: 0;
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: var(--border-radius-md);
    transition: all var(--transition-normal);
}

.upload-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: 50%;
    animation: bounce 2s infinite;
}

.upload-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

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

.dropzone-title {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
}

.dropzone-subtitle {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-top: 2.5rem;
}

.feature-card {
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--border-radius-md);
    text-align: center;
    transition: all var(--transition-normal);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.4);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.feature-description {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Editor Section */
.editor-section {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: 64px;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--color-bg-toolbar);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tool-divider {
    width: 1px;
    height: 24px;
    background: rgba(99, 102, 241, 0.3);
    margin: 0 0.5rem;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-secondary);
}

.tool-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-text-primary);
}

.tool-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.tool-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.file-name-display {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.color-picker {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
}

.font-size-select,
.stroke-width-select,
.export-quality-select {
    height: 40px;
    padding: 0 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.font-size-select:focus,
.stroke-width-select:focus,
.export-quality-select:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

.save-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

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

.save-btn svg {
    width: 18px;
    height: 18px;
}

/* Page Navigation */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    flex-shrink: 0;
}

.page-btn,
.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover,
.zoom-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--color-text-primary);
}

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

.page-btn svg {
    width: 16px;
    height: 16px;
}

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

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 2rem;
    padding-left: 2rem;
    border-left: 1px solid rgba(99, 102, 241, 0.2);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    overflow: auto;
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#pdfCanvas,
#annotationCanvas {
    display: block;
}

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

/* Text Input Overlay */
.text-input-overlay {
    position: fixed;
    z-index: 1000;
    background: var(--color-bg-card);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
}

.text-input-overlay textarea {
    width: 250px;
    min-height: 80px;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: both;
}

.text-input-overlay textarea:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

.text-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.text-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.text-btn.cancel {
    background: transparent;
    color: var(--color-text-secondary);
}

.text-btn.cancel:hover {
    color: var(--color-text-primary);
}

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

.text-btn.confirm:hover {
    background: var(--color-accent-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(10px);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--color-accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--color-text-secondary);
    font-size: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }

    .nav-links {
        gap: 1rem;
        font-size: 0.85rem;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .toolbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .tool-divider {
        display: none;
    }

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

/* ================================================
   New Editor Layout (Server-Side)
   ================================================ */

.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
}

.thumbnail-sidebar {
    width: 180px;
    background: var(--color-bg-secondary);
    border-right: 1px solid rgba(99, 102, 241, 0.2);
    overflow-y: auto;
    padding: 1rem 0.5rem;
}

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

.thumbnail {
    position: relative;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    background: var(--color-bg-card);
}

.thumbnail:hover {
    border-color: var(--color-accent-primary);
    transform: scale(1.02);
}

.thumbnail.active {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.thumbnail.dragging {
    opacity: 0.5;
}

.thumbnail.drag-over {
    border-color: var(--color-success);
}

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

.thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: var(--color-text-primary);
    text-align: center;
    font-size: 0.75rem;
    padding: 0.25rem;
}

.page-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
    overflow: hidden;
}

.page-nav-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--color-bg-toolbar);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.page-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 2rem;
}

.page-image-container img {
    max-width: 100%;
    max-height: 100%;
    box-shadow: var(--shadow-lg);
    border-radius: var(--border-radius-sm);
}

/* Responsive adjustments for editor layout */
@media (max-width: 768px) {
    .editor-layout {
        flex-direction: column;
    }

    .thumbnail-sidebar {
        width: 100%;
        height: 120px;
        border-right: none;
        border-bottom: 1px solid rgba(99, 102, 241, 0.2);
        overflow-x: auto;
        overflow-y: hidden;
    }

    .thumbnail-strip {
        flex-direction: row;
        height: 100%;
    }

    .thumbnail {
        min-width: 80px;
        height: 100%;
    }
}