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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
    padding: 30px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.tool-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tool-btn {
    padding: 10px 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tool-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.tool-btn.active {
    background: #667eea;
    color: white;
}

.color-picker {
    width: 50px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
}

.image-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.image-selector label {
    font-weight: 600;
    color: #333;
}

#imageSelect {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

#imageSelect:focus {
    outline: none;
    border-color: #667eea;
}

.refresh-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

.canvas-container {
    position: relative;
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    background: #f0f0f0;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    display: block;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.canvas-container.empty::before {
    content: "Select an image to begin annotating";
    color: #999;
    font-size: 1.2em;
    position: absolute;
}

.annotations-list {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.annotations-list h3 {
    color: #333;
    margin-bottom: 15px;
}

.annotation-item {
    background: white;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.annotation-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.annotation-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.annotation-label {
    color: #667eea;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.annotation-label:hover {
    color: #764ba2;
}

.annotation-type {
    font-weight: 600;
    color: #333;
    min-width: 80px;
}

.annotation-label-edit {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: rgba(102, 126, 234, 0.05);
    font-size: 14px;
    transition: all 0.2s ease;
}

.annotation-label-edit:hover {
    background: white;
    border-color: #ddd;
}

.annotation-label-edit:focus {
    outline: none;
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.color-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    vertical-align: middle;
    flex-shrink: 0;
}

.delete-btn {
    padding: 5px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.clear-btn {
    background: #6c757d;
    color: white;
}

.clear-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.load-btn {
    background: #28a745;
    color: white;
}

.load-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.export-btn {
    background: #17a2b8;
    color: white;
}

.export-btn:hover {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.4);
}

.label-input {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    width: 200px;
}

.label-input:focus {
    outline: none;
    border-color: #667eea;
}

.status-message {
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    text-align: center;
    display: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Scrollbar styling */
.annotations-list::-webkit-scrollbar {
    width: 8px;
}

.annotations-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.annotations-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.annotations-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tool-group {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .label-input {
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .image-selector {
        flex-direction: column;
        align-items: stretch;
    }
}