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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f6;
    overflow: hidden;
}

#root {
    width: 100%;
    height: 100vh;
}

#main-container {
    display: flex;
    height: 100%;
    gap: 15px;  /* Increased gap */
    padding: 10px;
}

#canvas-section {
    flex: 1;
    min-width: 0;  /* Allow it to shrink if needed */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

#canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #fafafa;
    background-image: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#canvas-container {
    position: relative;
    display: inline-block;
    transform-origin: top left;
    background: white;
}

#background-image {
    max-width: none;
    height: auto;
}

#drawing-canvas {
    position: relative;
    z-index: 10;  /* Ensure canvas is on top */
    cursor: crosshair;
    display: block;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#controls {
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

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

.zoom-controls {
    border-left: 1px solid #ddd;
    padding-left: 15px;
}

#controls button {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

#controls button:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#controls button:active {
    transform: translateY(0);
}

#controls button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

#undo-btn {
    background: #2196F3;
}

#undo-btn:hover:not(:disabled) {
    background: #1976D2;
}

#redo-btn {
    background: #FF9800;
}

#redo-btn:hover:not(:disabled) {
    background: #F57C00;
}

#zoom-in-btn, #zoom-out-btn {
    background: #9C27B0;
    padding: 8px 12px;
    min-width: auto;
}

#zoom-in-btn:hover:not(:disabled), 
#zoom-out-btn:hover:not(:disabled) {
    background: #7B1FA2;
}

#zoom-reset-btn {
    background: #607D8B;
    padding: 8px 12px;
    font-size: 16px;
    min-width: auto;
}

#zoom-reset-btn:hover {
    background: #455A64;
}

#zoom-level {
    padding: 6px 10px;
    background: #e3f2fd;
    border-radius: 4px;
    font-size: 13px;
    color: #1976D2;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

#status-info {
    margin-left: auto;
    padding: 6px 12px;
    background: #e3f2fd;
    border-radius: 4px;
    font-size: 13px;
    color: #1976D2;
    font-weight: 500;
}

/* Properties Panel Styles - LARGER SIZE */
#properties-panel {
    width: 400px;  /* Increased from 320px */
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    transition: all 0.3s ease;
}

#properties-panel.themed {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;  /* More padding */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    transition: background 0.3s ease;
}

.panel-header h3 {
    margin: 0;
    font-size: 20px;  /* Larger */
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;  /* Larger */
    cursor: pointer;
    padding: 0;
    width: 36px;  /* Bigger */
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;  /* More padding */
    background: transparent;
}

.property-section {
    margin-bottom: 20px;  /* More spacing */
    padding: 18px;  /* More padding */
    border-radius: 8px;
    transition: all 0.2s ease;
    background: rgba(248, 249, 250, 0.5);
}

.property-section:last-child {
    margin-bottom: 0;
}

.property-section:hover {
    transform: translateX(2px);
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 10px;  /* More gap between label and input */
}

.property-group label {
    font-size: 14px;  /* Larger */
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.property-group input,
.property-group select,
.property-group textarea {
    padding: 12px 14px;  /* More padding */
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;  /* Larger text */
    transition: all 0.2s;
    background: white;
}

/* Hover effects for better interactivity */
.property-group input:hover:not(:focus):not(.readonly-field),
.property-group select:hover:not(:focus),
.property-group textarea:hover:not(:focus) {
    border-color: #b0b0b0;
}

/* Better focus states */
.property-group input:focus,
.property-group select:focus,
.property-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);  /* Bigger focus ring */
    transform: translateY(-1px);  /* Subtle lift effect */
}

.property-group textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 100px;  /* Taller textarea */
    line-height: 1.5;  /* Better line spacing */
}

/* Make select dropdown bigger and clearer */
.property-group select {
    font-size: 15px;
    padding: 12px 14px;
    cursor: pointer;
}

.property-group select option {
    padding: 8px;
    font-size: 14px;
}

