/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 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;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

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

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
}

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

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

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

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

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

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

/* Upload Section */
.upload-section {
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

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

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.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(--surface-hover);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.7);
}

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

/* Preview Section */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--border-radius-sm);
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.image-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.image-info span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Analysis Section */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

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

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

.analysis-results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-card {
    background: var(--surface-hover);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
}

/* Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.tag-confidence {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-swatch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

.color-swatch-preview {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.color-swatch-info {
    font-size: 0.875rem;
}

.color-swatch-name {
    display: block;
    font-weight: 500;
}

.color-swatch-hex {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Properties Grid */
.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.property-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--border-radius-sm);
}

.property-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.property-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

/* Customization Panel */
.customization-panel {
    background: var(--surface-hover);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

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

.option-group select,
.option-group input[type="text"] {
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.option-group select:focus,
.option-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

/* Suggestions Container */
.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-card {
    background: var(--surface-hover);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    border: 1px solid transparent;
    transition: var(--transition);
}

.suggestion-card:hover {
    border-color: var(--border-color);
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.suggestion-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
}

.suggestion-length {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.suggestion-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

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

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.copy-btn.copied {
    background: var(--success-color);
}

/* Footer */
.footer {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.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;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 0.75rem;
    }

    .header {
        padding: 1.5rem 0.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

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

    .upload-icon svg {
        width: 48px;
        height: 48px;
    }

    section {
        padding: 1rem;
    }

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

    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .suggestion-actions {
        flex-wrap: wrap;
    }

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

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo-img {
        width: 40px;
        height: 40px;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .image-preview img {
        max-height: 280px;
    }

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus States */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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