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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --background-color: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 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);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

html {
    font-size: 16px;
}

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

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

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    flex: 1;
}

/* Sections */
section {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Control Groups */
.control-group {
    margin-bottom: 1.5rem;
}

.control-group:last-of-type {
    margin-bottom: 1.5rem;
}

/* Input Wrapper */
.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-wrapper.full-width {
    width: 100%;
}

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

.input-wrapper small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Dimension Inputs */
.dimension-inputs {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dimension-separator {
    font-size: 1.25rem;
    color: var(--text-secondary);
    padding-bottom: 0.5rem;
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

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

/* Color Inputs */
.color-inputs {
    display: flex;
    gap: 1.5rem;
}

.color-input-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--card-background);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.color-text {
    width: 90px;
    font-family: monospace;
    text-transform: uppercase;
}

/* Text Inputs */
.text-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Format Inputs */
.format-inputs {
    display: flex;
    gap: 1rem;
}

/* Form Controls */
input[type="text"],
input[type="number"],
select {
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-background);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[type="number"] {
    width: 100px;
}

select {
    cursor: pointer;
    min-width: 120px;
}

/* Buttons */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    width: 100%;
}

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

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Preview Section */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 200px;
    overflow: auto;
    margin-bottom: 1.5rem;
}

#previewCanvas {
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow-lg);
}

/* URL Section */
.url-section {
    margin-bottom: 1.5rem;
}

.url-container {
    display: flex;
    gap: 0.5rem;
}

.url-container input {
    flex: 1;
    font-family: monospace;
    font-size: 0.8rem;
    background: var(--background-color);
}

.url-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
}

.action-buttons .primary-btn {
    flex: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    margin-top: auto;
}

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

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }

    .controls-section {
        order: 1;
    }

    .preview-section {
        order: 2;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .logo {
        width: 36px;
        height: 36px;
    }

    section {
        padding: 1rem;
    }

    .dimension-inputs {
        flex-wrap: wrap;
    }

    .dimension-separator {
        display: none;
    }

    .dimension-inputs .input-wrapper {
        flex: 1;
        min-width: 100px;
    }

    input[type="number"] {
        width: 100%;
    }

    .color-inputs {
        flex-direction: column;
        gap: 1rem;
    }

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

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #111827;
        --card-background: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --border-color: #374151;
    }

    input[type="text"],
    input[type="number"],
    select {
        background: #374151;
        color: var(--text-primary);
    }

    .preset-btn {
        background: #374151;
        border-color: #4b5563;
    }

    input[type="color"] {
        background: #374151;
        border-color: #4b5563;
    }

    .preview-container {
        background: repeating-conic-gradient(#374151 0% 25%, #1f2937 0% 50%) 50% / 20px 20px;
    }
}
