:root {
    --bg-dark: #07090e;
    --panel-bg: rgba(13, 17, 28, 0.7);
    --panel-border: rgba(255, 255, 255, 0.07);
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.4);
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #7c3aed 100%);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --green-glow: #10b981;
    --red-glow: #ef4444;
}

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

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

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* 1. Sidebar Panel */
.control-panel {
    width: 380px;
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
}

.logo-header {
    padding: 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-gradient);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
}

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

.logo-highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.panel-section {
    padding: 24px;
    border-bottom: 1px solid var(--panel-border);
}

.panel-section h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Custom Dropdown Input */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.styled-select {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.styled-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Dynamic Sliders styling */
.sliders-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.slider-value {
    font-weight: 600;
    color: var(--text-primary);
}

.styled-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background 0.3s;
}

.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, background-color 0.3s;
}

.styled-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.styled-range:focus::-webkit-slider-thumb {
    background: var(--accent);
}

/* Skeleton loaders */
.skeleton-loader {
    height: 24px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    border-radius: 6px;
    margin-bottom: 12px;
}

@keyframes loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Actions Section */
.actions-section {
    margin-top: auto;
    border-bottom: none;
}

.btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

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

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.panel-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--panel-border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green-glow);
}

.status-offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red-glow);
}

/* 2. Viewport Area */
.viewport-area {
    flex-grow: 1;
    position: relative;
    height: 100%;
}

#canvas-container {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #111422 0%, #06080e 100%);
}

/* 3. Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 8, 14, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--accent-glow);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 4. Logs Console */
.logs-console {
    position: absolute;
    bottom: 24px;
    right: 24px;
    left: 24px;
    height: 200px;
    background: rgba(10, 12, 19, 0.85);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
    transition: all 0.3s ease;
}

.logs-console.minimized {
    height: 48px;
    width: 450px;
    left: auto;
}

.logs-header {
    padding: 12px 18px;
    background: rgba(20, 24, 38, 0.5);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.logs-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--green-glow);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.logs-header h3 {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.logs-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logs-ping-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    margin-right: 8px;
    transition: color 0.2s;
}

.logs-ping-toggle:hover {
    color: var(--text-secondary);
}

.logs-ping-toggle input {
    cursor: pointer;
    accent-color: var(--accent);
}

.logs-console.minimized .logs-ping-toggle {
    display: none !important;
}

.logs-header button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s;
}

.logs-header button:hover {
    color: var(--text-primary);
}

.logs-header button.btn-diagnostics {
    color: #60a5fa; /* Blue accent */
    font-weight: 600;
}

.logs-header button.btn-diagnostics:hover {
    color: #93c5fd;
}

.logs-body {
    flex-grow: 1;
    padding: 12px 18px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Logging color themes */
.log-line {
    color: #e5e7eb;
    word-break: break-all;
    white-space: pre-wrap;
}

.log-api { color: #38bdf8; }     /* cyan */
.log-cad { color: #34d399; }     /* mint-green */
.log-web { color: #f472b6; }     /* pink */
.log-cad-cli { color: #fbbf24; } /* orange/yellow */
.log-error { color: #f87171; font-weight: 600; } /* light-red */
.log-warning { color: #fb7185; } /* peach-rose */

/* 5. Toast Notifications */
.toast {
    position: absolute;
    top: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 8px;
    background: rgba(13, 17, 28, 0.95);
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 120;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.toast-error {
    border-left-color: var(--red-glow);
}

.toast.toast-success {
    border-left-color: var(--green-glow);
}

/* 6. Mobile Responsiveness */
.sidebar-toggle-btn {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: rgba(13, 17, 28, 0.9);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 80;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.sidebar-toggle-btn:hover {
    background: var(--accent-gradient);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.panel-backdrop {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 5, 9, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.panel-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: flex;
    }

    .sidebar-close-btn {
        display: block;
    }

    .control-panel {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 320px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
    }

    .control-panel.expanded {
        transform: translateX(0);
    }

    .logs-console {
        display: none !important;
    }

    .toast {
        top: auto;
        bottom: 24px;
        left: 16px;
        right: 16px;
        font-size: 0.85rem;
    }
}
