/* Modern AI Image Generator Styles - ChatGPT Inspired */

:root {
    /* Color Palette - Banana Theme */
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --secondary: #fbbf24;
    --secondary-hover: #f59e0b;
    --accent: #fed7aa;
    --danger: #ef4444;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Background - Banana themed */
    --bg-primary: #ffffff;
    --bg-secondary: #fef7cd;
    --bg-tertiary: #fef3c7;
    --bg-dark: #0f1419;
    
    /* Text Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-500);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Borders */
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Font Awesome Icon Support */
.fa, .fas, .far, .fal, .fad, .fab {
    font-family: "Font Awesome 5 Free", "Font Awesome 5 Pro", "FontAwesome" !important;
    font-style: normal;
    font-display: auto;
    line-height: 1;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: inline-block;
    text-decoration: none;
}

.fas, .fa {
    font-weight: 900 !important;
}

.far {
    font-weight: 400 !important;
}

.fab {
    font-weight: 400 !important;
}

/* Button icon specific fixes */
button .fas, button .far, button .fab, button .fa {
    pointer-events: none;
    vertical-align: middle;
    line-height: inherit;
}

/* Fallback SVG icons - if Font Awesome fails to load */
.icon-fallback {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: middle;
}

/* Button fallback icons */
.upload-btn .icon-fallback {
    fill: currentColor;
}

.send-btn .icon-fallback {
    fill: currentColor;
}

.action-btn .icon-fallback {
    fill: currentColor;
}

/* Spinner animation for fallback icons */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #fef7cd 0%, #fef3c7 25%, #fed7aa 65%, #fdba74 100%);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header and Navigation - Fixed positioning */
.app-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    /* Ensure consistent box model */
    box-sizing: border-box;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    /* Prevent flex shrink that could cause shifts */
    flex-shrink: 0;
}

/* Logo - Fixed positioning */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    /* Prevent flex shrink */
    flex-shrink: 0;
    /* Fixed minimum width to prevent shifts */
    min-width: max-content;
}

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
    /* Prevent image flex */
    flex-shrink: 0;
}

.logo-icon {
    font-size: 20px;
    color: var(--primary);
    /* Prevent icon flex */
    flex-shrink: 0;
}

.logo i {
    font-size: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

/* Navigation tabs - Fixed layout */
.nav-tabs {
    display: flex;
    gap: 4px;
    /* Center the navigation */
    flex: 1;
    justify-content: center;
    /* Prevent shrinking */
    flex-shrink: 0;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    /* Prevent text wrapping and shrinking */
    white-space: nowrap;
    flex-shrink: 0;
    /* Fixed minimum width */
    min-width: max-content;
}

.nav-tab:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--primary);
    color: white;
}

.nav-tab i {
    font-size: 14px;
    /* Prevent icon shifts */
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

/* User Menu Styles */
.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Prevent flex shrink */
    flex-shrink: 0;
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    flex-shrink: 0;
}

.avatar-display {
    flex-shrink: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--gray-200);
}

.user-avatar:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.default-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--gray-200);
}

.default-user-avatar:hover {
    transform: scale(1.05);
    background: var(--gray-200);
    border-color: var(--primary);
}

