/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --success-color: #5cb85c;
    --danger-color: #d9534f;
    --warning-color: #f0ad4e;
    --dark-bg: #2c3e50;
    --light-bg: #ecf0f1;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
header {
    background: var(--dark-bg);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: #95a5a6;
    font-size: 1rem;
}

/* Main Content */
main {
    padding: 30px;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-section.hidden {
    display: none;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 60px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--light-bg);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.upload-area.dragging {
    border-color: var(--success-color);
    background: #e8f5e9;
    transform: scale(1.02);
}

.upload-prompt {
    pointer-events: none;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.2rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.upload-hint {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Canvas Section */
.canvas-section {
    margin-top: 30px;
}

.canvas-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: auto;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#displayCanvas {
    display: block;
    max-width: 100%;
    max-height: none;
    height: auto;
    cursor: crosshair;
}

#displayCanvas.selecting {
    cursor: move;
}

#displayCanvas.resizing {
    cursor: nwse-resize;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
    z-index: 10;
}

.canvas-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loadingText {
    margin-top: 20px;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    background: var(--light-bg);
    padding: 25px;
    border-radius: 8px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-dark);
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

/* Info Panel */
.info-panel {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.info-panel p {
    margin: 5px 0;
    color: var(--text-dark);
}

/* Error Message */
.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--danger-color);
    color: white;
    padding: 15px 45px 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.error-text {
    display: block;
}

.error-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.error-close:hover {
    opacity: 0.8;
}

/* Footer */
footer {
    background: var(--light-bg);
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .controls {
        padding: 15px;
    }

    .btn {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }
}
