:root {
    /* MagicWand 2.0 - Copilot Light Semantic Palette */
    --brand-bg: #f8fafc; /* Very light slate */
    --brand-surface: #ffffff;
    --brand-border: rgba(0, 0, 0, 0.08);
    --brand-text: #0f172a;
    --brand-muted: #64748b;
    
    /* Semantic Colors */
    --accent-blue: #2563eb;
    --accent-green: #10b981;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    
    /* Gradients */
    --grad-blue: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --grad-surface: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0) 100%);
}

body.theme-copilot {
    background-color: var(--brand-bg);
    color: var(--brand-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.01em;
}

/* Sidebar Navigation */
.copilot-sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--brand-surface);
    border-right: 1px solid var(--brand-border);
    padding: 1.5rem 1rem;
    z-index: 1000;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--brand-border);
    margin-bottom: 1.5rem;
    text-decoration: none;
    color: var(--brand-text);
}

.sidebar-logo img {
    height: 32px;
    border-radius: 6px;
}

.sidebar-footer {
    color: var(--brand-text);
}

.sidebar-signout-form {
    margin-top: 0.2rem;
}

.sidebar-signout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--brand-muted);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-signout-btn:hover {
    color: var(--accent-red);
}

.nav-pill-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: var(--brand-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.nav-pill-custom:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--brand-text);
}

.nav-pill-custom.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent-blue);
}

/* Main Content Area */
.copilot-main {
    margin-left: 260px;
    padding: 2rem 3rem;
    min-height: 100vh;
}

/* Hero Section / Welcome */
.welcome-header h1 {
    font-weight: 800;
    color: var(--brand-text);
}

/* Action Cards */
.copilot-card {
    background: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.copilot-card:hover {
    border-color: rgba(37, 99, 235, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.icon-box {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
}

.icon-blue { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.icon-green { background: rgba(16, 185, 129, 0.1); color: #059669; }
.icon-amber { background: rgba(217, 119, 6, 0.1); color: #d97706; }
.icon-red { background: rgba(220, 38, 38, 0.1); color: #dc2626; }

/* Status Badges */
.status-pill {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

/* Modern Compact Tables for Manufacturing */
.table-copilot {
    background: var(--brand-surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--brand-border);
    font-size: 0.875rem;
}

.table-copilot thead th {
    background: #f1f5f9;
    color: var(--brand-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 1px solid var(--brand-border);
}

.table-copilot tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--brand-border);
    color: var(--brand-text);
}

.table-copilot tbody tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

/* Badge System */
.badge-copilot {
    padding: 0.4em 0.8em;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-success-soft { background: #ecfdf5; color: #059669; }
.badge-warning-soft { background: #fffbeb; color: #d97706; }
.badge-danger-soft { background: #fef2f2; color: #dc2626; }
.badge-primary-soft { background: #eff6ff; color: #2563eb; }

/* Page Header Utility */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--brand-text);
}

.page-subtitle {
    color: var(--brand-muted);
    font-size: 0.95rem;
}

/* AI Chat Overlay System */
.ai-portal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(248, 250, 252, 0.98);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(1.02); }
    to { opacity: 1; transform: scale(1); }
}

.ai-portal-content {
    max-width: 800px;
    width: 100%;
    text-align: center;
}

.ai-portal-avatar {
    width: 80px;
    height: 80px;
    background: var(--grad-blue);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    margin: 0 auto 2rem;
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.2);
}

.ai-portal-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--brand-text);
}

.ai-portal-input-container {
    background: white;
    border: 2px solid var(--accent-blue);
    border-radius: 20px;
    padding: 0.5rem;
    display: flex;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    margin-bottom: 2.5rem;
}

.ai-portal-input {
    border: none;
    flex-grow: 1;
    padding: 1rem;
    font-size: 1.25rem;
    outline: none;
    color: var(--brand-text);
}

.ai-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.ai-suggestion-card {
    background: white;
    border: 1px solid var(--brand-border);
    padding: 1.25rem;
    border-radius: 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-suggestion-card:hover {
    border-color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.02);
    transform: translateY(-2px);
}

.ai-portal-meta {
    min-height: 1.5rem;
    margin: -1rem 0 1.5rem;
}

.ai-portal-meta .form-select {
    max-width: 260px;
}

.ai-match-count-select {
    max-width: 140px;
}

.ai-gasket-id-input {
    max-width: 260px;
}

.ai-share-password-input {
    max-width: 320px;
}

.ai-share-link-box {
    max-width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.ai-category-row {
    display: flex;
    align-items: end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ai-design-match-link {
    white-space: nowrap;
}

.ai-portal-status {
    min-height: 1.25rem;
}

.ai-result-panel {
    width: 100%;
}

.ai-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ai-result-panel .card {
    border-radius: 16px;
}

.ai-result-panel .table th,
.ai-result-panel .table td {
    padding: 0.9rem 1rem;
}

.ai-close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--brand-muted);
    cursor: pointer;
}

.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.78);
    backdrop-filter: blur(4px);
}

.app-loading-card {
    min-width: 260px;
    max-width: 360px;
    padding: 1.25rem 1.5rem;
    border-radius: 18px;
    border: 1px solid var(--brand-border);
    background: rgba(255, 255, 255, 0.96);
    text-align: center;
}

.app-loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: 0.9rem;
}

.app-loading-title {
    color: var(--brand-text);
    margin-bottom: 0.35rem;
}

body.app-loading-active {
    overflow: hidden;
}
