/* StereogrammerWeb — Dark glassmorphism theme */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-glass: rgba(17, 24, 39, 0.75);
    --bg-glass-hover: rgba(30, 41, 59, 0.85);
    --border-glass: rgba(148, 163, 184, 0.12);
    --border-accent: rgba(99, 102, 241, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 0;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 10;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #a78bfa, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    overflow-y: auto;
    padding: 16px;
    gap: 16px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

/* ── Panel Sections ────────────────────────────────────────── */
.panel-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* ── Controls ──────────────────────────────────────────────── */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-glass);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

input[type="number"],
input[type="text"] {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    width: 100%;
    outline: none;
    transition: border-color var(--transition);
}

input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Radio group */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.radio-label input[type="radio"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.fixed-inputs {
    display: flex;
    gap: 6px;
}

.fixed-inputs input {
    width: 50%;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), #a78bfa);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

/* ── Depth Map Preview ─────────────────────────────────────── */
.depth-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.depth-upload-area:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.depth-upload-area .upload-icon {
    font-size: 1.5rem;
    opacity: 0.5;
}

.depth-upload-area .upload-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

#depth-preview {
    width: 100%;
    max-height: 100px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

#depth-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ── Texture Grid ──────────────────────────────────────────── */
.texture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.texture-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: rgba(30, 41, 59, 0.4);
    cursor: pointer;
    transition: all var(--transition);
}

.texture-card:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass);
}

.texture-card.selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 12px var(--accent-glow);
}

.texture-preview {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    background-color: #1e293b;
    background-position: center;
    background-repeat: no-repeat;
}

.texture-preview.grey-dots-preview {
    background-image: repeating-conic-gradient(
        #555 0% 25%, #333 0% 50%
    );
    background-size: 8px 8px;
    filter: grayscale(1) contrast(0.5);
}

.texture-preview.colour-dots-preview {
    background: conic-gradient(
        from 45deg,
        #6366f1, #ec4899, #f59e0b, #22c55e, #6366f1
    );
    filter: saturate(0.7) contrast(0.6);
}

.texture-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
    text-align: center;
}

.remove-texture-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    line-height: 1;
}

.texture-card:hover .remove-texture-btn {
    opacity: 1;
}

.remove-texture-btn:hover {
    background: var(--danger-hover);
}

/* ── Output Area ───────────────────────────────────────────── */
.output-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(236, 72, 153, 0.04) 0%, transparent 60%),
        var(--bg-primary);
}

.output-wrapper {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#output-canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: #0f172a;
    border: 1px solid var(--border-glass);
}

.output-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.output-empty .empty-icon {
    font-size: 3rem;
    opacity: 0.3;
}

/* ── Export Overlay ─────────────────────────────────────────── */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.export-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 320px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-dialog h2 {
    font-size: 1rem;
    font-weight: 600;
}

.export-dialog .dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

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

.divider {
    height: 1px;
    background: var(--border-glass);
    margin: 4px 0;
}

/* Hidden file inputs */
#depth-upload,
#texture-upload {
    display: none;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        max-height: 50vh;
        overflow-y: auto;
    }

    .panel-section {
        min-width: 200px;
        flex: 1;
    }

    .texture-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.texture-card {
    animation: fadeIn 0.3s ease-out;
}

/* Subtle pulse on generate button when ready */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 2px 12px var(--accent-glow); }
    50% { box-shadow: 0 4px 24px rgba(99, 102, 241, 0.5); }
}

.btn-primary:not(:disabled) {
    animation: pulse-glow 3s ease-in-out infinite;
}

.btn-primary:hover:not(:disabled) {
    animation: none;
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    overflow: hidden;
    z-index: 20;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ec4899);
    width: 0%;
    transition: width 0.2s linear;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* ── Info Tooltip ──────────────────────────────────────────── */
.header-title-wrapper {
    position: relative;
    cursor: help;
}

.info-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 12px;
    width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
    color: var(--text-secondary);
    font-size: 0.8rem;
    pointer-events: none;
}

.header-title-wrapper:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.info-tooltip p {
    margin-bottom: 6px;
}

.info-tooltip p:last-child {
    margin-bottom: 0;
}

.info-tooltip a {
    color: var(--accent);
    text-decoration: none;
}

.info-tooltip a:hover {
    text-decoration: underline;
}

.info-tooltip .small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

