/* CSS Reset and Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* CSS Custom Properties */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --background: #ffffff;
    --surface: #f8f9fa;
    --border: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --success: #10b981;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --border-radius: 8px;
}

/* Base Styles */
html {
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Header Styling */
.app-header {
    text-align: center;
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid;
    border-image: linear-gradient(90deg, var(--primary-color), var(--secondary-color)) 1;
    margin-bottom: var(--spacing-lg);
}

.app-header h1 {
    font-size: 2.5rem;
    margin: 0 0 var(--spacing-sm) 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
    font-size: 1.1rem;
}

/* ===== TAB NAVIGATION ===== */

.tab-navigation-container {
    margin-bottom: var(--spacing-lg);
    background-color: var(--surface);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border);
    background-color: var(--background);
}

.tab-button {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background-color: rgba(99, 102, 241, 0.05);
    color: var(--text-primary);
}

.tab-button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.tab-button.active {
    color: var(--primary-color);
    font-weight: 600;
    border-bottom-color: var(--primary-color);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content[style*="display: block"] {
    display: block !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) transparent;
    }
    
    .tab-nav::-webkit-scrollbar {
        height: 4px;
    }
    
    .tab-nav::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .tab-nav::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 2px;
    }
    
    .tab-button {
        min-width: 120px;
        font-size: 0.9rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

@media (max-width: 480px) {
    .tab-nav {
        white-space: nowrap;
    }
    
    .tab-button {
        flex: none;
        min-width: 100px;
        font-size: 0.85rem;
        padding: var(--spacing-sm) 12px;
    }
}

/* ===== UNIFIED TRAIT GENERATION INTERFACE ===== */

/* Category Sub-Tabs */
.category-sub-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: -1px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.category-sub-tabs::-webkit-scrollbar {
    height: 3px;
}

.category-sub-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.category-sub-tabs::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.category-sub-tab {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 80px;
}

.category-sub-tab:hover {
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-primary);
}

.category-sub-tab.active {
    background: var(--primary-color);
    color: white;
    border-bottom: 1px solid var(--primary-color);
    font-weight: 600;
}

/* Trait Controls Container */
.trait-controls-container {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0 var(--border-radius) var(--border-radius) var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.trait-controls-container h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

/* Unified Preview Container */
.unified-preview-container {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.unified-preview-container h4 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.trait-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-sm);
    max-height: 200px;
    overflow-y: auto;
}

.trait-preview-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: var(--spacing-lg);
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
    background: rgba(99, 102, 241, 0.05);
}

