:root {
    --bg-main: #0c0e14;
    --bg-surface: #141722;
    --bg-panel: rgba(20, 23, 34, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --accent-purple: #8b5cf6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

#app {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Topbar */
.topbar {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
}

.brand-info h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #c084fc;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 2px;
}

.ai-badge i {
    width: 12px;
    height: 12px;
}

.project-metrics {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px 18px;
    border-radius: var(--radius-md);
}

.metric {
    display: flex;
    flex-direction: column;
}

.metric .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric .value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.metric-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 14px var(--accent-glow);
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* 3D Canvas Viewport */
#canvasContainer {
    flex: 1;
    position: relative;
    width: 100%;
    height: calc(100vh - 64px);
    overflow: hidden;
}

#webglCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Viewport Overlays */
.viewport-overlay {
    position: absolute;
    z-index: 50;
    pointer-events: none;
}

.viewport-overlay * {
    pointer-events: auto;
}

.viewport-overlay.top-right {
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn i {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: rgba(30, 35, 52, 0.9);
}

.icon-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
}

/* Left Panel */
.viewport-overlay.left-panel {
    top: 20px;
    left: 20px;
    width: 250px;
}

.panel-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-header h3 {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-header h3 i {
    width: 14px;
    height: 14px;
}

.floor-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.floor-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.floor-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.floor-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-glow);
}

.slider-group {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.slider-header span:first-child {
    display: flex;
    align-items: center;
    gap: 4px;
}

.slider-header span:first-child i {
    width: 12px;
    height: 12px;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent);
}

/* Layer Drawer */
.drawer {
    position: absolute;
    top: 64px;
    right: 0;
    width: 360px;
    height: calc(100vh - 64px);
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-header h3 {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.layer-category {
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.category-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-title.wall { color: #60a5fa; }
.category-title.column { color: #f87171; }
.category-title.window { color: #38bdf8; }
.category-title.door { color: #fbbf24; }
.category-title.slab { color: #a78bfa; }
.category-title.ignore { color: var(--text-muted); }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 14, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-overlay h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.loading-overlay p {
    font-size: 13px;
    color: var(--text-muted);
}


/* Element Inspector Card */
.element-inspector {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 280px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
    z-index: 50;
    animation: fadeIn 0.2s ease-out;
}

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

.inspector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.inspector-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inspector-icon {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.inspector-header h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.inspector-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.inspector-row:last-child {
    border-bottom: none;
}

.inspector-row .label {
    color: var(--text-muted);
}

.inspector-row .val {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: 500;
}

/* AI Summary Card in Drawer */
.ai-summary-card {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 20px;
}

.ai-summary-card h4 {
    font-size: 13px;
    font-weight: 700;
    color: #c084fc;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.rule-list {
    list-style: none;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rule-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
    color: var(--text-secondary);
}

.rule-list li strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.category-title.roof { color: #f97316; }
.category-title.room { color: #10b981; }

/* 3D Room Badge Overlay */
.room-badge-3d {
    position: absolute;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #93c5fd;
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
}

.room-badge-3d:hover {
    background: rgba(37, 99, 235, 0.9);
    color: #ffffff;
    border-color: #60a5fa;
    transform: translate(-50%, -55%) scale(1.05);
}

/* FPS Crosshair */
.walk-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.7);
    border-radius: 50%;
    pointer-events: none;
    z-index: 105;
}

/* Door Interaction HUD Prompt */
.door-prompt {
    position: absolute;
    top: 54%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(56, 189, 248, 0.7);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    z-index: 110;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
    animation: promptPulse 1.2s infinite alternate ease-in-out;
}

@keyframes promptPulse {
    from { transform: translate(-50%, -50%) scale(1); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }
    to { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 6px 22px rgba(56, 189, 248, 0.4); }
}

.door-prompt kbd {
    background: #2563eb;
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 8px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 1. Şahıs Gezinti HUD (Walk HUD) */
.walk-hud {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 12px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.walk-hud-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 12px;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
}

.walk-hud-tips {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

.walk-hud-tips kbd {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #f1f5f9;
}

/* Material & Color Customizer in Element Inspector */
.customizer-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.customizer-box h5 {
    font-size: 12px;
    font-weight: 600;
    color: #38bdf8;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.swatch-group {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.color-swatch-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    outline: none;
}

.color-swatch-btn:hover {
    transform: scale(1.15);
    border-color: #38bdf8;
}

.custom-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.custom-picker-row input[type="color"] {
    border: none;
    width: 32px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.material-btn-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.material-opt-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.material-opt-btn:hover {
    background: #334155;
    border-color: #38bdf8;
    color: #ffffff;
}

.btn-danger {
    background: #dc2626 !important;
    color: #ffffff !important;
    border: none !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
}
