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

:root {
    /* Colors - HSL for easy manipulation */
    --bg-primary: hsl(0, 0%, 98%);
    --bg-card: hsl(0, 0%, 100%);
    --text-primary: hsl(215, 25%, 20%);
    --text-secondary: hsl(215, 15%, 50%);
    --text-muted: hsl(215, 15%, 65%);
    
    --primary: hsl(210, 70%, 60%);
    --primary-hover: hsl(210, 70%, 55%);
    --primary-light: hsl(210, 50%, 95%);
    
    --border: hsl(210, 25%, 90%);
    --border-focus: hsl(210, 70%, 60%);
    
    --shadow-soft: 0 4px 20px -2px hsla(210, 70%, 60%, 0.12);
    --shadow-elevated: 0 8px 30px -4px hsla(210, 70%, 60%, 0.18);
    
    --gradient-primary: linear-gradient(135deg, hsl(210, 70%, 60%), hsl(210, 80%, 65%));
    
    --radius: 0.75rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 3rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.description {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-size: 1rem;
}

/* Features Section */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.feature-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    border: 1px solid var(--border);
}

.feature-card:hover {
    box-shadow: var(--shadow-elevated);
    transform: translateY(-2px);
}

.feature-icon {
    width: 3rem;
    height: 3rem;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.feature-card h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Main Card */
.main-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-elevated);
    border: 1px solid var(--border);
}

/* Step Section */
.step-section {
    margin-bottom: 2rem;
}

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

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.step-number {
    width: 2rem;
    height: 2rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.step-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

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

.upload-area.drag-over {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

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

.upload-icon {
    width: 4rem;
    height: 4rem;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
}

.upload-text {
    color: var(--text-secondary);
    margin-top: 1rem;
    font-size: 0.875rem;
}

.upload-formats {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* Image Preview */
.image-preview {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.image-preview img {
    width: 100%;
    height: 16rem;
    object-fit: contain;
    background-color: var(--primary-light);
}

.btn-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: hsl(0, 70%, 60%);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background: hsl(0, 70%, 55%);
    transform: scale(1.1);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.select-input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 0.25rem);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.select-input:hover {
    border-color: var(--border-focus);
}

.select-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px hsla(210, 70%, 60%, 0.1);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: calc(var(--radius) - 0.25rem);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-large {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* Progress Section */
.progress-section {
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.progress-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#progress-status {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: var(--primary-light);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percent {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Output Section */
.output-section {
    margin-top: 2rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.output-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.output-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.output-textarea {
    width: 100%;
    min-height: 18rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 0.25rem);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
}

.output-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px hsla(210, 70%, 60%, 0.1);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: calc(var(--radius) - 0.25rem);
    box-shadow: var(--shadow-elevated);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 20rem;
}

.toast.error {
    background: hsl(0, 70%, 60%);
}

.toast.success {
    background: hsl(142, 71%, 45%);
}

@keyframes slideIn {
    from {
        transform: translateX(calc(100% + 2rem));
    }
    to {
        transform: translateX(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

    .main-card {
        padding: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .output-actions {
        width: 100%;
    }

    .output-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}
