@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@100..800&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #374151;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --editor-bg: #1e1e1e;
    --sidebar-width: 320px;
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading Spinner */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--background);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 16px;
}

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

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

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-title i {
    color: var(--primary-color);
    font-size: 24px;
}

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

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    background: transparent;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    font-weight: 600;
    padding: 10px 20px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--text-muted);
    border-color: var(--text-muted);
    color: var(--background);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    justify-content: center;
    background: transparent;
    position: relative;
}

.btn-icon:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-icon i {
    font-size: 16px;
}

/* Ensure consistent button sizing */
.primary-actions .btn,
.utility-actions .btn {
    min-height: 40px;
    font-size: 14px;
    font-weight: 500;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Main Layout */
.main-container {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.sidebar-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.sidebar-search::placeholder {
    color: var(--text-muted);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Editor Layout */
.editor-container {
    display: flex;
    height: 100%;
    gap: 1px;
    background: var(--border);
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    min-width: 0;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.editor-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Monaco Editor Overrides */
.monaco-editor {
    font-family: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, monospace !important;
}

.monaco-editor .suggest-widget {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
}

/* Status Bar */
.status-bar {
    height: 32px;
    background: var(--surface-light);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-muted);
    justify-content: space-between;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.tab {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Function List */
.function-category {
    margin-bottom: 16px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.category-header:hover {
    background: var(--surface-light);
}

.category-icon {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.category-header.collapsed .category-icon {
    transform: rotate(-90deg);
}

.function-list {
    margin-left: 16px;
    margin-top: 8px;
}

.function-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: 'JetBrains Mono', monospace;
}

.function-item:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.function-item.active {
    background: var(--primary-color);
    color: white;
}

/* Example Cards */
.example-card {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-card:hover {
    border-color: var(--primary-color);
    background: var(--surface);
}

.example-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.example-description {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.example-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    padding: 2px 6px;
    background: var(--background);
    color: var(--text-muted);
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-container {
        flex-direction: column;
    }
    
    .editor-container {
        flex-direction: column;
        height: auto;
    }
    
    .editor-panel {
        min-height: 300px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Error UI */
#blazor-error-ui {
    background: var(--error);
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--error);
}

.validation-message {
    color: var(--error);
    font-size: 0.875rem;
}

/* Modern Playground Header Styles */
.playground-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    max-width: 100%;
    gap: 24px;
}

/* Brand Section */
.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.025em;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-actions {
    gap: 12px;
}

.utility-actions {
    gap: 4px;
}

.action-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

/* Theme Toggle Special Style */
.theme-toggle:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: var(--background);
}

/* Button Loading State */
.btn.loading {
    pointer-events: none;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Notification Dot */
.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

/* Examples Selector */
.header-extras {
    flex-shrink: 0;
}

.example-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    height: 40px;
    min-width: 200px;
}

.selector-icon {
    color: var(--text-muted);
    font-size: 14px;
    margin-right: 8px;
}

.example-selector {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.example-selector option {
    background: var(--surface);
    color: var(--text-primary);
}

.selector-arrow {
    color: var(--text-muted);
    font-size: 12px;
    pointer-events: none;
}

.example-selector-wrapper:hover {
    border-color: var(--primary-color);
}

.example-selector-wrapper:hover .selector-icon,
.example-selector-wrapper:hover .selector-arrow {
    color: var(--primary-color);
}

/* Responsive Header */
@media (max-width: 1200px) {
    .utility-actions {
        gap: 6px;
    }
    
    .utility-actions .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 1024px) {
    .header-container {
        padding: 8px 16px;
        gap: 16px;
    }
    
    .brand-text {
        display: none;
    }
    
    .action-divider {
        display: none;
    }
    
    .utility-actions .btn span {
        display: none;
    }
    
    .utility-actions .btn {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
    }
    
    .utility-actions .btn i {
        margin: 0;
    }
}

@media (max-width: 768px) {
    .header-container {
        padding: 8px 12px;
        gap: 12px;
    }
    
    .example-selector-wrapper {
        min-width: 150px;
    }
    
    .utility-actions {
        gap: 2px;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
    }
}