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

:root {
    --primary: #1a1a1a;
    --secondary: #f5f5f5;
    --accent: #ff6b35;
    --accent-hover: #e55a2b;
    --muted: #6b7280;
    --border: #d1d5db;
    --white: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--secondary);
    color: var(--primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1rem;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.125rem;
    color: var(--muted);
}

.logout-button {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.875rem;
}

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

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.controls-column,
.preview-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section h2,
.preview-column h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--primary);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.drop-zone.dragging {
    border-color: var(--accent);
    background: #fff5f1;
}

.upload-icon {
    color: var(--primary);
    margin: 0 auto 0.75rem;
    display: block;
}

.drop-zone.dragging .upload-icon {
    color: var(--accent);
}

.drop-zone-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.drop-zone-subtext {
    font-size: 0.875rem;
    color: var(--muted);
}

.uploaded-image-preview {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
}

.uploaded-image-preview.hidden {
    display: none;
}

#uploadPlaceholder.hidden {
    display: none;
}

/* Model Selector */
.model-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    background: var(--white);
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231a1a1a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.model-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Style Category Tabs */
.style-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.style-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.style-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.style-tab.active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--white);
}

/* Style Selector */
.style-selector {
    position: relative;
}

.style-button {
    width: 100%;
    background: var(--white);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
}

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

.chevron-icon {
    transition: transform 0.2s;
}

.style-button.open .chevron-icon {
    transform: rotate(180deg);
}

.style-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 10;
    max-height: 500px;
    overflow-y: auto;
}

.style-dropdown.hidden {
    display: none;
}

.style-option {
    width: 100%;
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    transition: background 0.15s;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.style-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.style-label {
    flex: 1;
    font-size: 1.05rem;
}

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

.style-option.selected {
    background: var(--accent);
    color: var(--white);
}

.style-option:first-child {
    border-top-left-radius: calc(0.5rem - 2px);
    border-top-right-radius: calc(0.5rem - 2px);
}

.style-option:last-child {
    border-bottom-left-radius: calc(0.5rem - 2px);
    border-bottom-right-radius: calc(0.5rem - 2px);
}

/* Style Examples Gallery */
.style-examples {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

.style-examples.hidden {
    display: none;
}

.examples-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.examples-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    padding-right: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--secondary);
}

.examples-grid::-webkit-scrollbar {
    width: 8px;
}

.examples-grid::-webkit-scrollbar-track {
    background: var(--secondary);
    border-radius: 4px;
}

.examples-grid::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.examples-grid::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

.example-image {
    width: 100%;
    height: auto;
    min-height: 250px;
    max-height: 350px;
    object-fit: contain;
    border-radius: 1rem;
    border: 4px solid var(--border);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

/* Generate Button */
.generate-button {
    width: 100%;
    background: var(--accent);
    color: var(--white);
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
}

.generate-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.generate-button:disabled {
    background: var(--border);
    color: var(--muted);
    cursor: not-allowed;
}

/* Preview Panel */
.preview-panel {
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    overflow: hidden;
    min-height: 24rem;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
}

.preview-icon {
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.preview-text {
    font-weight: 600;
    color: var(--muted);
}

.preview-subtext {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.preview-panel img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: var(--white);
}

.loading-overlay.hidden {
    display: none;
}

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

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

.loading-overlay p {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Style Customization Form */
.style-customizer {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--white);
    border: 2px solid var(--accent);
    border-radius: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.style-customizer.hidden {
    display: none;
}

.customizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.customizer-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.reset-btn {
    background: none;
    border: 1px solid var(--muted);
    color: var(--muted);
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.style-form-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Section grouping */
.form-section {
    background: var(--secondary);
    border-radius: 0.5rem;
    padding: 1rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.section-title::before {
    content: '▼';
    font-size: 0.625rem;
    transition: transform 0.2s;
}

.section-title.collapsed::before {
    transform: rotate(-90deg);
}

.section-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-content.collapsed {
    display: none;
}

/* Form fields */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-field.inline {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.form-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    min-width: 120px;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.85rem;
    color: var(--primary);
    background: var(--white);
    transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-field input::placeholder {
    color: var(--muted);
}

/* Checkbox/toggle fields */
.form-field.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form-field.checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.form-field.checkbox label {
    min-width: auto;
    cursor: pointer;
}

/* Array fields */
.array-field {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.array-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.array-item input {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.8rem;
    width: auto;
    min-width: 80px;
}

.array-item input:focus {
    outline: none;
}

.array-item .remove-item {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}

.array-item .remove-item:hover {
    color: var(--accent);
}

.add-item-btn {
    background: none;
    border: 1px dashed var(--border);
    color: var(--muted);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.add-item-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
