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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

section {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Upload Section */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--background);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--secondary-color);
    margin-bottom: 16px;
}

.upload-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* Preview Section */
.preview-container {
    text-align: center;
}

.image-preview {
    max-width: 100%;
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.image-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Controls Section */
.dimensions-controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.dimension-input {
    flex: 1;
}

.dimension-input label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.dimension-input input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.dimension-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Lock Button */
.lock-button {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.lock-button:hover {
    background: var(--background);
}

.lock-button.locked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.lock-button.locked .lock-icon {
    color: white;
}

.lock-icon {
    width: 24px;
    height: 24px;
    color: var(--secondary-color);
}

/* Aspect Ratio Info */
.aspect-ratio-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 20px;
}

.aspect-ratio-info span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.lock-status {
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.lock-status.unlocked {
    background: var(--secondary-color);
}

/* Quick Presets */
.quick-presets {
    margin-bottom: 20px;
}

.quick-presets p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.preset-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-secondary:hover {
    background: var(--background);
}

/* Output Section */
.output-preview {
    max-width: 100%;
    max-height: 400px;
    overflow: auto;
    border-radius: 8px;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    padding: 16px;
}

.output-preview canvas {
    max-width: 100%;
    max-height: 360px;
    object-fit: contain;
}

.output-info {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.download-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
}

.download-options label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.download-options select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--surface);
}

.download-options input[type="range"] {
    flex: 1;
    min-width: 100px;
}

.btn-download {
    width: 100%;
    background: var(--success-color);
    color: white;
    padding: 16px 24px;
}

.btn-download:hover {
    background: #059669;
}

.btn-download svg {
    width: 20px;
    height: 20px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 20px;
    margin-top: auto;
}

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

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header {
        padding: 24px 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    section {
        padding: 16px;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .dimensions-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .lock-button {
        width: 100%;
        height: 44px;
        order: 3;
    }

    .action-buttons {
        flex-direction: column;
    }

    .preset-buttons {
        justify-content: center;
    }

    .download-options {
        flex-direction: column;
        align-items: stretch;
    }

    .download-options input[type="range"] {
        width: 100%;
    }
}

/* Hidden utility class */
[hidden] {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

section:not([hidden]) {
    animation: fadeIn 0.3s ease;
}
