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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* Upload Page */
.upload-container {
    max-width: 600px;
    margin: 80px auto;
    text-align: center;
    padding: 0 20px;
}

.upload-container h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.upload-container > p {
    color: #666;
    margin-bottom: 32px;
}

.upload-area {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 48px 24px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #4a90d9;
    background: #f0f7ff;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-hint {
    color: #999;
    font-size: 14px;
    margin-top: 4px;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* QR Code */
.qr-section {
    margin-top: 32px;
}

.qr-code {
    width: 160px;
    border-radius: 12px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

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

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-primary {
    background: #4a90d9;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #3a7bc8;
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-success:hover {
    background: #219a52;
}

/* Spinner */
.spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    color: #666;
}

.spinner-icon {
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Editor Layout */
.editor-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Preview Panel */
.preview-panel {
    width: 50%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
    background: #e8e8e8;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.preview-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
}

.canvas-container {
    position: relative;
    flex-shrink: 0;
}

#pdfCanvas {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: block;
    max-width: 100%;
    height: auto;
}

#highlightCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Translation Panel */
.translation-panel {
    width: 50%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

.translation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    gap: 8px;
}

.translation-header h3 {
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.blocks-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.block-item {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.block-item:hover,
.block-item.active {
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

.block-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.block-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.block-type-heading { background: #e8f4fd; color: #2980b9; }
.block-type-text { background: #eee; color: #555; }
.block-type-field_label { background: #fef5e7; color: #e67e22; }
.block-type-field_value { background: #eafaf1; color: #27ae60; }
.block-type-image { background: #fdeef0; color: #c0392b; }

.tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    background: #f0f0f0;
    color: #777;
}

.original-text {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 4px;
    font-size: 13px;
    color: #666;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}

.btn-copy-original {
    display: block;
    background: none;
    border: none;
    color: #999;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 0;
    margin-bottom: 4px;
}

.btn-copy-original:hover {
    color: #4a90d9;
}

.translation-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 36px;
    transition: border-color 0.2s;
}

.translation-input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

/* Page separator in blocks list */
.page-separator {
    text-align: center;
    padding: 8px 0;
    color: #999;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 900px) {
    .editor-layout {
        flex-direction: column;
        height: auto;
        width: 100%;
    }
    .preview-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        height: 50vh;
    }
    .translation-panel {
        width: 100%;
        height: 50vh;
    }
}
