/* Preview Panel */

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-muted);
    overflow: hidden;
    min-width: 0;
}

/* PDF Preview */

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

/* Advanced Options Toggle */
.toolbar-advanced-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 26px;
    padding: 0;
    margin: 0 0.125rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.toolbar-advanced-dots:hover {
    color: var(--text);
}

.toolbar-advanced-dots:active {
    color: var(--primary);
}

.toolbar-advanced-dots .dots-icon {
    font-size: 1.125rem;
    line-height: 1;
    letter-spacing: -0.05em;
    font-weight: 300;
    display: inline-block;
    transform: rotate(90deg);
}

/* Advanced Content */
.toolbar-advanced-content {
    display: none;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
    animation: fadeInSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar-advanced-content[style*="display: flex"],
.toolbar-advanced-content[style*="display: block"] {
    display: flex !important;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Toolbar Controls */
.toolbar-control {
    height: var(--size-sm);
    padding: 0 var(--space-2);
    font-size: var(--font-size-xs);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s, background-color 0.15s, color 0.15s; /* Specific properties only */
    flex-shrink: 0;
    box-sizing: border-box;
}

.toolbar-control:hover {
    border-color: var(--primary);
}

.toolbar-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

.toolbar-btn-text {
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    background: var(--bg-muted);
}

.toolbar-btn-text:hover {
    background: var(--bg);
    color: var(--primary);
}

.toolbar-group select.toolbar-control {
    min-width: 100px;
    max-width: 120px;
    cursor: pointer;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border-light);
    margin: 0 0.125rem;
    flex-shrink: 0;
}

/* Toolbar Title Input */
.toolbar-title-input {
    width: 80px;
    min-width: 60px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.toolbar-title-input::placeholder {
    text-transform: none;
    color: var(--text-light);
    font-weight: 400;
}

/* Toolbar Segmented Control */
.toolbar-group .segmented-control {
    height: 26px;
}

.toolbar-group .segmented-control label {
    height: 20px;
    padding: 0 0.375rem;
    font-size: 0.625rem;
}

/* Template Button */
.toolbar-template-btn {
    width: 36px;
    height: var(--input-height);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; /* Specific properties only */
}

.toolbar-template-btn:hover {
    border-color: var(--primary);
    background: var(--bg-muted);
}

.toolbar-template-btn.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.toolbar-template-btn .template-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text);
}

.toolbar-template-btn .template-icon svg {
    width: 14px;
    height: 14px;
}

/* Style Select */
.toolbar-style {
    flex-shrink: 0;
}

.toolbar-style-select {
    width: auto;
    min-width: 8rem;
    max-width: 10rem;
    height: var(--input-height);
    padding: 0 var(--space-2);
    font-size: var(--font-size-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-2) center;
    padding-right: 1.5rem;
}

.toolbar-style-select:hover {
    border-color: var(--primary);
}

.toolbar-style-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

/* Layout Dropdown */
.toolbar-layout {
    position: relative;
    flex-shrink: 0;
}

.toolbar-layout-btn {
    width: 32px;
    height: var(--input-height);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; /* Specific properties only */
}

.toolbar-layout-btn:hover {
    border-color: var(--primary);
    background: var(--bg-muted);
}

.toolbar-layout-btn.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.layout-icon {
    font-size: 1rem;
    line-height: 1;
}

.layout-dropdown {
    position: fixed;
    z-index: 1000;
    width: 200px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: var(--space-2);
}

.layout-dropdown-header {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-1);
}

.layout-module {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: var(--space-2);
}

.layout-module:hover {
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
}

.layout-module > label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.layout-module .segmented-control {
    width: 100%;
    justify-content: stretch;
}

.layout-module .segmented-control label {
    flex: 1;
    justify-content: center;
    text-align: center;
}

/* Style Picker */
.toolbar-style-picker {
    position: relative;
    flex-shrink: 0;
}

.toolbar-picker-btn {
    width: 36px;
    height: var(--input-height);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; /* Specific properties only */
}

.toolbar-picker-btn:hover {
    border-color: var(--primary);
    background: var(--bg-muted);
}

.toolbar-picker-btn.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.picker-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.font-preview {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.5px;
}

.font-preview[data-font="serif"] {
    font-family: Georgia, 'Times New Roman', serif;
}

.font-preview[data-font="mono"] {
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
}

.color-preview {
    display: flex;
    gap: 2px;
    padding: 2px;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

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

.color-dot-secondary {
    background: var(--border);
}

.element-preview {
    font-size: 1rem;
    color: var(--text);
}

/* Style Picker Dropdown */
.style-picker-dropdown {
    position: fixed;
    z-index: 2000;
    width: 220px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: var(--space-2);
}

.picker-dropdown-header {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-1) var(--space-2);
    margin-bottom: 0.375rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.375rem;
}

.picker-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.picker-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    border: 1px solid transparent;
}

.picker-option:hover {
    background: var(--bg-muted);
}

