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

body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-btn, .export-btn {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.upload-btn:hover, .export-btn:hover:not(:disabled) {
    background: #2980b9;
}

.export-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.lang-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: bold;
    min-width: 50px;
}

.lang-toggle-btn:hover {
    background: #2c3e50;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.lang-toggle-btn .lang-code {
    font-size: 0.85em;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.main-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    height: calc(100vh - 70px);
    gap: 10px;
    padding: 10px;
}

.viewer-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    padding: 15px;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    padding: 8px 12px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.nav-btn:hover:not(:disabled) {
    background: #2c3e50;
}

.nav-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.page-info {
    padding: 8px 12px;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    min-width: 100px;
    text-align: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-btn {
    padding: 8px 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

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

.marker-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.tool-btn {
    padding: 8px 12px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: #c0392b;
}

.tool-btn.active {
    background: #27ae60;
}

.pdf-viewer {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #f8f9fa;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.page-container {
    position: relative;
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: visible;
    display: inline-block;
}

.pdf-canvas {
    display: block;
    position: relative;
    z-index: 1;
}

.overlay-svg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    pointer-events: auto !important;
    z-index: 999 !important;
}

.overlay-svg.pagebreak-mode {
    cursor: crosshair !important;
}

.page-container.pagebreak-mode {
    cursor: crosshair !important;
}

.selection-marker {
    fill: rgba(46, 204, 113, 0.4) !important;
    stroke: #27ae60 !important;
    stroke-width: 2 !important;
    cursor: move !important;
    transition: all 0.2s ease;
}

.selection-marker:hover {
    fill: rgba(46, 204, 113, 0.6) !important;
}

.selection-marker.selected {
    stroke: #f39c12 !important;
    stroke-width: 2 !important;
    fill: rgba(243, 156, 18, 0.3) !important;
}

.selection-marker.preview-highlighted {
    fill: rgba(52, 152, 219, 0.8) !important;
    stroke: #2980b9 !important;
    stroke-width: 5 !important;
}

.resize-handle.preview-highlighted {
    fill: #2980b9 !important;
    opacity: 1.0 !important;
}

.resize-handle {
    fill: #27ae60 !important;
    cursor: ns-resize !important;
    opacity: 0.9 !important;
    transition: all 0.2s ease;
}

.resize-handle:hover {
    opacity: 1.0 !important;
    fill: #2ecc71 !important;
}

.resize-handle.selected {
    fill: #f39c12 !important;
}

.move-handle {
    fill: #27ae60 !important;
    opacity: 0.9 !important;
    cursor: move !important;
    transition: all 0.2s ease;
}

.move-handle:hover {
    opacity: 1.0 !important;
    fill: #2ecc71 !important;
}

.move-handle.selected {
    fill: #f39c12 !important;
}

.pagebreak-line {
    stroke: #e74c3c !important;
    stroke-width: 6 !important;
    cursor: pointer !important;
    opacity: 0.8 !important;
    transition: all 0.2s ease;
}

.pagebreak-line:hover {
    stroke: #c0392b !important;
    stroke-width: 8 !important;
    opacity: 1.0 !important;
}

.pagebreak-line.selected {
    stroke: #f39c12 !important;
    stroke-width: 8 !important;
    opacity: 1.0 !important;
}

.preview-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    padding: 15px;
    background: #2c3e50;
    color: white;
    font-weight: bold;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.preview-page {
    background: white;
    border: 1px solid #bdc3c7;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.preview-page-header {
    background: #ecf0f1;
    padding: 8px 12px;
    font-size: 0.9rem;
    color: #2c3e50;
    border-bottom: 1px solid #bdc3c7;
}

.preview-page-content {
    padding: 10px;
    display: flex;
    justify-content: center;
    position: relative;
}

.preview-canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid #ecf0f1;
}

.preview-click-area {
    transition: all 0.2s ease;
    border-radius: 4px;
}

.preview-click-area:hover {
    background-color: rgba(52, 152, 219, 0.2) !important;
    border: 2px solid #3498db !important;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #7f8c8d;
    font-size: 1.2rem;
}

.upload-area.dragover {
    background: #e3f2fd;
    color: #1976d2;
}

#fileInput {
    display: none;
}

.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 20px;
    border-radius: 8px;
    z-index: 1000;
}

.loading.show {
    display: block;
}

.no-pdf-message {
    color: #e67e22;
    background: #fef5e7;
    padding: 10px;
    border-radius: 4px;
    margin: 10px;
    text-align: center;
    border: 1px solid #f39c12;
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
    
    .preview-panel {
        max-height: 300px;
    }
    
    .header-controls {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .upload-btn, .export-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .lang-toggle-btn {
        padding: 6px 10px;
        min-width: 45px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .page-nav, .zoom-controls, .marker-tools {
        justify-content: center;
    }
    
    .marker-tools {
        margin-left: 0;
    }
}