* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.upload-section {
    padding: 40px;
    text-align: center;
}

.file-input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-input-wrapper label {
    display: inline-block;
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.file-input-wrapper label:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

#fileName {
    display: block;
    margin-top: 15px;
    color: #666;
    font-size: 0.9em;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #764ba2;
    color: white;
}

.btn-primary:hover {
    background: #653a8a;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: #ffc107;
    color: #333;
    font-weight: 600;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.download-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.text-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.select-control {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.select-control:hover {
    border-color: #667eea;
}

.btn-tool {
    background: #f8f9fa;
    color: #333;
    padding: 8px 16px;
    margin: 0 5px;
}

.btn-tool:hover {
    background: #e2e6ea;
}

.btn-tool.active {
    background: #dc3545;
    color: white;
}

.editor-section {
    padding: 20px;
}

.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

#pageInfo {
    margin: 0 10px;
    font-weight: 600;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 20px;
}

#zoomLevel {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.canvas-container {
    position: relative;
    display: inline-block;
    background: #e9ecef;
    padding: 20px;
    border-radius: 10px;
    overflow: auto;
    max-height: 800px;
    margin: 0 auto;
}

#pdfCanvas {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    background: white;
}

#textLayer {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    z-index: 100;
}

.text-annotation {
    position: absolute;
    background: transparent;
    border: 1px dashed #999;
    padding: 2px;
    min-width: 150px;
    min-height: 30px;
    pointer-events: all;
    z-index: 1000;
    display: block;
    resize: both;
    overflow: auto;
}

.text-annotation:hover {
    border-color: #667eea;
}

.text-annotation .drag-handle {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 20px;
    height: 20px;
    background: #667eea;
    color: white;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border-radius: 3px;
    user-select: none;
    z-index: 1001;
    opacity: 0.7;
}

.text-annotation:hover .drag-handle {
    opacity: 1;
}

.text-annotation textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    outline: none;
    cursor: text;
    padding: 2px;
    font-family: Arial, sans-serif;
    display: block;
    overflow: hidden;
    line-height: 1.4;
    min-height: 25px;
}

.image-annotation {
    position: absolute;
    border: 2px dashed #999;
    overflow: visible;
    z-index: 1000;
    min-width: 50px;
    min-height: 50px;
    cursor: move;
    box-sizing: border-box;
}

.image-annotation:hover {
    border-color: #667eea;
    border-width: 2px;
}

.image-annotation img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}

.image-annotation .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-annotation .resize-handle {
    position: absolute;
    width: 15px;
    height: 15px;
    background: #667eea;
    border: 2px solid white;
    z-index: 1003;
    pointer-events: auto;
}

.image-annotation .resize-handle.top-left {
    top: -7px;
    left: -7px;
    cursor: nwse-resize;
}

.image-annotation .resize-handle.top-right {
    top: -7px;
    right: -7px;
    cursor: nesw-resize;
}

.image-annotation .resize-handle.bottom-left {
    bottom: -7px;
    left: -7px;
    cursor: nesw-resize;
}

.image-annotation .resize-handle.bottom-right {
    bottom: -7px;
    right: -7px;
    cursor: nwse-resize;
}

.text-annotation .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.message.show {
    opacity: 1;
}

.message.success {
    background: #28a745;
    color: white;
}

.message.error {
    background: #dc3545;
    color: white;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .zoom-controls {
        margin: 10px 0;
    }
}
#pdfCanvas {
  position: relative;
  z-index: 1;
}

#textLayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  z-index: 2;
}

.highlight-box {
  border: 1px solid #f7e600;
  box-sizing: border-box;
  z-index: 5;
}
.cover-rect {
    background-color: white;
    opacity: 1;
    pointer-events: none;
}

.cover-rect {
    background-color: white;
    opacity: 1;
    border: 1px solid #ccc;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}
/* === FIX: ensure text layer and cover boxes are visible above PDF === */
#textLayer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  pointer-events: auto !important;
  z-index: 1000 !important; /* higher than canvas */
}

/* make white boxes visible and draggable */
.cover-rect {
  position: absolute !important;
  background-color: rgba(255, 255, 255, 1) !important;
  border: 1px solid #999 !important;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.25) !important;
  pointer-events: auto !important;
  z-index: 1500 !important;
}
