:root {
    --primary-color: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #EFF6FF;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border-color: #E2E8F0;
    --bg-surface: #FFFFFF;
    --bg-app: #F8FAFC;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-app);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    user-select: none;
}

#out {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Splash Screen Container */
#loading-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, #F8FAFC 0%, #EEF2F6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s ease;
}

#loading-splash.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px 44px;
    width: 90%;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.12),
                0 0 0 1px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* App Logo */
.splash-logo-wrapper {
    position: relative;
    width: 72px;
    height: 72px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border: 1px solid #BFDBFE;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.splash-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

/* Titles */
.splash-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.splash-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin: 0 0 28px 0;
    line-height: 1.4;
}

/* Progress Container */
.progress-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-track {
    width: 100%;
    height: 8px;
    background-color: #E2E8F0;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #3B82F6 0%, #1D4ED8 100%);
    border-radius: 999px;
    transition: width 0.25s ease-out;
    position: relative;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

/* Shimmer effect on the progress bar */
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

#progress-status {
    color: var(--text-secondary);
    font-weight: 500;
}

#progress-percent {
    font-weight: 700;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

/* Keep browser-native pan/zoom from acting on the Avalonia host. The CAD/PLAN
   controls must own zoom/pan internally. */
#out {
    touch-action: none;
    overscroll-behavior: none;
}

/* Update Notification Toast */
.update-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    max-width: 440px;
    pointer-events: none;
}

.update-toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #BFDBFE;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 12px 30px -6px rgba(15, 23, 42, 0.18),
                0 4px 10px -2px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    animation: updateToastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.update-toast.dismissing {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
}

@keyframes updateToastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.update-toast-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.update-toast-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
}

.update-toast-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2563EB;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    animation: toastPulse 2s infinite;
}

@keyframes toastPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(37, 99, 235, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

.update-toast-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}

.update-toast-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.update-toast-btn {
    background: var(--primary-color);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.update-toast-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.update-toast-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.update-toast-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.update-toast-close:hover {
    color: var(--text-primary);
    background: #F1F5F9;
}

@media (max-width: 520px) {
    .update-toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }
    
    .update-toast {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px;
    }

    .update-toast-actions {
        width: 100%;
        justify-content: space-between;
    }

    .update-toast-btn {
        flex: 1;
    }
}

/* CAD Drag and Drop Overlay */
.cad-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s ease;
}

.cad-drop-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.cad-drop-box {
    background: #FFFFFF;
    border: 2.5px dashed #2563EB;
    border-radius: 18px;
    padding: 38px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.25);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cad-drop-overlay.visible .cad-drop-box {
    transform: scale(1);
}

.cad-drop-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.cad-drop-title {
    font-size: 20px;
    font-weight: 700;
    color: #1D4ED8;
    margin-bottom: 8px;
}

.cad-drop-sub {
    font-size: 13.5px;
    color: #64748B;
    max-width: 320px;
    line-height: 1.4;
}
