:root {
    --bg-app: #0f1115;
    --bg-panel: #181b21;
    --bg-input: #22262e;
    --border-color: #2f343e;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: 60px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-main);
}

.logo svg {
    color: var(--primary);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    transition: background-color 0.3s;
}

.status-indicator.connected .dot {
    background-color: #22c55e;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 360px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.select-wrapper {
    position: relative;
}

select,
textarea,
input[type="text"] {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

select:focus,
textarea:focus,
input:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.row-group {
    display: flex;
    gap: 8px;
}

.row-group .select-wrapper {
    flex: 1;
}

.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-input);
}

.file-upload-area:hover {
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.image-preview {
    max-width: 100%;
    max-height: 450px;
    border-radius: var(--radius-sm);

}

.icon-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radio-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.radio-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.radio-card:hover {
    border-color: var(--text-muted);
}

.radio-card.active {
    border-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
}

.radio-card input {
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
}

.ratio-icon {
    border: 1.5px solid currentColor;
    border-radius: 2px;
}

.ratio-icon.square {
    width: 14px;
    height: 14px;
}

.ratio-icon.landscape {
    width: 16px;
    height: 12px;
}

.ratio-icon.portrait {
    width: 12px;
    height: 16px;
}

.ratio-icon.wide {
    width: 18px;
    height: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.gallery-area {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

.text-btn:hover {
    color: var(--text-main);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-input);
    aspect-ratio: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Loader */
.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-panel);
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-grid {
    padding: 24px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    font-size: 12px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Debug Info Panel */
.debug-info-panel {
    margin-top: 24px;
    padding: 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.debug-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.debug-label {
    font-weight: 600;
    color: var(--text-main);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-value {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 4px;
    word-break: break-all;
    max-height: 100px;
    overflow-y: auto;
}

/* History Modal Styles */
.history-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 100%;
}

.history-image {
    width: 100%;
    height: 180px;
    flex-shrink: 0;
    background-color: #000;
    border-bottom: 1px solid var(--border-color);
}

.history-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background-color: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

/* Modal Filters */
.modal-filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-input {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

.history-details {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.history-workflow {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.history-row {
    display: flex;
    gap: 8px;
    font-size: 12px;
    align-items: center;
}

.history-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.history-section .label,
.history-row .label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
}

.prompt-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 4px;
    max-height: 60px;
    overflow-y: auto;
}

.prompt-text.negative {
    color: #ff8a80;
    /* Light red/pink for negative */
}

.monospace {
    font-family: monospace;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

.pagination-controls .btn.small {
    padding: 8px 16px;
    font-size: 13px;
    min-width: 100px;
}

.page-info {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.btn.secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border-color);
    color: var(--text-muted);
}