.picker-option.selected {
    background: var(--primary-subtle);
    border-color: var(--primary);
}

.picker-option-preview {
    flex-shrink: 0;
    width: 32px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
}

.picker-option-preview.font-opt-preview {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text);
}

.picker-option-preview.font-opt-preview[data-family="times"] {
    font-family: Georgia, 'Times New Roman', serif;
}

.picker-option-preview.font-opt-preview[data-family="courier"] {
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
}

.picker-option-preview.font-opt-preview[data-family="helvetica"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

.picker-option-preview.color-opt-preview {
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: none;
    border: 1px solid var(--border);
}

.picker-option-preview.color-opt-preview .color-swatch {
    flex: 1;
    height: 100%;
}

.color-swatch-bg {
    width: 10px;
}

.picker-option-preview.element-opt-preview {
    font-size: 1rem;
    color: var(--text);
}

.picker-option-info {
    flex: 1;
    min-width: 0;
}

.picker-option-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text);
    line-height: 1.2;
}

.picker-option-desc {
    font-size: 0.625rem;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-option-check {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: var(--font-size-md);
    opacity: 0;
    flex-shrink: 0;
}

.picker-option.selected .picker-option-check {
    opacity: 1;
}

/* Size Input */
.toolbar-size {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

.toolbar-size-input {
    width: 3.5rem;
    text-transform: uppercase;
    text-align: center;
    font-size: var(--font-size-sm);
}

.toolbar-size .custom-size-controls {
    display: flex;
    gap: 0.125rem;
    align-items: center;
}

.toolbar-size .custom-size-input {
    width: 2rem;
    height: 26px;
    padding: 0 0.125rem;
    font-size: 0.625rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.toolbar-size .custom-size-controls span {
    font-size: 0.5rem;
    color: var(--text-muted);
}

.toolbar-size .custom-unit-select {
    width: 2rem;
    height: 26px;
    padding: 0;
    font-size: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

/* Logo Upload in Toolbar */
.toolbar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

.toolbar-logo .logo-preview-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-logo .logo-preview {
    max-width: 40px;
    max-height: 22px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    padding: 1px;
}

.toolbar-logo .btn-remove-logo {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    font-size: 0.625rem;
}

.logo-upload-container {
    display: inline-block;
    min-height: var(--input-height);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.logo-preview-wrap {
    position: relative; /* For absolute positioned remove button */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 0;
    height: var(--input-height); /* Match other form elements */
}

.logo-preview-wrap.logo-hidden {
    display: none;
}

.logo-preview {
    max-width: 100%;
    max-height: var(--input-height); /* Match container height */
    object-fit: contain;
    border-radius: var(--radius-sm);
}

/* PDF Preview Container */
#pdf-preview {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pdf-preview-container {
    position: relative;
    padding: 0;
    overflow: hidden; /* Prevent scrollbars - zoom/pan is handled by JS */
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    background: var(--bg-muted);
}

/* Canvas wrapper for pdf.js rendering - scrollable container */
.pdf-canvas-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: auto; /* Allow both scroll directions when zoomed */
    touch-action: pan-x pan-y pinch-zoom; /* Allow pan and pinch-zoom gestures */
    padding: 20px 0;
    margin: 0;
    box-sizing: border-box;
    scroll-behavior: auto; /* Immediate scroll for zooming */
}

/* Content wrapper for zoom scaling */
.pdf-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    transform-origin: top center;
    will-change: transform;
    /* No transition for OS-like immediate pinch-zoom response */
}

/* PDF preview canvas (pdf.js rendered) */
.pdf-preview-canvas {
    display: block;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    flex-shrink: 0;
    /* Canvas dimensions are set dynamically by JavaScript */
}

/* Loading indicator */
.pdf-preview-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    z-index: 5;
}

/* Legacy iframe styles (kept for fallback) */
.pdf-preview-container iframe {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    background: transparent;
    flex-shrink: 0;
}

/* Responsive Toolbar */
@media (max-width: 1200px) {
    .preview-toolbar {
        gap: var(--space-1);
        padding: var(--space-1) 0.375rem;
    }
    
    .toolbar-control {
        height: 24px;
        padding: 0 0.375rem;
        font-size: 0.625rem;
    }
    
    .toolbar-group .segmented-control {
        height: 24px;
    }
    
    .toolbar-group .segmented-control label {
        height: 18px;
        padding: 0 var(--space-1);
        font-size: 0.5625rem;
    }
    
    .toolbar-title-input {
        width: 70px;
        min-width: 50px;
    }
    
    .toolbar-style-select {
        min-width: 6rem;
        max-width: 8rem;
        font-size: 0.625rem;
    }
    
    .toolbar-size-input {
        width: 3rem;
        font-size: var(--font-size-sm);
    }
    
    .toolbar-export-btn {
        height: 24px;
        padding: 0 var(--space-2);
        font-size: 0.625rem;
    }
    
    .toolbar-separator {
        height: 16px;
    }
}

