/* BCGR Web UI Styles */

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-hover: #252525;
    --text: #ffffff;
    --text-muted: #888;
    --border: #333;
    --success: #22c55e;
    --error: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Main content */
main {
    flex: 1;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface);
}

.drop-zone:hover,
.drop-zone.highlight {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.drop-zone:hover .upload-icon,
.drop-zone.highlight .upload-icon {
    color: var(--primary);
}

.drop-text {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.drop-hint {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.formats {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Status */
.status {
    text-align: center;
    padding: 3rem;
}

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

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

#statusText {
    color: var(--text-muted);
}

/* Results */
.results {
    margin-top: 2rem;
}

.results h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

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

.result-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.result-card.error {
    border-color: var(--error);
}

.preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.preview {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

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

.preview .label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Checkerboard pattern for transparency */
.checkerboard {
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #222;
}

/* Background Color Picker */
.bg-color-picker {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.color-options {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.color-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: var(--text-muted);
}

.color-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.checkerboard-small {
    background-image:
        linear-gradient(45deg, #666 25%, transparent 25%),
        linear-gradient(-45deg, #666 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #666 75%),
        linear-gradient(-45deg, transparent 75%, #666 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    background-color: #444;
}

.color-input {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.card-info {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filename {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.time {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.error-content {
    padding: 1.5rem;
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

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

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

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

.btn-download:hover {
    filter: brightness(1.1);
}

#downloadAll {
    margin-top: 1.5rem;
}

/* Settings Panel */
.settings-panel {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: 1rem;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    font-size: 1.25rem;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-group label {
    font-weight: 500;
    color: var(--text-muted);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

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

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

.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: 1rem auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Results Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Compact Result Cards */
.result-card-compact {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.result-preview {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.result-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-actions {
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* Card Toolbar */
.card-toolbar {
    padding: 0.5rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
}

.toolbar-colors {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.color-dot:hover {
    transform: scale(1.15);
    border-color: var(--text-muted);
}

.color-dot.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.color-dot-input {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
    overflow: hidden;
}

.color-dot-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-dot-input::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.toolbar-actions {
    display: flex;
    gap: 0.35rem;
}

.tool-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: var(--surface-hover);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--error);
}

.modal-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image-container img {
    max-width: 40vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

.modal-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.tab-btn {
    padding: 0.75rem 2rem;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

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

.mode-content {
    /* Default display */
}

/* Inpaint Editor */
.inpaint-editor {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.inpaint-toolbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-group label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.tool-group input[type="range"] {
    width: 120px;
    accent-color: var(--primary);
}

.inpaint-canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
}

#inpaintCanvas {
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: crosshair;
    max-width: 100%;
}

.inpaint-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

.inpaint-result {
    margin-top: 1.5rem;
    text-align: center;
}

.inpaint-result h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.inpaint-result img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.inpaint-result .result-actions {
    margin-top: 1rem;
    justify-content: center;
}

/* Inpaint Modal */
.inpaint-modal-content {
    max-width: 800px;
    width: 90vw;
}

.inpaint-modal-content h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

/* Tool Toggle */
.tool-toggle {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tool-toggle:first-child {
    border-radius: 6px 0 0 6px;
}

.tool-toggle:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.tool-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tool-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .preview-container {
        grid-template-columns: 1fr;
    }

    .card-info {
        flex-wrap: wrap;
    }
}
