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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: #333;
}

header {
    background: #667eea;
    color: white;
    padding: 40px;
    text-align: center;
}

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

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 40px;
    padding: 40px;
    grid-template-areas: 
        "controls-top preview"
        "controls-bottom preview";
}

.controls-top {
    grid-area: controls-top;
}

.controls-bottom {
    grid-area: controls-bottom;
}

.preview {
    grid-area: preview;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-areas:
            "controls-top"
            "preview"
            "controls-bottom";
    }
    
    .controls-top {
        grid-area: controls-top;
    }
    
    .preview {
        grid-area: preview;
    }
    
    .controls-bottom {
        grid-area: controls-bottom;
    }
}

.controls {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    height: fit-content;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="range"] {
    width: calc(100% - 50px);
    margin-right: 10px;
}

#scale-value {
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
}

.form-group input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.generate-btn,
.download-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

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

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

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

.download-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

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

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

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

.download-btn-secondary {
    background: #17a2b8;
}

.download-btn-secondary:hover {
    background: #138496;
    box-shadow: 0 5px 20px rgba(23, 162, 184, 0.4);
}

.preview {
    display: flex;
    flex-direction: column;
}

.preview h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.8em;
}

.canvas-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 600px;
    border: 2px dashed #e0e0e0;
    position: relative;
}

#barcode-canvas {
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background: white;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: absolute;
}

.loading-indicator.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-indicator p {
    color: #667eea;
    font-weight: 600;
    font-size: 1.1em;
}

.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    border-radius: 12px;
    padding: 20px 30px;
    display: none;
    font-weight: 500;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.2);
    position: absolute;
}

.error-message.show {
    display: block;
}

.info {
    margin-top: 20px;
    padding: 20px;
    background: #e7f3ff;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info p {
    color: #555;
    line-height: 1.6;
}

footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}
