/* ==========================================================================
   PT Intelligence - Design System & Engineering Workspace Styles
   Ultra-Modern Glassmorphism & High-Precision Dark Theme
   ========================================================================== */

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

:root {
    --bg-base: #060913;
    --bg-surface: #0b1120;
    --bg-surface-elevated: #111a2e;
    --bg-card: rgba(17, 26, 46, 0.75);
    --bg-glass: rgba(15, 23, 42, 0.82);
    
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-bright: rgba(56, 189, 248, 0.35);

    --primary-cyan: #0284c7;
    --primary-glow: #38bdf8;
    --accent-emerald: #10b981;
    --accent-orange: #f97316;
    --accent-violet: #8b5cf6;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #020617;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', "Consolas", monospace;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

/* Header & Top Navigation */
.app-header {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

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

.brand-logo-badge {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary-glow) 0%, var(--primary-cyan) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

.brand-title-group h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-version {
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 2px 6px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: var(--primary-glow);
    border-radius: var(--radius-sm);
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.project-quick-selector {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
}

.user-avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: #fff;
}

.user-name-role {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
}

.user-role-badge {
    font-size: 10px;
    color: var(--primary-glow);
}

/* Main Workspace with Sidebar */
.workspace-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Navigation */
.app-sidebar {
    width: 240px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 12px;
}

.nav-group-title {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-top: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(2, 132, 199, 0.18) 0%, rgba(56, 189, 248, 0.05) 100%);
    border-left: 3px solid var(--primary-glow);
    color: var(--primary-glow);
    font-weight: 600;
}

.nav-link .icon {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.nav-counter {
    margin-left: auto;
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
}

/* Main Content Workspace */
.main-viewport {
    flex: 1;
    background: var(--bg-base);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Module Container */
.module-view {
    display: none;
    padding: 24px;
    flex: 1;
}

.module-view.active {
    display: flex;
    flex-direction: column;
}

/* Metric Cards Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--primary-glow));
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 8px;
    letter-spacing: -0.03em;
    font-family: var(--font-sans);
}

.metric-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tables */
.data-table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.015);
}

.table-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    text-align: left;
    padding: 12px 18px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
}

table.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

table.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

table.data-table tr.selected {
    background: rgba(2, 132, 199, 0.12);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.badge-hp {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: #38bdf8;
}

.badge-lp {
    background: rgba(249, 115, 22, 0.15);
    border: 1px solid rgba(249, 115, 22, 0.4);
    color: #fb923c;
}

.badge-verified {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
}

.badge-review {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

/* CAD Viewer Workspace */
.cad-workspace-container {
    display: flex;
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #090e1a;
}

.cad-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
}

canvas#cadCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* CAD Floating HUD Toolbar */
.cad-hud-toolbar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
    box-shadow: var(--shadow-md);
}

.cad-tool-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
}

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

.cad-tool-btn.active {
    background: var(--primary-cyan);
    color: #fff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* CAD Coordinate Status Bar */
.cad-status-bar {
    position: absolute;
    bottom: 12px;
    left: 20px;
    right: 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    z-index: 20;
}

.coord-readout {
    display: flex;
    align-items: center;
    gap: 16px;
}

.coord-item span {
    color: var(--primary-glow);
    font-weight: 600;
}

/* Side Panels in CAD Viewer */
.cad-side-panel {
    width: 340px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Layer Checklist */
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 12px;
}

.layer-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-cyan) 0%, #0369a1 100%);
    color: #fff;
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 0 16px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0284c7 0%, var(--primary-glow) 100%);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.55);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: var(--radius-sm);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

.modal-body {
    padding: 22px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-surface-elevated);
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary-glow);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* File Drop Zone */
.upload-dropzone {
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.015);
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary-glow);
    background: rgba(56, 189, 248, 0.04);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-glow);
    margin-bottom: 12px;
}