.user-info span {
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.user-info span:hover {
    color: var(--primary);
}

.user-info i {
    color: var(--primary);
    flex-shrink: 0;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.recharge-btn {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 10px;
    padding: 2px;
    border-radius: 50%;
    transition: color 0.2s;
}

.recharge-btn:hover {
    color: white;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.user-actions a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.profile-btn {
    background: var(--gray-100);
    color: var(--primary) !important;
}

.profile-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #5a67d8 !important;
}

.admin-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

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

.user-actions .logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--gray-100);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.user-actions .logout-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.user-actions .recharge-history-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--gray-100);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.user-actions .recharge-history-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.auth-buttons {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.auth-btn {
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.auth-btn.login-btn {
    background: var(--gray-100);
    color: var(--text-primary);
}

.auth-btn.login-btn:hover {
    background: var(--gray-200);
}

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

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

/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

/* Generate Container */
.generate-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 0;
    min-height: calc(100vh - 60px);
}

/* Template Section */
.template-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.section-header {
    text-align: center;
    margin-bottom: 32px;
}

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

.section-header p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* Template Categories */
.template-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.category-btn {
    background: var(--gray-100);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

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

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.template-card {
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card.selected {
    border-color: var(--primary);
    background: rgba(16, 163, 127, 0.05);
}

.template-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.template-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.template-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.template-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.template-example {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    color: var(--text-tertiary);
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1.3;
    word-break: break-word;
    border-left: 3px solid var(--primary);
}

.template-variables {
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* Free Form Message */
.free-form-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 40px;
    background: var(--bg-primary);
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius-xl);
    margin: 20px 0;
}

.free-form-icon {
    font-size: 48px;
    margin-bottom: 24px;
}

.free-form-message h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.free-form-message > p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.free-form-tips {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.free-form-tips h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.free-form-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.free-form-tips li {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.free-form-tips li:before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Chat Container - Legacy compatibility */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
}

/* Input Container */
.input-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.message-form {
    max-width: 100%;
    margin: 0;
}

/* Auth Required Styles */
.auth-required {
    max-width: 800px;
    margin: 0 auto;
}

.auth-required-content {
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    text-align: center;
}

.auth-required-content i {
    font-size: 48px;
    color: var(--gray-400);
    margin-bottom: 16px;
}

.auth-required-content h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-required-content p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 24px;
}

.auth-required-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.auth-required-buttons .auth-btn {
    padding: 12px 24px;
    font-size: 16px;
}

/* Credit Warning Styles */
.credit-warning {
    margin-bottom: 16px;
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: var(--border-radius-lg);
    padding: 16px;
}

.credit-warning-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #92400e;
}

.credit-warning-content i {
    font-size: 24px;
    color: #f59e0b;
}

.credit-warning-content h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.credit-warning-content p {
    margin: 0;
    font-size: 14px;
}

/* Disabled state for inputs and buttons */
.input-box textarea:disabled {
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
}

.upload-btn:disabled,
.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-btn:disabled:hover,
.send-btn:disabled:hover {
    background: var(--gray-100);
    color: var(--text-secondary);
}

.send-btn:disabled:hover {
    background: var(--gray-300);
}

/* Image Preview Container */
.image-preview-container {
    margin-bottom: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 16px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-count {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.preview-count.at-limit {
    color: var(--accent);
    font-weight: 600;
}

.clear-all-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.clear-all-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.image-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--gray-100);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: var(--transition);
}

.image-preview:hover .remove-btn {
    opacity: 1;
}

/* Add More Preview Button */
.add-more-preview {
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.add-more-preview:hover {
    border-color: var(--primary);
    background: rgba(16, 163, 127, 0.05);
}

.add-more-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    width: 100%;
    height: 100%;
    color: var(--text-secondary);
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.add-more-btn:hover {
    color: var(--primary);
    background: rgba(16, 163, 127, 0.05);
}

.add-more-btn i {
    font-size: 24px;
    margin-bottom: 4px;
}

.add-more-btn span {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

/* Input Box */
.input-box {
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-xl);
    transition: var(--transition);
}

.input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.input-box.drag-over {
    border-color: var(--primary);
    background: rgba(16, 163, 127, 0.05);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 16px;
    gap: 12px;
}

/* Syntax Highlight Container */
.syntax-highlight-container {
    flex: 1;
    position: relative;
    display: flex;
}

/* Input wrapper with consistent font settings */
.input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: transparent;
    color: var(--text-primary);
    min-height: 24px;
    max-height: 200px;
    width: 100%;
    position: relative;
    z-index: 2;
    padding: 0;
    margin: 0;
    /* Make text transparent when highlighting is active */
    caret-color: var(--text-primary);
    /* Ensure consistent text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Match overlay letter spacing */
    letter-spacing: normal;
    word-spacing: normal;
    /* Ensure no text decorations */
    text-decoration: none;
    text-shadow: none;
}

/* Hide original text when syntax highlighting is active */
.syntax-highlight-container.has-variables textarea {
    color: transparent;
    text-shadow: none;
    -webkit-text-fill-color: transparent;
}

/* Keep placeholder visible */
.syntax-highlight-container.has-variables textarea::placeholder {
    color: var(--text-tertiary);
    -webkit-text-fill-color: var(--text-tertiary);
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.input-wrapper textarea.drag-over {
    background: rgba(16, 163, 127, 0.05);
    border-radius: var(--border-radius);
}

/* Syntax Highlight Overlay */
.syntax-highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    font-size: 14px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    min-height: 24px;
    max-height: 200px;
    color: var(--text-primary);
    /* Ensure exact alignment with textarea */
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Match textarea font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Ensure exact letter spacing match */
    letter-spacing: normal;
    word-spacing: normal;
}

/* Allow pointer events on syntax elements */
.syntax-variable {
    pointer-events: auto;
}

/* Syntax Highlighting Styles */
.syntax-bracket {
    color: var(--gray-300);
    font-weight: 400;
    opacity: 0.7;
}

.syntax-variable {
    color: var(--primary);
    background: rgba(16, 163, 127, 0.08);
    font-weight: 600;
    /* Remove padding and margin to prevent offset */
    padding: 0;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    transition: var(--transition);
    /* Use box-shadow instead of border to avoid layout shift */
    box-shadow: inset 0 -2px 0 rgba(16, 163, 127, 0.3);
    pointer-events: auto;
    display: inline;
    /* Ensure no layout changes */
    vertical-align: baseline;
    text-decoration: none;
}

.syntax-variable:hover {
    background: rgba(16, 163, 127, 0.15);
    color: var(--primary-hover);
    box-shadow: inset 0 -2px 0 rgba(16, 163, 127, 0.5);
    /* Remove transform to prevent position shifts */
    transform: none;
}

.syntax-variable.selected {
    background: var(--primary);
    color: white;
    box-shadow: inset 0 -2px 0 var(--primary);
}

/* Mobile-friendly touch targets for syntax highlighting */
@media (max-width: 768px) {
    .syntax-variable {
        padding: 2px 4px;
        min-height: 24px;
        display: inline-flex;
        align-items: center;
    }
    
    .syntax-variable:hover {
        transform: none; /* Disable transform on mobile */
    }
}

/* Ensure textarea is transparent for highlighting to show through */
.syntax-highlight-container textarea {
    background: transparent !important;
}

/* Syntax help tip */
.syntax-help-tip {
    position: absolute;
    bottom: -28px;
    left: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    background: rgba(16, 163, 127, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(16, 163, 127, 0.2);
    white-space: nowrap;
    z-index: 3;
    animation: fadeInUp 0.3s ease-out;
}

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

.upload-btn, .send-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 14px;
}

.upload-btn {
    background: var(--gray-100);
    color: var(--text-secondary);
    transition: var(--transition);
}

.upload-btn:hover:not(:disabled) {
    background: var(--gray-200);
    color: var(--text-primary);
}

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

.upload-btn.has-images:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.upload-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--gray-100);
    color: var(--gray-400);
}

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

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Results Container */
.results-container {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Loading Animation */
.loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-animation {
    margin-bottom: 16px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: loading 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-message p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Generated Results */
.generated-results {
    flex: 1;
}

.results-header {
    margin-bottom: 20px;
}

.results-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.result-item {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

.result-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.result-item img {
    width: 100%;
    height: 280px;
    object-fit: cover;
}

.result-actions {
    padding: 16px;
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    background: var(--gray-100);
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

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

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

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

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 16px;
    border-radius: var(--border-radius-lg);
    margin: 20px 0;
    font-size: 14px;
}

.error-message strong {
    display: block;
    margin-bottom: 8px;
}

.error-message button {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    margin-top: 8px;
}

/* Debug Panel */
.debug-panel {
    background: var(--bg-primary);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin: 20px 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.debug-panel h4 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 16px;
}

.debug-panel h5 {
    margin: 16px 0 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.debug-panel pre {
    background: var(--gray-900);
    color: #f1f5f9;
    padding: 16px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
}

.debug-panel button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    margin-top: 12px;
    transition: var(--transition);
}

.debug-panel button:hover {
    background: var(--primary-hover);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--border-radius-lg);
}

.close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    transition: var(--transition);
}

.close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        padding: 0 16px;
    }
    
    .generate-container {
        padding: 16px 0;
        gap: 16px;
    }
    
    .template-section {
        padding: 20px;
    }
    
    .section-header h1 {
        font-size: 22px;
    }
    
    .template-categories {
        gap: 6px;
    }
    
    .category-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .template-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .template-card {
        padding: 16px;
    }
    
    .template-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .template-title {
        font-size: 15px;
    }
    
    .input-container {
        padding: 16px;
    }
    
    .header-content {
        padding: 0 16px;
    }
    
    .nav-tabs {
        gap: 2px;
    }
    
    .nav-tab {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }

    .modern-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .generate-container {
        gap: 12px;
    }
    
    .template-section {
        padding: 16px;
    }
    
    .section-header {
        margin-bottom: 20px;
    }
    
    .section-header h1 {
        font-size: 20px;
    }
    
    .template-categories {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .category-btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
    }
    
    .input-wrapper {
        padding: 12px;
        gap: 8px;
    }
    
    .upload-btn, .send-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .modern-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .gallery-header h1 {
        font-size: 20px;
    }
    
    .gallery-container {
        padding: 16px;
    }
}

