/* CSS Custom Properties for Theming */
:root {
    /* Background gradient */
    --color-bg-gradient-1: #667eea;
    --color-bg-gradient-2: #764ba2;
    
    /* Surfaces */
    --color-surface: #ffffff;
    --color-surface-alt: #f9fafb;
    --color-surface-muted: #f3f4f6;
    
    /* Text */
    --color-text-primary: #333333;
    --color-text-secondary: #374151;
    --color-text-muted: #6b7280;
    --color-text-on-gradient: #ffffff;
    
    /* Borders */
    --color-border: #e5e7eb;
    --color-border-focus: #667eea;
    --color-border-light: #f3f4f6;
    
    /* Accent */
    --color-accent: #667eea;
    --color-accent-hover: #5a6fd6;
    
    /* Feedback */
    --color-success: #10b981;
    --color-success-bg: #f0fdf4;
    --color-error: #ef4444;
    --color-error-bg: #fee2e2;
    --color-error-border: #fecaca;
    --color-error-text: #991b1b;
    
    /* Shadows */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-color-strong: rgba(0, 0, 0, 0.15);
    --shadow-accent: rgba(102, 126, 234, 0.3);
    --shadow-accent-strong: rgba(102, 126, 234, 0.4);
}

/* Dark Theme */
@media (prefers-color-scheme: dark) {
    :root {
        /* Background gradient - deeper, muted tones */
        --color-bg-gradient-1: #1e1b4b;
        --color-bg-gradient-2: #312e81;
        
        /* Surfaces */
        --color-surface: #1f2937;
        --color-surface-alt: #374151;
        --color-surface-muted: #4b5563;
        
        /* Text */
        --color-text-primary: #f9fafb;
        --color-text-secondary: #e5e7eb;
        --color-text-muted: #9ca3af;
        --color-text-on-gradient: #f9fafb;
        
        /* Borders */
        --color-border: #4b5563;
        --color-border-focus: #818cf8;
        --color-border-light: #374151;
        
        /* Accent */
        --color-accent: #818cf8;
        --color-accent-hover: #a5b4fc;
        
        /* Feedback */
        --color-success: #34d399;
        --color-success-bg: #064e3b;
        --color-error: #f87171;
        --color-error-bg: #7f1d1d;
        --color-error-border: #991b1b;
        --color-error-text: #fecaca;
        
        /* Shadows */
        --shadow-color: rgba(0, 0, 0, 0.3);
        --shadow-color-strong: rgba(0, 0, 0, 0.4);
        --shadow-accent: rgba(129, 140, 248, 0.3);
        --shadow-accent-strong: rgba(129, 140, 248, 0.4);
    }
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--color-bg-gradient-1) 0%, var(--color-bg-gradient-2) 100%);
    min-height: 100vh;
    color: var(--color-text-primary);
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--color-text-on-gradient);
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    font-size: 1.2rem;
    font-weight: 300;
    opacity: 0.9;
}

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

.input-section {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow-color);
    backdrop-filter: blur(10px);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.input-group input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--color-surface-alt);
    color: var(--color-text-primary);
}

.input-group input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--shadow-accent);
}

.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.option-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.option-group select,
.option-group input[type="color"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--color-surface-alt);
    color: var(--color-text-primary);
    transition: all 0.3s ease;
}

.option-group select:focus,
.option-group input[type="color"]:focus {
    outline: none;
    border-color: var(--color-border-focus);
    background: var(--color-surface);
}

.option-group input[type="color"] {
    height: 3rem;
    cursor: pointer;
}

.logo-upload-group {
    grid-column: 1 / -1;
}

.logo-upload-area {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--color-surface-alt);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-upload-area:hover,
.logo-upload-area.drag-over {
    border-color: var(--color-border-focus);
    background: var(--color-surface);
}

.logo-upload-area:focus-visible {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--shadow-accent);
    background: var(--color-surface);
}

.logo-upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.logo-upload-prompt svg {
    opacity: 0.5;
}

.logo-preview {
    position: relative;
    display: inline-block;
}

.logo-preview img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 6px;
    object-fit: contain;
    border: 1px solid var(--color-border);
}

.logo-clear-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.logo-clear-btn:hover {
    background: var(--color-error);
    color: white;
    border-color: var(--color-error);
}

.generate-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-bg-gradient-2) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px var(--shadow-accent);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-accent-strong);
}

.generate-btn:active {
    transform: translateY(0);
}

.demo-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.demo-btn:hover {
    background: var(--color-accent);
    color: white;
    transform: translateY(-1px);
}

.result-section {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow-color);
    text-align: center;
    display: none;
    animation: fadeInUp 0.5s ease;
}

.result-section.show {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qr-container {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.qr-code-wrapper {
    text-align: center;
}

#qr-code {
    padding: 1rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 2px solid var(--color-border-light);
    transition: all 0.3s ease;
    display: inline-block;
}

#qr-code:hover {
    box-shadow: 0 8px 25px var(--shadow-color-strong);
    transform: translateY(-2px);
}

#qr-code canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.qr-code-label {
    display: block;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.qr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    font-size: 1rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.qr-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top: 2px solid var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

.download-btn:hover {
    background: var(--color-accent);
    color: white;
}

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

.url-display {
    padding: 1rem;
    background: var(--color-surface-muted);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    word-break: break-all;
}

.url-display span:first-child {
    font-weight: 500;
}

.url-display span:last-child {
    color: var(--color-text-secondary);
    font-weight: 600;
}

footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--color-text-on-gradient);
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .input-section,
    .result-section {
        padding: 1.5rem;
    }
    
    .options {
        grid-template-columns: 1fr;
    }
    
    .actions {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .input-section,
    .result-section {
        padding: 1rem;
    }
}

/* Loading state */
.generate-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.generate-btn.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

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

/* Success animations */
.copy-btn.success {
    background: var(--color-success) !important;
    color: white !important;
    border-color: var(--color-success) !important;
}

.copy-btn.success::after {
    content: ' ✓';
}

/* Utility classes for JavaScript state management */
.input-error {
    border-color: var(--color-error) !important;
}

.input-valid {
    border-color: var(--color-border) !important;
}

.input-success-feedback {
    border-color: var(--color-success) !important;
    background-color: var(--color-success-bg) !important;
}

.btn-success-feedback {
    border-color: var(--color-success) !important;
    background-color: var(--color-success-bg) !important;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow-color-strong);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification.show {
    transform: translateX(0);
}

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

.notification.error {
    background-color: var(--color-error);
}

/* Error message box (for library loading issues) */
.error-message-box {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--color-error-bg);
    color: var(--color-error-text);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--color-error-border);
    z-index: 1000;
    max-width: 350px;
    box-shadow: 0 4px 12px var(--shadow-color-strong);
}

.error-message-box a {
    color: var(--color-error-text);
    text-decoration: underline;
}

.error-message-box button {
    background: var(--color-error-text);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

@media (prefers-color-scheme: dark) {
    .error-message-box a {
        color: var(--color-error);
    }
    
    .error-message-box button {
        background: var(--color-error);
        color: var(--color-surface);
    }
}
