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

:root {
    /* 2026 Modern Color Palette */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --accent-color: #667eea;
    --accent-hover: #5568d3;
    --background: #0f0f1e;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    background-image: 
        radial-gradient(at 0% 0%, rgba(102, 126, 234, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(118, 75, 162, 0.1) 0px, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    position: relative;
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease;
}

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

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Usage Display */
.usage-display {
    position: absolute;
    top: 0;
    right: 0;
    animation: fadeIn 1s ease 0.3s both;
}

.usage-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.usage-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.usage-card svg {
    color: var(--accent-color);
    flex-shrink: 0;
}

.usage-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.usage-label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.usage-count {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.usage-unit {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-left: 0.25rem;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    animation: fadeIn 1s ease;
}

/* Glass Morphism Effect */
.config-panel,
.results-panel {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.config-panel:hover,
.results-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg);
}

/* Section Titles */
.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Config Sections */
.config-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.config-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-group select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.helper-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    flex: 1;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Status Messages */
.status-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    animation: slideIn 0.3s ease;
    display: none;
}

.status-message.success {
    display: block;
    background: rgba(75, 252, 126, 0.1);
    border: 1px solid rgba(75, 252, 126, 0.3);
    color: #4bfc7e;
}

.status-message.error {
    display: block;
    background: rgba(245, 87, 108, 0.1);
    border: 1px solid rgba(245, 87, 108, 0.3);
    color: #f5576c;
}

.status-message.info {
    display: block;
    background: rgba(79, 172, 254, 0.1);
    border: 1px solid rgba(79, 172, 254, 0.3);
    color: #4facfe;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 3rem 2rem;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--surface);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-subtext {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Image Gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.image-card {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    animation: scaleIn 0.5s ease;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 255, 255, 0.15);
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    background: rgba(0, 0, 0, 0.3);
}

.image-card-info {
    padding: 1rem;
}

.image-card-prompt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
    max-height: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

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

.image-card-actions button {
    flex: 1;
    padding: 0.625rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.image-card-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.image-card-actions button.btn-inpaint {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.image-card-actions button.btn-inpaint:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.image-card-actions button.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.image-card-actions button.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgb(239, 68, 68);
    transform: translateY(-1px);
}

/* Footer */
.footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-color);
}

.footer-links span {
    margin: 0 0.5rem;
}

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

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 400px 1fr;
    }
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .config-panel {
        order: 1;
    }
    
    .results-panel {
        order: 2;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .usage-display {
        position: static;
        display: flex;
        justify-content: flex-end;
        margin-bottom: 1rem;
    }
    
    .usage-card {
        padding: 0.4rem 0.6rem;
        gap: 0.4rem;
    }
    
    .usage-card svg {
        width: 14px;
        height: 14px;
    }
    
    .usage-count {
        font-size: 1rem;
    }
    
    .config-panel,
    .results-panel {
        padding: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .image-gallery {
        grid-template-columns: 1fr;
    }
}

/* Prompt Queue Styles */
.prompt-queue {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.prompt-queue-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.prompt-queue-item:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.prompt-queue-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
}

.prompt-queue-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
    max-height: 3.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.prompt-queue-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 87, 108, 0.1);
    border: 1px solid rgba(245, 87, 108, 0.3);
    border-radius: 6px;
    color: #f5576c;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.prompt-queue-remove:hover {
    background: rgba(245, 87, 108, 0.2);
    border-color: #f5576c;
    transform: scale(1.1);
}

.prompt-queue-remove:focus {
    outline: 2px solid #f5576c;
    outline-offset: 2px;
}

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

.prompt-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.prompt-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.prompt-actions button svg {
    flex-shrink: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--surface);
    border-radius: 6px;
    border: 2px solid var(--background);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-hover);
}

/* Selection */
::selection {
    background: rgba(102, 126, 234, 0.3);
    color: var(--text-primary);
}

/* Image Upload Styles */
.image-upload-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-upload:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
}

.image-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.image-preview img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    display: block;
    background: rgba(0, 0, 0, 0.3);
}

.btn-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    background: rgba(245, 87, 108, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: rgba(245, 87, 108, 1);
    transform: scale(1.1);
}

/* Mask Editor Styles */
.mask-editor-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(10px);
}

.mask-editor-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.tool-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.tool-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.brush-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.brush-size-control label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.brush-size-control input[type="range"] {
    width: 100px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.brush-size-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.brush-size-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.brush-size-control span {
    min-width: 30px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.canvas-container {
    position: relative;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: crosshair;
}

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