/* Generation Mode Section */
.generation-mode-section {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.generation-mode-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

/* Generation Mode Table */
.generation-mode-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    background: var(--background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.generation-mode-table th {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.generation-mode-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.generation-mode-table tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.generation-mode-table tr:last-child td {
    border-bottom: none;
}

.generation-mode-table .category-label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.mode-radio-cell {
    text-align: center;
    width: 25%;
}

.mode-radio-cell input[type="radio"] {
    margin-right: var(--spacing-sm);
}

.mode-radio-cell label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.mode-radio-cell input[type="radio"]:checked + label {
    color: var(--primary-color);
    font-weight: 600;
}

/* Generate Traits Section */
.generate-traits-section {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

/* Tab 3 Section Spacing */
#rarity-collection-content > section {
    margin-bottom: var(--spacing-xl);
}

/* ===== BUDGET MANAGEMENT TABLE ===== */

.budget-management-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    background: var(--background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.budget-management-table th {
    background: var(--surface);
    color: var(--text-primary);
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--border);
}

.budget-management-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.budget-management-table tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.budget-management-table tr:last-child td {
    border-bottom: none;
}

.provider-name-cell {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 120px;
}

.cost-cell {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 100px;
}

.input-cell {
    width: 120px;
}

.input-cell input {
    width: 100px;
    padding: var(--spacing-sm);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-cell input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.remaining-cell {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.progress-cell {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 150px;
}

.budget-progress-bar {
    min-width: 100px;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
}

.budget-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 4px;
}

.budget-progress-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.budget-progress-fill.danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Responsive Design for Budget Table */
@media (max-width: 768px) {
    .budget-management-table,
    .budget-management-table thead,
    .budget-management-table tbody,
    .budget-management-table th,
    .budget-management-table td,
    .budget-management-table tr {
        display: block;
    }
    
    .budget-management-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .budget-management-table tr {
        border: 1px solid var(--border);
        margin-bottom: var(--spacing-md);
        border-radius: var(--border-radius);
        padding: var(--spacing-md);
        background: var(--surface);
    }
    
    .budget-management-table td {
        border: none;
        position: relative;
        padding: var(--spacing-sm) 0;
        padding-left: 35%;
        margin-bottom: var(--spacing-sm);
    }
    
    .budget-management-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 30%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .provider-name-cell {
        padding-left: 0;
        margin-bottom: var(--spacing-md);
        font-size: 1.1rem;
    }
    
    .input-cell {
        width: auto;
    }
    
    .input-cell input {
        width: 100%;
        max-width: 150px;
    }
    
    .progress-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .budget-progress-bar {
        width: 100%;
        min-width: auto;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .category-sub-tabs {
        padding: 0 var(--spacing-sm);
    }
    
    .category-sub-tab {
        min-width: 70px;
        font-size: 0.8rem;
        padding: var(--spacing-sm);
    }
    
    .generation-mode-table {
        font-size: 0.8rem;
    }
    
    .generation-mode-table th,
    .generation-mode-table td {
        padding: var(--spacing-sm);
    }
    
    .trait-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
    
    .trait-preview-grid img {
        height: 60px;
    }
}

/* Mobile breakpoint for extreme narrow screens */
@media (max-width: 600px) {
    .generation-mode-table {
        display: block;
        overflow: visible;
    }
    
    .generation-mode-table thead,
    .generation-mode-table tbody,
    .generation-mode-table th,
    .generation-mode-table td,
    .generation-mode-table tr {
        display: block;
    }
    
    .generation-mode-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .generation-mode-table tr {
        border: 1px solid var(--border);
        margin-bottom: var(--spacing-md);
        border-radius: var(--border-radius);
        padding: var(--spacing-md);
        background: var(--background);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .generation-mode-table td {
        border: none;
        position: relative;
        padding: var(--spacing-sm) 0;
        padding-left: 35%;
        margin-bottom: var(--spacing-sm);
        min-height: 40px;
        display: flex;
        align-items: center;
    }
    
    .generation-mode-table td:before {
        content: attr(data-label) ":";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 30%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-primary);
        font-size: 0.9rem;
    }
    
    .generation-mode-table .category-label {
        padding-left: 0;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--primary-color);
        margin-bottom: var(--spacing-md);
        border-bottom: 1px solid var(--border);
        padding-bottom: var(--spacing-sm);
    }
    
    .generation-mode-table .category-label:before {
        display: none;
    }
    
    .mode-radio-cell {
        text-align: left;
        padding-left: 35%;
    }
    
    .mode-radio-cell input[type="radio"] {
        margin-right: var(--spacing-sm);
        transform: scale(1.2);
    }
    
    .mode-radio-cell label {
        font-size: 1rem;
        font-weight: 500;
    }
}

@media (max-width: 480px) {
    .generation-mode-table tr {
        padding: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
    }
    
    .generation-mode-table td {
        padding-left: 40%;
        font-size: 0.9rem;
    }
    
    .generation-mode-table td:before {
        width: 35%;
        font-size: 0.8rem;
    }
    
    .generation-mode-table .category-label {
        font-size: 1rem;
    }
    
    .mode-radio-cell {
        padding-left: 40%;
    }
}

/* Section Base Styles */
section {
    background-color: var(--surface);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

section h2 {
    border-left: 4px solid var(--primary-color);
    padding-left: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    font-size: 1.5rem;
}







.trait-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    min-height: 120px;
    padding: var(--spacing-sm);
    border: 1px dashed var(--border);
    border-radius: var(--border-radius);
    align-items: start;
}

.trait-preview-container img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: calc(var(--border-radius) / 2);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.trait-preview-container img:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.file-count {
    display: none;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

.file-count.visible {
    display: inline-block;
}

/* Slider Controls */
.slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--background);
    outline: none;
    margin: var(--spacing-sm) 0;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.slider:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.slider-value {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1rem;
}

.color-seed-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-top: var(--spacing-sm);
    transition: border-color 0.3s ease;
}

.color-seed-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.generate-traits-btn-container {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

#generateTraitsBtn {
    min-width: 250px;
    font-size: 1.1rem;
    padding: var(--spacing-md) var(--spacing-lg);
}

/* Rarity Configuration Section */
.rarity-controls-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.rarity-status {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-md);
}

/* Rarity Category Containers */
.rarity-category {
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    background-color: var(--background);
}

.rarity-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.rarity-category-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.validation-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.validation-badge.valid {
    background-color: var(--success);
    color: white;
}

.validation-badge.invalid {
    background-color: #ef4444;
    color: white;
}

/* Rarity Trait Items */
.rarity-trait-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: background-color 0.3s ease;
}

.rarity-trait-item:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

.rarity-trait-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: calc(var(--border-radius) / 2);
    border: 2px solid var(--border);
    object-fit: cover;
    flex-shrink: 0;
}