/* Gallery Specific Styles */
.gallery-container {
    padding: 40px 20px;
    max-width: none;
    width: 100%;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.header-info h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.header-info p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 16px;
}

.gallery-stats {
    display: flex;
    gap: 24px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Modern Gallery Grid */
.modern-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.gallery-card {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gray-300);
}

.card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--gray-100);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.gallery-card:hover .card-image img {
    transform: scale(1.05);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.gallery-card:hover .card-overlay {
    opacity: 1;
}

.overlay-actions {
    display: flex;
    gap: 12px;
}

.overlay-actions .action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.overlay-actions .action-btn:hover {
    background: white;
    transform: scale(1.1);
}

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

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

.card-info {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 12px;
}

.image-actions {
    display: flex;
    gap: 4px;
}

.mini-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--gray-100);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: var(--transition);
}

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

/* Empty Gallery State */
.empty-gallery {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    min-height: 400px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.empty-icon i {
    font-size: 32px;
    color: var(--gray-400);
}

.empty-gallery h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-gallery p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 400px;
    line-height: 1.5;
}

.start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: var(--border-radius-lg);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.start-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ================ Template Parameters Customization ================ */
.template-params-container {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    overflow: visible; /* 改为visible，允许弹窗显示在容器外 */
    animation: slideDown 0.3s ease-out;
    transition: all 0.3s ease-out;
    /* 确保弹窗不受容器限制 */
    position: relative;
}

