/* ═══════════════════════════════════════════════════════
   PrintGen.ai – Design System
   Industrial-Futuristic / CNC-Workshop Ästhetik
   ═══════════════════════════════════════════════════════ */

/* ─── CSS Variablen ─── */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --bg-input: #14141e;
    --border: #2a2a3a;
    --border-hover: #3a3a4a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #5a5a70;
    --accent: #00e5a0;
    --accent-dim: rgba(0, 229, 160, 0.15);
    --accent-glow: rgba(0, 229, 160, 0.4);
    --cyan: #00b4d8;
    --red: #ff4d6a;
    --red-dim: rgba(255, 77, 106, 0.15);
    --yellow: #ffb800;
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'DM Sans', sans-serif;
    --sidebar-width: 420px;
    --radius: 8px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

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

/* hidden-Attribut muss immer gewinnen */
[hidden] {
    display: none !important;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

/* ─── App Layout ─── */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ═══ SIDEBAR ═══ */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    color: var(--accent);
    display: flex;
}

.logo-accent {
    color: var(--accent);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

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

/* ─── Labels ─── */
.input-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    cursor: default;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ─── Prompt Textarea ─── */
.prompt-wrapper {
    position: relative;
}

.prompt-input {
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    padding-right: 80px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition);
}

.prompt-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.prompt-input::placeholder {
    color: var(--text-muted);
}

.prompt-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 4px;
}

/* ─── Buttons ─── */
.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon.recording {
    background: var(--red-dim);
    border-color: var(--red);
    color: var(--red);
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 106, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 77, 106, 0); }
}

.btn-lang {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    width: auto;
    padding: 0 8px;
}

.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    border: none;
    border-radius: var(--radius);
    color: var(--bg-primary);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

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

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

.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
}

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

.btn-sm {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-sm:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ─── Voice Status ─── */
.voice-status {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    padding: 6px 10px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
    animation: fade-in 0.2s ease;
}

/* ─── Drop Zone ─── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.drop-zone-content svg {
    color: var(--text-muted);
}

.image-preview {
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.btn-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid var(--bg-secondary);
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Chips ─── */
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* ─── Size Editor ─── */
.panel-collapsible .panel-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-toggle {
    width: 100%;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
}

.panel-toggle .chevron {
    transition: transform var(--transition);
}

.panel-collapsible.open .panel-toggle .chevron {
    transform: rotate(180deg);
}

.size-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.size-axis {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    width: 16px;
    text-align: center;
}

.size-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

.size-num {
    width: 52px;
    padding: 4px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: center;
}

.size-num:focus {
    outline: none;
    border-color: var(--accent);
}

.size-unit {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    width: 14px;
}

.size-mm {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.size-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-lock {
    transition: all var(--transition);
}

.btn-lock.active svg {
    color: var(--accent);
}

.size-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--red-dim);
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 12px;
}

/* ─── Code Preview ─── */
.code-preview {
    max-height: 200px;
    overflow: auto;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ─── Status Log ─── */
.status-log {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.status-entry {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.status-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 44px;
}

.status-msg {
    color: var(--text-secondary);
    line-height: 1.4;
}

.status-msg.error {
    color: var(--red);
}

.status-msg.success {
    color: var(--accent);
}

/* ═══ VIEWPORT ═══ */
#viewport {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ─── Model Info ─── */
.model-info {
    position: absolute;
    bottom: 16px;
    left: 16px;
    padding: 6px 12px;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    backdrop-filter: blur(8px);
}

.info-sep {
    color: var(--border);
}

/* ─── View Presets ─── */
.view-presets {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
}

.btn-view {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.btn-view:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-view.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Loading Overlay ─── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
}

/* ─── Animationen ─── */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #viewport {
        min-height: 50vh;
    }

    .sidebar-header {
        padding: 12px 16px;
    }

    .sidebar-content {
        padding: 12px 16px;
        gap: 14px;
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 100%;
    }

    .prompt-input {
        min-height: 60px;
        font-size: 16px; /* Verhindert Zoom auf iOS */
    }

    .chip {
        font-size: 10px;
        padding: 5px 10px;
    }

    .btn-primary {
        padding: 12px 16px;
        font-size: 14px;
    }

    .view-presets {
        top: 8px;
        right: 8px;
    }

    .btn-view {
        width: 30px;
        height: 30px;
        font-size: 10px;
    }
}