.rarity-trait-label {
    min-width: 80px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rarity-slider-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-grow: 1;
}

/* Rarity Sliders */
.rarity-slider {
    flex-grow: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--background);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow 0.3s ease;
}

.rarity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    cursor: pointer;
    transition: transform 0.2s ease;
}

.rarity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.rarity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease;
}

.rarity-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.rarity-slider:focus {
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.rarity-percentage {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Rarity Tier Badges */
.rarity-tier {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    min-width: 70px;
    text-align: center;
}

.rarity-tier.legendary {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
}

.rarity-tier.epic {
    background-color: #3b82f6;
    color: white;
}

.rarity-tier.rare {
    background-color: var(--success);
    color: white;
}

.rarity-tier.common {
    background-color: #6b7280;
    color: white;
}

/* Validation Summary */
.rarity-validation-summary {
    text-align: center;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    display: none;
}

.rarity-validation-summary.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
    display: block;
}

.rarity-validation-summary.warning {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid #ef4444;
    display: block;
}

#resetRarityBtn {
    display: block;
    margin: var(--spacing-lg) auto 0;
}

/* Generation Section */
.generation-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-primary);
}

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

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#previewCanvas {
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    margin: var(--spacing-lg) auto;
    display: block;
    background-image: 
        linear-gradient(45deg, #25293c 25%, transparent 25%), 
        linear-gradient(-45deg, #25293c 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #25293c 75%), 
        linear-gradient(-45deg, transparent 75%, #25293c 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Button Styles */
.btn-primary,
.btn-secondary {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

/* Progress Bar */
.progress-container {
    display: none;
    margin-top: var(--spacing-lg);
    background-color: var(--background);
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 30px;
    position: relative;
}

.progress-container.active {
    display: block;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    font-weight: bold;
    color: var(--text-primary);
}

/* Output Section */
.output-section {
    display: none;
}

.output-section.visible {
    display: block;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.collection-grid > * {
    aspect-ratio: 1 / 1;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.collection-grid > *:hover {
    transform: scale(1.05);
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {

    
    .rarity-controls-container {
        grid-template-columns: 1fr;
    }
    
    .app-header h1 {
        font-size: 2rem;
    }
    
    .app-container {
        padding: var(--spacing-md);
    }
    
    section {
        padding: var(--spacing-md);
    }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.8rem;
    }
    
    section h2 {
        font-size: 1.3rem;
    }
    
    .app-container {
        padding: var(--spacing-sm);
    }
    
    section {
        padding: var(--spacing-sm);
    }
    
    .slider {
        height: 10px;
    }
    
    .slider::-webkit-slider-thumb,
    .slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
    
    .trait-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: var(--spacing-sm);
    }
    
    .trait-preview-container img {
        height: 60px;
    }
    
    .rarity-trait-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .rarity-trait-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .rarity-slider-container {
        width: 100%;
    }
    
    #previewCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .generation-form {
        gap: var(--spacing-md);
    }
    
    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        padding: var(--spacing-md);
    }
}

/* ===== AI CONFIGURATION SECTION ===== */

.ai-config-section {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border);
}

.ai-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    cursor: pointer;
}

.ai-config-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.1);
}

.toggle-btn[aria-expanded="false"] {
    transform: rotate(-90deg);
}

.ai-config-content {
    display: block;
    transition: all 0.3s ease;
}

.ai-config-content.collapsed {
    display: none;
}

.config-subsection {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.config-subsection:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.config-subsection h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    font-size: 1.3rem;
}

.config-subsection h4 {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

/* ===== PROVIDER CARDS ===== */

.provider-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.provider-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
    position: relative;
}

.provider-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.provider-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.provider-card-disabled {
    opacity: 0.7;
    background: var(--surface);
}

.coming-soon-badge {
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}

.provider-radio-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.security-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.warning-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.warning-content {
    font-size: 0.9rem;
    line-height: 1.4;
}

.cost-row-disabled {
    opacity: 0.6;
    background: rgba(0, 0, 0, 0.02);
}

.section-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 8px;
}

.section-badge.optional {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.provider-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.provider-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
}