.template-params-container.collapsed .params-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden; /* 内容区域折叠时隐藏 */
    transition: all 0.3s ease-out;
}

.template-params-container:not(.collapsed) .params-content {
    max-height: 600px;
    opacity: 1;
    transition: all 0.3s ease-out;
}

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

.params-header {
    background: var(--bg-tertiary);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.params-header:hover {
    background: var(--bg-secondary);
}

.params-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.expand-collapse-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.expand-collapse-btn:hover {
    background: rgba(245, 158, 11, 0.1);
    transform: scale(1.1);
}

.template-params-container:not(.collapsed) .expand-collapse-btn i {
    transform: rotate(90deg);
    transition: transform 0.3s ease-out;
}

.template-params-container.collapsed .expand-collapse-btn i {
    transform: rotate(0deg);
    transition: transform 0.3s ease-out;
}

.params-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.params-header h3 i {
    color: var(--primary);
}

.close-params-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-params-btn:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.params-content {
    overflow: visible; /* 改为visible，允许弹窗显示 */
    transition: all 0.3s ease-out;
}

.params-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
    /* 确保弹窗可以显示在网格外 */
    overflow-x: visible;
    /* 允许子元素超出网格边界 */
    position: relative;
}

.param-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.param-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.param-label i {
    font-size: 12px;
    color: var(--primary);
}

.param-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    background: white;
    resize: none;
    min-height: 38px;
    line-height: 1.4;
}

.param-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.param-input.textarea {
    min-height: 60px;
    resize: vertical;
}

.params-actions {
    padding: 16px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.apply-params-btn,
.reset-params-btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.apply-params-btn {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.apply-params-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.reset-params-btn {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--gray-300);
}

.reset-params-btn:hover {
    background: var(--gray-50);
    color: var(--text-primary);
    border-color: var(--gray-400);
}

/* Responsive design for parameters */
@media (max-width: 768px) {
    .params-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px;
    }
    
    .params-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .apply-params-btn,
    .reset-params-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ================ Parameter Color Customization ================ */
.param-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 12px;
    background: var(--gray-50);
    transition: var(--transition);
}

.param-field:hover {
    border-color: var(--gray-300);
    background: white;
}

.param-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.param-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.param-label i {
    font-size: 12px;
    color: var(--primary);
}

/* Color Selection Panel - 简洁单色块设计 */
.param-color-selection {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative; /* 重要：为弹窗定位提供参考点 */
}

.color-display {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid var(--gray-300);
    transition: var(--transition);
    position: relative;
}

