/* ============================================
   AzureInsight — Global Theme
   ============================================ */

:root {
    --ai-primary: #0078d4;
    --ai-primary-dark: #005a9e;
    --ai-primary-light: #deecf9;
    --ai-accent: #00b7c3;
    --ai-sidebar-bg: #1b1f3b;
    --ai-sidebar-hover: #272d52;
    --ai-sidebar-active: #0078d4;
    --ai-body-bg: #f4f6f9;
    --ai-card-bg: #ffffff;
    --ai-text: #2c3e50;
    --ai-text-muted: #6c757d;
    --ai-border: #e2e8f0;
    --ai-success: #10b981;
    --ai-danger: #ef4444;
    --ai-warning: #f59e0b;
    --ai-radius: 12px;
    --ai-radius-sm: 8px;
    --ai-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --ai-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --ai-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --ai-transition: 0.2s ease;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--ai-text);
    background: var(--ai-body-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--ai-text);
    margin-top: 0;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a { color: var(--ai-primary); text-decoration: none; }
a:hover { color: var(--ai-primary-dark); text-decoration: underline; }

h1:focus { outline: none; }

/* ============================================
   Cards
   ============================================ */

.ai-card {
    background: var(--ai-card-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    padding: 1.5rem;
    transition: box-shadow var(--ai-transition);
}

.ai-card:hover {
    box-shadow: var(--ai-shadow-md);
}

.ai-card-header {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ai-text-muted);
    margin-bottom: 0.5rem;
}

.ai-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ai-text);
}

/* ============================================
   Buttons
   ============================================ */

.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--ai-radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--ai-transition);
}

.btn-ai-primary {
    background: var(--ai-primary);
    color: white;
}
.btn-ai-primary:hover {
    background: var(--ai-primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
}

.btn-ai-outline {
    background: transparent;
    color: var(--ai-primary);
    border: 1.5px solid var(--ai-primary);
}
.btn-ai-outline:hover {
    background: var(--ai-primary);
    color: white;
}

/* ============================================
   Auth Pages (Login / Register)
   ============================================ */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1b1f3b 0%, #0f1225 40%, #0a2540 100%);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(0, 120, 212, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 183, 195, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(20px);
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    border-radius: 14px;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: white;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--ai-text);
}

.auth-brand p {
    color: var(--ai-text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.auth-card .form-floating {
    margin-bottom: 1rem;
}

.auth-card .form-control {
    border-radius: var(--ai-radius-sm);
    border: 1.5px solid var(--ai-border);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    transition: border-color var(--ai-transition), box-shadow var(--ai-transition);
}

.auth-card .form-control:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

.auth-card .btn-primary {
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--ai-radius-sm);
    background: var(--ai-primary);
    border: none;
    transition: all var(--ai-transition);
}

.auth-card .btn-primary:hover {
    background: var(--ai-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.35);
}

.auth-card .btn-link {
    color: var(--ai-primary);
    font-size: 0.85rem;
    text-decoration: none;
}
.auth-card .btn-link:hover {
    text-decoration: underline;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--ai-text-muted);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--ai-border);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ai-border);
    font-size: 0.85rem;
    color: var(--ai-text-muted);
}

.auth-footer a {
    font-weight: 500;
}

/* ============================================
   Sidebar
   ============================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--ai-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--ai-transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    border-radius: 10px;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: var(--ai-radius-sm);
    text-decoration: none;
    transition: all var(--ai-transition);
}

.sidebar-nav .nav-link:hover {
    background: var(--ai-sidebar-hover);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.sidebar-nav .nav-link.active {
    background: var(--ai-sidebar-active);
    color: white;
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
    padding: 1rem 0.85rem 0.4rem;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.5rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
    text-transform: uppercase;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.85rem;
    margin-top: 0.5rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    border-radius: var(--ai-radius-sm);
    cursor: pointer;
    transition: all var(--ai-transition);
}

.sidebar-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* ============================================
   Main Content Area
   ============================================ */

.main-panel {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--ai-card-bg);
    border-bottom: 1px solid var(--ai-border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ai-text);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.content-area {
    flex: 1;
    padding: 2rem;
}

/* ============================================
   Dashboard Cards Grid
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--ai-card-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    padding: 1.25rem 1.5rem;
    transition: all var(--ai-transition);
}

.stat-card:hover {
    box-shadow: var(--ai-shadow-md);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.stat-card-icon.blue {
    background: rgba(0, 120, 212, 0.1);
    color: var(--ai-primary);
}

.stat-card-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ai-success);
}

.stat-card-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--ai-warning);
}

.stat-card-icon.cyan {
    background: rgba(0, 183, 195, 0.1);
    color: var(--ai-accent);
}

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ai-text-muted);
    margin-bottom: 0.25rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ai-text);
}

.stat-card-sub {
    font-size: 0.75rem;
    color: var(--ai-text-muted);
    margin-top: 0.25rem;
}

/* ============================================
   Tables
   ============================================ */

.ai-table-card {
    background: var(--ai-card-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    overflow: hidden;
}

.ai-table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-table-header h3 {
    margin: 0;
    font-size: 1rem;
}

.ai-table {
    width: 100%;
    border-collapse: collapse;
}

.ai-table thead th {
    background: #f8fafc;
    padding: 0.75rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ai-text-muted);
    border-bottom: 1px solid var(--ai-border);
    text-align: left;
}

.ai-table tbody td {
    padding: 0.85rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.ai-table tbody tr:last-child td {
    border-bottom: none;
}

.ai-table tbody tr:hover {
    background: #f8fafc;
}

.ai-table tfoot td {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    background: #f8fafc;
    border-top: 2px solid var(--ai-border);
}

/* ============================================
   Chart Container
   ============================================ */

.chart-card {
    background: var(--ai-card-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    padding: 1.5rem;
}

.chart-card h3 {
    margin: 0 0 1.25rem;
    font-size: 1rem;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 220px;
    padding: 0 0.25rem;
}

.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.bar-value {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--ai-text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
}

.bar-fill {
    width: 100%;
    max-width: 48px;
    border-radius: 6px 6px 0 0;
    min-height: 3px;
    transition: height 0.5s ease;
}

.bar-label {
    font-size: 0.6rem;
    color: var(--ai-text-muted);
    margin-top: 6px;
    white-space: nowrap;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ai-border);
    font-size: 0.75rem;
    color: var(--ai-text-muted);
}

.chart-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 0.35rem;
}

/* ============================================
   Badge / Tag
   ============================================ */

.ai-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
}

.ai-badge.up {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ai-danger);
}

.ai-badge.down {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ai-success);
}

.ai-badge.neutral {
    background: rgba(108, 117, 125, 0.1);
    color: var(--ai-text-muted);
}

/* ============================================
   Loading / Alerts
   ============================================ */

.ai-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--ai-text-muted);
}

.ai-alert {
    padding: 1rem 1.25rem;
    border-radius: var(--ai-radius-sm);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.ai-alert.danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

.ai-alert.success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #047857;
}

/* ============================================
   Forms (global overrides)
   ============================================ */

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

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

.validation-message {
    color: var(--ai-danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ============================================
   Blazor Error Boundary
   ============================================ */

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAy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5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ============================================
   Responsive
   ============================================ */

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

    .main-panel {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }
}