/* =====================================================
   PDF Dark Mode Tool - Professional Styles
   ===================================================== */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --dark-bg: #1a1a2e;
    --dark-surface: #16213e;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}


/* Error Message */
.error-message {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    margin: 12px 20px;
    border-radius: var(--radius);
    border-left: 4px solid var(--danger);
    font-size: 14px;
    font-weight: 500;
}

/* Editor Layout */
.editor-layout {
    display: none;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: var(--gray-100);
}

/* Top Bar */
.editor-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.file-name {
    font-weight: 600;
    color: var(--gray-800);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    color: var(--gray-500);
}

.file-separator {
    color: var(--gray-300);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Main Area */
.editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Pages Sidebar */
.pages-sidebar {
    width: 180px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.sidebar-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

.pages-count {
    font-size: 12px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 10px;
}

.pages-grid {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.pages-grid::-webkit-scrollbar {
    width: 6px;
}

.pages-grid::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.page-thumbnail {
    cursor: pointer;
    margin-bottom: 12px;
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    background: white;
    box-shadow: var(--shadow-sm);
}

.page-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-thumbnail.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.page-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Preview Stage */
.preview-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gray-100);
}

/* Preview Toolbar */
.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    gap: 16px;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-selector label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

.mode-buttons {
    display: flex;
    gap: 4px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    transition: var(--transition);
}

.mode-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(59,130,246,0.3);
}

.mode-btn svg {
    flex-shrink: 0;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-level {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    min-width: 45px;
    text-align: center;
}

/* Canvas */
.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background: var(--gray-100);
    background-image: 
        radial-gradient(circle, var(--gray-300) 1px, transparent 1px);
    background-size: 20px 20px;
}

.canvas-stage {
    position: relative;
    display: inline-block;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: 2px;
}

[data-role="pdf-canvas"] {
    display: block;
    max-width: 100%;
}

/* Page Navigation */
.page-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: white;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    transition: var(--transition);
}

.nav-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-input-group input {
    width: 56px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.page-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.page-separator {
    color: var(--gray-400);
    font-weight: 600;
}

/* Options Panel */
.options-panel {
    width: 260px;
    background: white;
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.panel-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
}

.panel-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.option-group {
    margin-bottom: 16px;
}

.option-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.option-group input[type="range"] {
    width: 100%;
    margin: 4px 0;
}

.option-value {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 600;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-transform: none;
    font-size: 13px;
    font-weight: 500;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.option-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-700);
    background: white;
}

/* ====== Background Color Section ====== */
.color-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.color-preset {
    width: 100%;
    height: 36px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.color-preset:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.color-preset.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.color-preset.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.color-custom {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-custom input[type="color"] {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 2px;
    background: white;
}

.color-custom input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: monospace;
    color: var(--gray-700);
    text-transform: uppercase;
}

.color-custom input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Panel Actions */
.panel-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-preview,
.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-preview {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-preview:hover {
    background: var(--gray-200);
}

.btn-download {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Progress Overlay */
.progress-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.progress-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    min-width: 320px;
    box-shadow: var(--shadow-lg);
}

.spinner {
    animation: spin 1s linear infinite;
    color: var(--primary);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.progress-message {
    margin: 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.progress-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    width: 0%;
    transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 1024px) {
    .options-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
    .pages-sidebar {
        width: 140px;
    }
}

@media (max-width: 768px) {
    .editor-layout {
        height: calc(100vh - 150px);
    }
    .pages-sidebar {
        display: none !important;
    }
    .mode-selector > label {
        display: none;
    }
    .mode-btn span {
        display: none;
    }
    .upload-text {
        font-size: 20px;
    }
    .color-presets {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .preview-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .mode-buttons {
        flex-wrap: wrap;
    }
    .zoom-controls {
        width: 100%;
        justify-content: center;
    }
    .options-panel {
        width: 100%;
    }
}