.readonly-field {
    background-color: #e9ecef !important;  /* Darker grey background */
    cursor: not-allowed !important;
    color: #495057 !important;  /* Darker grey text */
    border-color: #ced4da !important;  /* Grey border */
    font-weight: 500;  /* Make ID stand out */
    opacity: 0.8;  /* Slightly transparent to emphasize non-editable */
}

/* Add hover state to reinforce non-editable nature */
.readonly-field:hover {
    background-color: #e9ecef !important;  /* Stay grey on hover */
    border-color: #ced4da !important;  /* Keep grey border */
}

/* Override focus state for readonly field */
.property-group input.readonly-field:focus {
    outline: none;
    border-color: #ced4da !important;  /* Keep grey border even on focus */
    box-shadow: none !important;  /* Remove focus shadow */
    transform: none !important;  /* No lift effect */
    background-color: #e9ecef !important;  /* Keep grey background */
}

/* Coordinates Section */
.coordinates-section {
    background: rgba(248, 249, 250, 0.8);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    transition: background 0.3s ease;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.bbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.coord-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.coord-group label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    min-width: 20px;
}

.coord-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    background: #f8f9fa;
}

.size-info {
    text-align: center;
    padding: 8px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.size-info span {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.panel-footer {
    padding: 20px 24px;  /* More padding */
    background: rgba(248, 249, 250, 0.5);
    border-top: 1px solid rgba(224, 224, 224, 0.5);
    border-radius: 0 0 8px 8px;
}

.button-group {
    display: flex;
    gap: 12px;  /* More gap */
    flex-direction: column;
}

.save-btn, .reset-btn {
    width: 100%;
    padding: 14px;  /* Bigger buttons */
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;  /* Larger text */
    font-weight: 600;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.save-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.4);
    background: linear-gradient(135deg, #ff5252 0%, #d63031 100%);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Color indicator bar */
.color-indicator-bar {
    width: 100%;
    height: 5px;  /* Thicker */
    border-radius: 8px 8px 0 0;
    margin-bottom: -5px;
    animation: colorPulse 2s ease-in-out infinite;
}

@keyframes colorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Scrollbar styling */
.panel-content::-webkit-scrollbar,
#canvas-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.panel-content::-webkit-scrollbar-track,
#canvas-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb,
#canvas-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover,
#canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    #properties-panel {
        width: 350px;  /* Still reasonable on medium screens */
    }
}

@media (max-width: 768px) {
    #properties-panel {
        width: 300px;  /* Minimum comfortable width */
    }
    
    .panel-content {
        padding: 16px;
    }
    
    .panel-footer {
        padding: 16px;
    }
    
    .bbox-grid {
        grid-template-columns: 1fr;
    }
}

.mode-controls {
    background: #e8eaf6;
    padding: 4px;
    border-radius: 6px;
    gap: 4px;
}

.mode-btn {
    padding: 8px 14px !important;
    background: white !important;
    color: #666 !important;
    border: 2px solid transparent !important;
    transition: all 0.2s !important;
    position: relative;
}

.mode-btn:hover {
    background: #f5f5f5 !important;
    transform: none !important;
}

.mode-btn.active {
    background: #5c6bc0 !important;
    color: white !important;
    border-color: #5c6bc0 !important;
    box-shadow: 0 2px 8px rgba(92, 107, 192, 0.3) !important;
}

.mode-btn.active:hover {
    background: #4a5ab3 !important;
}

.mode-icon {
    font-size: 16px;
    margin-right: 2px;
}

/* Update canvas cursor for pan mode */
#drawing-canvas.pan-mode {
    cursor: grab !important;
}

#drawing-canvas.pan-mode.panning {
    cursor: grabbing !important;
}

.text-content-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ocr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.ocr-btn:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    transform: translateY(-1px);
}

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

/* Loading state - keep the same green color, just add animation */
.ocr-btn.loading {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    position: relative;
    overflow: hidden;
}

.ocr-btn.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.ocr-icon {
    font-size: 14px;
}

/* Panel title styling */
.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title span {
    font-size: 14px;
    font-weight: 500;
}