:root {
    --bg-dark: #0a0e17;
    --bg-panel: #111827;
    --bg-card: #1f2937;
    --blueprint-grid: #1e3a8a;
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.4);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --success: #10b981;
    --focus: #f59e0b;
    --border: #374151;
    --font-sans: 'Noto Sans KR', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

/* Utilities */
.mono-text {
    font-family: var(--font-mono);
    color: var(--cyan);
}

.hidden { display: none !important; }
.active { display: flex !important; }

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.primary-btn {
    background-color: var(--cyan);
    color: var(--bg-dark);
    box-shadow: 0 0 10px var(--cyan-glow);
}
.primary-btn:hover {
    background-color: #0891b2;
    box-shadow: 0 0 15px var(--cyan-glow);
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}
.secondary-btn:hover {
    background-color: rgba(255,255,255,0.05);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--cyan);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.header-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    gap: 2rem;
}

.highlight { color: var(--text-main); font-weight: 500; }
.status-ready { color: var(--text-muted); }
.status-analyzing { color: var(--focus); animation: pulse 1.5s infinite; }
.status-done { color: var(--success); }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.left-panel { flex: 3; position: relative; }
.right-panel { flex: 2; position: relative; }

/* Cards */
.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

/* Upload Section */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 4rem 2rem;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background-color: var(--bg-card);
    transition: border-color 0.3s;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--cyan);
    background-color: rgba(6, 182, 212, 0.05);
}

.upload-icon {
    font-size: 4rem;
    color: var(--text-muted);
}
.upload-area p { color: var(--text-muted); margin-bottom: 1rem; }

/* Scanning Section */
.scanner-container {
    position: relative;
    width: 300px;
    height: 300px;
    border: 1px solid var(--cyan);
    margin-bottom: 2rem;
    background-size: 20px 20px;
    background-image: 
        linear-gradient(to right, rgba(6, 182, 212, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.1) 1px, transparent 1px);
    overflow: hidden;
}

#scan-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.5;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--cyan);
    box-shadow: 0 0 10px 2px var(--cyan);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

.spin-icon { animation: spin 2s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.scan-text h3 { margin-bottom: 0.5rem; color: var(--cyan); display: flex; align-items: center; justify-content: center; gap: 0.5rem;}
#scan-log { font-size: 0.875rem; color: var(--text-muted); }

/* Turnaround Display */
.views-card {
    justify-content: flex-start;
    padding: 1.5rem;
}

.view-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.turnaround-display {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sheet-container {
    position: relative;
    flex: 1;
    background-color: #0d47a1;
    border: 1px solid var(--cyan);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.blueprint-bg {
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

.generated-views {
    display: flex;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.view-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px dashed rgba(255,255,255,0.2);
    position: relative;
    padding: 2rem;
}
.view-pane:last-child {
    border-right: none;
}

.pane-label {
    position: absolute;
    bottom: 10px;
    font-size: 0.75rem;
    padding: 2px 6px;
    background-color: rgba(0,0,0,0.5);
    border: 1px solid var(--border);
}

.dynamic-view {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Apply blueprint filter to make it look like a CAD drawing */
    filter: grayscale(100%) invert(1) contrast(200%) sepia(100%) hue-rotate(180deg) saturate(300%) brightness(150%) opacity(0.8) drop-shadow(0 0 2px rgba(255,255,255,0.5));
    transition: transform 0.5s ease;
}

/* The visual tricks to simulate turnaround */
.front-view {
    transform: none;
}
.side-view {
    /* Compress width to simulate a side profile */
    transform: scaleX(0.45);
}
.back-view {
    /* Flip horizontally to simulate looking from behind */
    transform: scaleX(-1);
}

.grid-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
}

.sheet-container .mono-text {
    position: absolute;
    font-size: 0.75rem;
    padding: 2px 6px;
    background-color: rgba(0,0,0,0.5);
    border: 1px solid var(--border);
}

.label-front { bottom: 10%; left: 15%; }
.label-side { bottom: 10%; left: 45%; }
.label-back { bottom: 10%; left: 75%; }

.reference-box {
    height: 120px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
}

.reference-box .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}

#original-ref {
    height: 100%;
    width: 100px;
    object-fit: contain;
    border: 1px solid var(--border);
}

/* Dashboard (Right Panel) */
.dashboard-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    color: var(--text-main);
}

.evaluation-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
}

.tab-content-container {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.tab-pane {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}
.tab-pane.active { display: flex; }

/* Result Cards inside Tabs */
.result-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.result-card.success { border-left: 4px solid var(--success); }
.result-card.focus { border-left: 4px solid var(--focus); }

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.check-icon { color: var(--success); }
.focus-icon { color: var(--focus); }

.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.data-item {
    display: flex;
    flex-direction: column;
    background-color: rgba(0,0,0,0.2);
    padding: 0.75rem;
    border-radius: 4px;
}

.data-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.data-value { font-size: 1rem; font-weight: 500; margin-top: 0.25rem; }

.highlight-box {
    grid-column: span 2;
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.highlight-box .data-value { color: var(--success); font-size: 1.25rem; }

.report-desc {
    font-size: 0.875rem;
    color: #cbd5e1;
    line-height: 1.5;
    background-color: rgba(255,255,255,0.02);
    padding: 1rem;
    border-radius: 4px;
    border-left: 2px solid var(--border);
}

/* Simulations (Tab Content visuals) */
.visual-analysis {
    background-color: #000;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 1px solid var(--border);
}

.simulation-box {
    position: relative;
    height: 150px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-bottom: 2px solid #333;
}

.eye-level-line {
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    height: 1px;
    border-top: 1px dashed var(--focus);
}

.eye-level-line::after {
    content: 'Eye-level (1.2m)';
    position: absolute;
    right: 5px;
    top: -20px;
    font-size: 10px;
    color: var(--focus);
    font-family: var(--font-mono);
}

.analysis-stats p {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.harmony-sim .road-bg {
    height: 150px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.island {
    width: 120px;
    height: 40px;
    background-color: #333;
    border-radius: 50%;
    position: absolute;
    bottom: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border: 2px solid #555;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.final-overlay {
    height: 100px;
    margin-bottom: 10px;
    filter: brightness(1.2) contrast(1.2);
    opacity: 0.9;
    drop-shadow: 0 10px 5px rgba(0,0,0,0.8);
}

.blueprint-img-small {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
}

/* Dashboard Mask */
.dashboard-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(4px);
    z-index: 10;
    display: none; /* hidden by default, toggled with class active */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.dashboard-mask.active { display: flex; }
.lock-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .workspace { flex-direction: column; }
    .turnaround-display { height: 400px; }
}