.gemini-logo {
    background: linear-gradient(135deg, #4285f4, #34a853);
}

.openai-logo {
    background: linear-gradient(135deg, #00a67e, #00c896);
}

.stablediffusion-logo {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
}

.procedural-logo {
    background: linear-gradient(135deg, #f59e0b, #fb923c);
}

.provider-logo::before {
    content: attr(data-provider);
}

.gemini-logo::before {
    content: "G";
}

.openai-logo::before {
    content: "AI";
}

.stablediffusion-logo::before {
    content: "SD";
}

.provider-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.api-key-input-group {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.api-key-input {
    flex: 1;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.validate-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.validate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.validate-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.status-indicator {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.status-indicator.valid {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-indicator.invalid {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-indicator.validating {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-indicator.not-configured {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.quota-display {
    margin-bottom: var(--spacing-md);
}

.quota-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: var(--spacing-sm);
}

.quota-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.quota-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.3s ease;
}

.cost-badge {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: var(--spacing-md);
}

.cost-badge-free {
    background: linear-gradient(135deg, var(--success), #34d399);
    font-weight: 700;
}

.remove-key-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.remove-key-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ===== ACTIVE PROVIDER SELECTOR ===== */

.active-provider-section {
    margin-bottom: var(--spacing-xl);
}

.provider-radio-group {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.provider-radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    min-width: 120px;
    justify-content: center;
}

.provider-radio-label:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.provider-radio-label input[type="radio"] {
    margin: 0;
}

.provider-radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.provider-radio-label:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

/* ===== CONFIG ACTIONS ===== */

.config-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.action-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

/* ===== STYLE CONFIGURATION ===== */

.style-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.style-preset-selector {
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
}

.style-preset-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.master-prompt-textarea,
.negative-prompts-textarea {
    min-height: 100px;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
}

.master-prompt-textarea:focus,
.negative-prompts-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.char-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

.inheritance-level-group {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.inheritance-radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    flex: 1;
    min-width: 100px;
    justify-content: center;
}

.inheritance-radio-label:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.inheritance-radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.inheritance-radio-label:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

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

.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.color-picker-item {
    width: 50px;
    height: 50px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.color-picker-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== GENERATION MODE CONFIGURATION ===== */

.global-ai-toggle {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--background);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.help-text {
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.no-api-message {
    padding: var(--spacing-md);
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
}







.mode-radio-group {
    display: flex;
    gap: var(--spacing-lg);
}

.mode-radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    min-width: 90px;
    justify-content: center;
}

.mode-radio-label:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.mode-radio-label.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mode-radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.mode-radio-label:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.hybrid-opacity-section {
    padding: var(--spacing-lg);
    background: var(--background);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.hybrid-opacity-section label {
    display: block;
    margin-bottom: var(--spacing-md);
    font-weight: 500;
    color: var(--text-primary);
}

/* ===== COST ESTIMATION ===== */

.cost-estimator {
    background: var(--background);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.cost-input-group {
    margin-bottom: var(--spacing-lg);
}

.cost-input-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.cost-input-group input {
    width: 150px;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-primary);
}

.cost-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-lg);
}

.cost-breakdown-table th,
.cost-breakdown-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.cost-breakdown-table th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.cost-breakdown-table td {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.cost-row.active {
    background: rgba(99, 102, 241, 0.05);
}

.cost-total {
    border-top: 2px solid var(--primary-color);
    background: var(--surface);
}

.cost-total td {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.cost-warning {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-weight: 500;
}

/* ===== VALIDATION MESSAGES ===== */

.validation-message {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

.validation-message.success {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    border: 1px solid #10b981;
}

.validation-message.error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: 1px solid #ef4444;
}

.validation-message.info {
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border: 1px solid #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== RESPONSIVE DESIGN FOR AI CONFIG ===== */

@media (max-width: 1024px) {
    .provider-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .style-config-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ai-config-section {
        padding: var(--spacing-md);
    }
    
    .provider-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .provider-radio-group,
    .mode-radio-group,
    .inheritance-level-group {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    

    
    .color-palette-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .color-picker-item {
        width: 40px;
        height: 40px;
    }
    
    .cost-breakdown-table {
        font-size: 0.8rem;
    }
    
    .cost-breakdown-table th,
    .cost-breakdown-table td {
        padding: var(--spacing-sm);
    }
    
    .validation-message {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .config-actions {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        text-align: center;
    }
    
    .api-key-input-group {
        flex-direction: column;
    }
    
    .validate-btn {
        width: 100%;
    }
}
/* ===== BUDGET MANAGEMENT STYLES ===== */

.budget-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}



.budget-global {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.global-budget-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.budget-thresholds {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
}

.budget-thresholds select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--background);
    color: var(--text-primary);
}

/* ===== COST ANALYTICS DASHBOARD STYLES ===== */

.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
}

.stat-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.analytics-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-xl);
}

.chart-container {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
}

.chart-container h4 {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.chart-container canvas {
    width: 100%;
    height: auto;
    max-width: 100%;
}

.analytics-table {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
}

.analytics-table h4 {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.table-container {
    overflow-x: auto;
}

#transactionTable {
    width: 100%;
    border-collapse: collapse;
}

#transactionTable th,
#transactionTable td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#transactionTable th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#transactionTable td {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.status-badge {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.analytics-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.btn-secondary {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

/* ===== BUDGET WARNING MODAL ===== */

.budget-warning-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.budget-warning-content {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.budget-warning-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.budget-warning-icon {
    width: 48px;
    height: 48px;
    background: #f59e0b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.budget-warning-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.budget-warning-message {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-xl);
}

.budget-warning-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.budget-warning-actions button {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.budget-warning-actions .btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

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

.budget-warning-actions .btn-cancel {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.budget-warning-actions .btn-cancel:hover {
    background: var(--surface);
    border-color: var(--primary-color);
}

/* ===== RESPONSIVE DESIGN FOR BUDGET & ANALYTICS ===== */

@media (max-width: 1024px) {
    .analytics-charts {
        grid-template-columns: 1fr;
    }
    

}

@media (max-width: 768px) {
    .analytics-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card {
        padding: var(--spacing-md);
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .budget-global {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    .analytics-actions {
        flex-direction: column;
    }
    
    .budget-warning-content {
        padding: var(--spacing-lg);
    }
    
    .budget-warning-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .analytics-summary {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        padding: var(--spacing-md);
    }
    
    .analytics-table {
        padding: var(--spacing-md);
    }
    
    #transactionTable th,
    #transactionTable td {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
}

/* ===== QUALITY ASSURANCE STYLES ===== */

.qa-config-section {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.qa-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.qa-config-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.threshold-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.queue-status {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* ===== MODAL STYLES ===== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.qa-preview-modal-content {
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
}

.qa-approval-modal-content {
    max-width: 900px;
}

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

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.3s;
}

.modal-close:hover {
    background: var(--bg-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ===== PREVIEW MODAL STYLES ===== */

.preview-summary {
    margin-bottom: 1.5rem;
}

.preview-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

.stat-item {
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--text-primary);
}

.preview-category-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.preview-category-tabs button {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.preview-category-tabs button.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.preview-category-tabs button:hover {
    color: var(--text-primary);
}

.preview-grid-container {
    margin-bottom: 1.5rem;
}

.preview-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.preview-grid-item {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.preview-grid-item:hover {
    transform: scale(1.05);
}

.preview-grid-item.outlier {
    border-color: #ef4444;
}

.preview-grid-item img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-score-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

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

.consistency-score-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.consistency-score-card h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.consistency-score-card .score-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-color);
    display: block;
    margin-bottom: 0.5rem;
}

.score-breakdown-mini {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== APPROVAL MODAL STYLES ===== */

.approval-progress {
    margin-bottom: 1.5rem;
}

.approval-progress span {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s;
}

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

.comparison-item h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.comparison-image {
    width: 100%;
    height: auto;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.image-metadata {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.score-breakdown {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.score-breakdown h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.score-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.score-bar-item {
    display: grid;
    grid-template-columns: 150px 1fr 50px;
    gap: 1rem;
    align-items: center;
}

.score-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.score-bar {
    height: 20px;
    background: var(--bg-primary);
    border-radius: 10px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);
    transition: width 0.3s;
}

.score-value {
    text-align: right;
    font-weight: bold;
    color: var(--text-primary);
}

.approval-notes {
    margin-top: 1rem;
}

.approval-notes label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.approval-notes textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
}

/* ===== BUTTON STYLES ===== */

.btn-danger {
    background: #ef4444;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 0.875rem;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.875rem;
}

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

.btn-primary {
    background: var(--accent-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 0.875rem;
}

.btn-primary:hover {
    background: #5b21b6;
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .threshold-grid {
        grid-template-columns: 1fr;
    }
    
    .queue-status {
        grid-template-columns: 1fr;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .score-bar-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: center;
    }
    
    .preview-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

/* ===== TOAST ANIMATIONS ===== */

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast {
    animation: slideIn 0.3s ease-out;
}