.color-display:hover {
    transform: scale(1.1);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.color-display.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* 颜色选择弹窗 - 使用fixed定位完全脱离文档流 */
.color-picker-popup {
    position: fixed; /* 改为fixed，相对于视窗定位 */
    z-index: 10000; /* 进一步提高层级 */
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 12px;
    min-width: 200px;
    display: none;
    animation: popupSlideIn 0.2s ease-out;
    /* 确保弹窗不被裁剪 */
    overflow: visible;
    /* 确保完全脱离父容器约束 */
    max-width: none;
    max-height: none;
}

.color-picker-popup.show {
    display: block;
}

/* 移除所有定位变体的CSS，因为我们将用JavaScript动态计算位置 */

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.popup-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    transition: var(--transition);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    position: relative;
}

.color-preset:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.color-preset.selected {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.color-preset.selected::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.custom-color-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

.custom-color-label {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
}

.param-color-picker {
    width: 40px;
    height: 24px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
    background: white;
    padding: 0;
    outline: none;
    transition: var(--transition);
}

.param-color-picker:hover {
    border-color: var(--primary);
}

/* 弹窗遮罩层 */
.color-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: none;
}

.color-popup-overlay.show {
    display: block;
}

.param-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    background: white;
    resize: none;
    min-height: 38px;
    line-height: 1.4;
    font-family: inherit;
}

.param-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.param-input.textarea {
    min-height: 60px;
    resize: vertical;
}

/* Welcome Section - Simplified */
.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    min-height: 300px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(254, 247, 205, 0.6));
    border-radius: var(--border-radius-xl);
    margin: 20px 0;
}

.welcome-content {
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: white;
    font-size: 32px;
    box-shadow: var(--shadow-md);
}

.welcome-section h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Site Footer */
.site-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--gray-200);
    padding: 20px 0;
    margin-top: auto;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-content p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Redemption Code Section */
.redemption-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.redemption-section:hover {
    box-shadow: var(--shadow-md);
}

.redemption-section .section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.redemption-section .section-header h2 i {
    color: var(--primary);
}

.redemption-form {
    margin-top: 16px;
}

.redemption-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.redemption-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
}

.redemption-input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.redemption-input-group input::placeholder {
    font-family: 'Inter', sans-serif;
    letter-spacing: normal;
    text-transform: none;
}

.redeem-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
}

.redeem-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.redeem-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.redemption-message {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.redemption-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.redemption-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.redemption-message.success i {
    color: #059669;
}

.redemption-message.error i {
    color: #dc2626;
}
/* Redemption Page Styles */
.redeem-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    text-align: center;
    margin-bottom: 48px;
}

.page-header .header-content {
    max-width: 600px;
    margin: 0 auto;
}

.page-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.page-title i {
    color: var(--primary);
}

.page-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.redeem-form-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    margin-bottom: 48px;
}

.redeem-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.redeem-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 24px;
}

.card-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h2 i {
    color: var(--primary);
}

.card-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.redeem-form {
    margin-bottom: 32px;
}

.credits-info-card {
    background: linear-gradient(135deg, var(--primary) 0%, #fbbf24 100%);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-md);
}

.credits-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.9;
}

.credits-display-large {
    margin-bottom: 24px;
}

.credits-number {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
    display: block;
    transition: var(--transition);
}

.credits-label {
    font-size: 16px;
    opacity: 0.9;
    margin-top: 4px;
    display: block;
}

.credits-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.credits-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.credits-actions .btn-primary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.credits-actions .btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.credits-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
}

.credits-actions .btn-secondary:hover {
    background: white;
    transform: translateY(-1px);
}

.auth-required-section {
    text-align: center;
    padding: 64px 32px;
}

.auth-card {
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 48px 32px;
    box-shadow: var(--shadow-sm);
}

.auth-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 32px;
    color: var(--gray-500);
}

.auth-card h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 32px;
}

.auth-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.auth-actions .btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.auth-actions .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-actions .btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.auth-actions .btn-secondary:hover {
    background: var(--gray-200);
    transform: translateY(-1px);
}

/* Responsive adjustments for redeem page */
@media (max-width: 768px) {
    .redeem-form-section {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .redeem-card {
        padding: 24px;
    }
    
    .credits-info-card {
        padding: 24px;
    }
    
    .credits-actions {
        flex-direction: column;
    }
    
    .auth-actions {
        flex-direction: column;
    }
}
