/* CSS Variables */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2937;
    --bg-card-hover: #374151;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #374151;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: 0.2s;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-right {
    position: relative;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.user-menu:hover {
    background: var(--bg-card);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.user-name {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    min-width: 200px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 200;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dropdown-item.disabled {
    cursor: default;
}

.dropdown-item:not(.disabled):hover {
    background: var(--bg-card-hover);
    cursor: pointer;
}

.dropdown-item.logout {
    color: var(--danger);
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 250px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1rem;
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 90;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 80;
}

@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
    }

    .menu-toggle {
        display: none;
    }
}

/* Nav Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--bg-primary);
}

@media (min-width: 768px) {
    .main-content {
        left: 251px; /* 250px sidebar + 1px border */
        padding: 1.5rem 2rem;
    }
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2.5rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-btn .ms-icon {
    width: 20px;
    height: 20px;
}

.login-card .domains {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.stat-card .icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.stat-card .icon svg {
    width: 20px;
    height: 20px;
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* File Upload */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.dropzone svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.dropzone p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.dropzone .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* File List */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.file-item.selected {
    border-color: var(--accent);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-icon {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
}

.file-name {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.icon-btn.danger:hover {
    color: var(--danger);
}

/* Progress */
.progress {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.badge-blue { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-green { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-yellow { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-red { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}
.alert-info strong {
    color: #60a5fa;
}
.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* Feedback Button */
.feedback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    margin-right: 0.5rem;
}

.feedback-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Feedback Success State */
.feedback-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem 0;
}

.feedback-success svg {
    color: var(--success);
    margin-bottom: 1rem;
}

.feedback-success p {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* Header Right Layout */
.header-right {
    display: flex;
    align-items: center;
    position: relative;
}

/* Job Status */
.job-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.job-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.job-id {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 640px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Utilities */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }

/* Blazor Error UI */
#blazor-error-ui {
    background: var(--danger);
    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;
}

#blazor-error-ui .reload {
    color: white;
    margin-left: 0.5rem;
}
