/* CV Editor Styles */

/* Configuration Toolbar - Desktop App Style */
.configuration-toolbar {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    color: #64748b;
    border-radius: 4px;
    transition: all 150ms ease-in-out;
    cursor: pointer;
    border: none;
    background: transparent;
}

.toolbar-btn:hover {
    color: #1e293b;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

/* View Mode Toggle Specific Styling */
.view-mode-toggle {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.view-mode-toggle button {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    transition: all 150ms ease-in-out;
    cursor: pointer;
}

.view-mode-toggle button:disabled {
    cursor: default;
}

.view-mode-toggle button.active-edit {
    background: #3b82f6;
    color: white;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.view-mode-toggle button.active-preview {
    background: #10b981;
    color: white;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.view-mode-toggle button:not(:disabled):hover {
    background: #f3f4f6;
}

/* Toolbar Separators */
.toolbar-separator {
    width: 1px;
    height: 16px;
    background: #d1d5db;
    margin: 0 8px;
}

/* CV Selection Button */
.cv-selection-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 13px;
    transition: all 150ms ease-in-out;
    cursor: pointer;
}

.cv-selection-btn:hover {
    background: #bfdbfe;
}

.cv-selection-btn .cv-info {
    text-align: left;
}

.cv-selection-btn .cv-name {
    font-weight: 500;
    color: #1e40af;
}

.cv-selection-btn .cv-job {
    font-size: 11px;
    color: #1d4ed8;
}

/* Split Block Styling - Clear and Intuitive */
.cv-block-wrapper.split-block {
    position: relative;
}

/* Enhanced visual separation for split blocks */
.cv-block-wrapper.split-first {
    margin-bottom: 2px !important;
    position: relative !important;
    border: 2px solid #f59e0b !important;
    border-radius: 8px !important;
    background: rgba(245, 158, 11, 0.03) !important;
}

.cv-block-wrapper.split-intermediate {
    border-radius: 8px !important;
    margin: 2px 0 !important;
    position: relative !important;
    border: 2px dashed #f59e0b !important;
    background: rgba(245, 158, 11, 0.05) !important;
    opacity: 0.8 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.cv-block-wrapper.split-last {
    border-radius: 8px !important;
    margin-top: 2px !important;
    position: relative !important;
    border: 2px dashed #f59e0b !important;
    background: rgba(245, 158, 11, 0.05) !important;
    opacity: 0.8 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* Split indicators using pseudo-elements - much cleaner positioning */

/* Split indicators - positioned independently of text size */
.cv-block-wrapper.split-first::after {
    content: var(--split-continues-next);
    position: absolute;
    right: 100%;
    top: -16px;
    margin-right: 20px;
    background: rgba(245, 158, 11, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    z-index: 12;
    white-space: nowrap;
    transform: rotate(-90deg);
    transform-origin: right center;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    text-align: center;
}

.cv-block-wrapper.split-intermediate::after {
    content: var(--split-continued-both);
    position: absolute;
    top: 50%;
    transform: translateX(-15px) translateY(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    background: rgba(245, 158, 11, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    z-index: 12;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    text-align: center;
    width: 30px;
    display: flex;
    align-items: center;
}

.cv-block-wrapper.split-last::after {
    content: var(--split-continued-previous);
    position: absolute;
    left: -6px;
    bottom: -2px;
    background: rgba(245, 158, 11, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    z-index: 12;
    white-space: nowrap;
    transform: rotate(-90deg);
    transform-origin: 0 100%;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    text-align: center;
}

/* Hover effects */
.cv-block-wrapper.split-first:hover {
    border-color: #d97706 !important;
    background: rgba(245, 158, 11, 0.08) !important;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2) !important;
}

.cv-block-wrapper.split-intermediate:hover,
.cv-block-wrapper.split-last:hover {
    border-color: #d97706 !important;
    background: rgba(245, 158, 11, 0.1) !important;
}

/* Lock indicator for non-draggable blocks using CSS variables */
.cv-block-wrapper.split-intermediate:hover::after,
.cv-block-wrapper.split-last:hover::after {
    content: var(--split-cannot-move) !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    z-index: 25;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Zone restrictions when dragging */
body.cv-dragging .cv-zone:has(.split-intermediate:only-child),
body.cv-dragging .cv-zone:has(.split-last:only-child) {
    border: 3px dashed #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.08) !important;
    position: relative;
}

.cv-zone .drop-restriction-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    z-index: 20;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    display: none;
}

body.cv-dragging .cv-zone:has(.split-intermediate:only-child) .drop-restriction-indicator,
body.cv-dragging .cv-zone:has(.split-last:only-child) .drop-restriction-indicator {
    display: block;
}

/* Enhanced drop zone feedback */
body.cv-dragging .cv-zone.zone-droppable {
    border: 3px solid #10b981 !important;
    background-color: rgba(16, 185, 129, 0.05) !important;
}

body.cv-dragging .cv-zone.zone-not-droppable {
    border: 3px dashed #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

/* Page indicators for split blocks */
.cv-page-wrapper {
    position: relative;
}

.cv-page-wrapper .page-split-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(245, 158, 11, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    z-index: 5;
    display: none;
}

.cv-page-wrapper:has(.split-block) .page-split-indicator {
    display: block;
}

/* Connection lines between split blocks */
.cv-block-wrapper.split-block.split-start {
    margin-bottom: 8px;
}

.cv-block-wrapper.split-block.split-middle {
    margin: 8px 0;
}

.cv-block-wrapper.split-block.split-end {
    margin-top: 8px;
}

/* Shake animation for restricted drag attempts */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* Main Layout */
.cv-editor {
    --primary-color: #2B4C8C;
    --secondary-color: #E5E7EB;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --error-color: #EF4444;
    --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;
}

.cv-editor-container {
    height: calc(100vh - 120px);
    overflow: hidden;
    background: var(--gray-50);
}

.cv-editor-sidebar {
    background: white;
    border-right: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.cv-editor-panel {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) var(--gray-100);
}

.cv-editor-panel::-webkit-scrollbar {
    width: 6px;
}

.cv-editor-panel::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.cv-editor-panel::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.cv-editor-panel::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Tab Navigation */
.cv-editor .tab-nav {
    border-bottom: 1px solid var(--gray-200);
}

.cv-editor .tab-button {
    position: relative;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.cv-editor .tab-button:hover {
    color: var(--gray-700);
    border-bottom-color: var(--gray-300);
}

.cv-editor .tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(43, 76, 140, 0.05);
}

/* Layout Selector */
.layout-selector .layout-preview {
    height: 64px;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    background: white;
    overflow: hidden;
    position: relative;
}

.layout-selector .layout-preview.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.layout-selector .layout-item {
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-selector .layout-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Style Customizer */
.style-customizer .preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.style-customizer .preset-item {
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.style-customizer .preset-item:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.style-customizer .preset-item.selected {
    border-color: var(--primary-color);
    background: rgba(43, 76, 140, 0.05);
}

.style-customizer .color-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    display: flex;
    overflow: hidden;
}

.style-customizer .color-swatch.selected {
    border-color: var(--gray-800);
    box-shadow: 0 0 0 2px var(--gray-800);
}

/* Color Picker */
.color-picker {
    position: relative;
}

.color-picker .color-preview {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-picker .color-preview:hover {
    transform: scale(1.05);
}

.color-picker .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.color-picker .preset-colors {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
}

.color-picker .preset-color {
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
    border: 2px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-picker .preset-color:hover {
    transform: scale(1.1);
}

.color-picker .preset-color.selected {
    border-color: var(--gray-800);
}

/* Range Slider */
.range-slider {
    --slider-height: 0.5rem;
    --thumb-size: 1rem;
    --track-color: var(--gray-200);
    --fill-color: var(--primary-color);
    --thumb-color: white;
    --thumb-border: var(--primary-color);
}

.range-slider .slider-track {
    height: var(--slider-height);
    background: var(--track-color);
    border-radius: calc(var(--slider-height) / 2);
    position: relative;
    overflow: hidden;
}

.range-slider .slider-fill {
    height: 100%;
    background: var(--fill-color);
    border-radius: inherit;
    transition: width 0.2s ease;
}

.range-slider .slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--slider-height);
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.range-slider .slider-thumb {
    position: absolute;
    top: 50%;
    width: var(--thumb-size);
    height: var(--thumb-size);
    background: var(--thumb-color);
    border: 2px solid var(--thumb-border);
    border-radius: 50%;
    transform: translateY(-50%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    pointer-events: none;
}

.range-slider:hover .slider-thumb,
.range-slider.dragging .slider-thumb {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.range-slider.dragging .slider-thumb {
    box-shadow: 0 0 0 4px rgba(43, 76, 140, 0.1);
}

/* Section Manager */
.section-manager .section-item {
    transition: all 0.2s ease;
}

.section-manager .section-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-manager .section-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.section-manager .drag-handle {
    cursor: grab;
}

.section-manager .drag-handle:active {
    cursor: grabbing;
}

.section-manager .section-actions button {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.section-manager .section-item:hover .section-actions button {
    opacity: 1;
}

/* CV Preview */
.cv-preview {
    background: var(--gray-100);
}

.cv-preview .preview-toolbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cv-preview .view-mode-selector {
    background: var(--gray-100);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.cv-preview .view-mode-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.cv-preview .view-mode-button.active {
    background: white;
    color: var(--gray-900);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cv-preview .preview-container {
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    overflow: hidden;
}

.cv-preview iframe {
    border: none;
    width: 100%;
    height: 100%;
    background: white;
    transition: transform 0.2s ease;
}

/* Ensure iframe containers take full dimensions */
.cv-preview-container {
    width: 100%;
    height: 100%;
    min-height: 600px; /* Minimum height for usability */
}

/* For desktop view, ensure full width */
.cv-preview-container:not(.max-w-sm):not(.max-w-2xl) {
    width: 100% !important;
    max-width: none !important;
}

.cv-editor .flex-1 {
    min-height: 0; /* Allow flexbox to shrink */
}

/* Loading States */
.cv-editor-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cv-editor-loading .spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Save Indicator */
.cv-editor-save-indicator {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    transition: opacity 0.3s ease;
    opacity: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cv-editor-container {
        height: auto;
        min-height: calc(100vh - 120px);
    }
    
    .cv-editor {
        flex-direction: column;
    }
    
    .cv-editor-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
}

@media (max-width: 768px) {
    .cv-editor-sidebar {
        width: 100%;
    }
    
    .style-customizer .preset-grid {
        grid-template-columns: 1fr;
    }
    
    .color-picker .preset-colors {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .cv-preview .view-mode-selector {
        flex-wrap: wrap;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .cv-editor {
        --gray-50: #1F2937;
        --gray-100: #374151;
        --gray-200: #4B5563;
        --gray-300: #6B7280;
        --gray-400: #9CA3AF;
        --gray-500: #D1D5DB;
        --gray-600: #E5E7EB;
        --gray-700: #F3F4F6;
        --gray-800: #F9FAFB;
        --gray-900: #FFFFFF;
    }
}

/* Print Styles */
@media print {
    .cv-editor-sidebar,
    .cv-preview .preview-toolbar,
    .cv-editor-loading {
        display: none !important;
    }
    
    .cv-editor {
        height: auto !important;
    }
    
    .cv-preview iframe {
        height: auto !important;
        min-height: auto !important;
    }
}

/* Accessibility */
.cv-editor button:focus,
.cv-editor input:focus,
.cv-editor select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.cv-editor [aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animations */
.cv-editor .fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.cv-editor .slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Utility Classes */
.cv-editor .drag-over {
    background: rgba(43, 76, 140, 0.1);
    border: 2px dashed var(--primary-color);
}

.cv-editor .highlight {
    background: rgba(43, 76, 140, 0.1);
    border-radius: 0.25rem;
    animation: highlight 0.5s ease-in-out;
}

@keyframes highlight {
    0% { background: rgba(43, 76, 140, 0.3); }
    100% { background: rgba(43, 76, 140, 0.1); }
}
