/* xAIDRA - Professional Corporate Theme */

:root {
    --primary-blue: #2c5282;
    --primary-blue-dark: #1a365d;
    --primary-blue-light: #4a6fa5;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --success: #38a169;
    --warning: #d69e2e;
    --danger: #c53030;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

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

a {
    color: var(--primary-blue);
    text-decoration: none;
}

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

/* ==================== LAYOUT ==================== */

.xaidra-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.xaidra-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-left,
.header-center,
.header-right {
    flex: 1;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-section i {
    font-size: 1.5rem;
    color: var(--primary-blue);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-blue);
    letter-spacing: -0.02em;
}

.version-badge {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.header-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

.user-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.user-info-mini {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-email {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--danger);
    color: var(--danger);
}

.xaidra-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.xaidra-sidebar {
    width: 240px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.xaidra-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.content-wrapper {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== NAVIGATION ==================== */

.xaidra-nav {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.section-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--primary-blue);
    background: var(--bg-secondary);
    text-decoration: none;
}

.nav-item.active {
    color: var(--primary-blue);
    background: var(--bg-secondary);
    border-left-color: var(--primary-blue);
    font-weight: 500;
}

.nav-icon {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

/* ==================== CARDS ==================== */

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.card-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* ==================== STATS ==================== */

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

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.bg-primary {
    background: var(--primary-blue);
}

.stat-icon.bg-success {
    background: var(--success);
}

.stat-icon.bg-danger {
    background: var(--danger);
}

.stat-icon.bg-warning {
    background: var(--warning);
}

.stat-content h3 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ==================== FORMS ==================== */

.form-label,
label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-control,
.form-select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
textarea,
select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    background: var(--bg-primary);
    border-color: var(--primary-blue);
    color: var(--text-primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ==================== BUTTONS ==================== */

.btn {
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

.btn-outline-primary {
    background: transparent;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-outline-primary:hover {
    background: var(--primary-blue);
    color: white;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
    color: white;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

/* ==================== TABLES ==================== */

.table {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.table thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

.table thead th {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

.table tbody td {
    padding: 0.75rem;
    font-size: 0.875rem;
}

/* ==================== BADGES ==================== */

.badge {
    padding: 0.25rem 0.5rem;
    font-weight: 500;
    border-radius: 3px;
    font-size: 0.75rem;
}

.badge-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ==================== ALERTS ==================== */

.alert {
    border-radius: 4px;
    border: 1px solid;
    padding: 0.75rem 1rem;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

/* ==================== MODAL ==================== */

.modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
}

.modal-header .modal-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.125rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
}

/* ==================== TABS ==================== */

.nav-tabs {
    border-bottom: 1px solid var(--border-color);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: transparent;
    border-bottom: 2px solid transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-blue);
    text-decoration: none;
}

.nav-tabs .nav-link.active {
    color: var(--primary-blue);
    border-bottom: 2px solid var(--primary-blue);
    background: transparent;
}

/* ==================== PAGE HEADER ==================== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==================== TOAST ==================== */

.toast-notice {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    color: #fff;
    background: #2d3748;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    animation: toast-slide-in 0.2s ease-out;
}

.toast-notice i {
    opacity: 0.9;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: #d69e2e;
}

.toast-info {
    background: var(--primary-blue);
}

@keyframes toast-slide-in {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==================== CONTEXT MENU ==================== */

.context-menu {
    position: fixed;
    background: #ffffff; /* Solid fallback */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999; /* Ensure it is above everything */
    min-width: 240px;
    padding: 8px;
    animation: menu-pop 0.15s cubic-bezier(0, 0, 0.2, 1);
    pointer-events: auto;
}

@keyframes menu-pop {
    from { opacity: 0; transform: scale(0.98) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #1f2937;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.1s ease-in-out;
    user-select: none;
}

.context-menu-item:hover {
    background: var(--primary-blue) !important;
    color: #ffffff !important;
}

.context-menu-item:hover i {
    color: #ffffff !important;
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.context-menu-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 4px;
}

.context-menu-header {
    padding: 8px 16px 4px;
    font-size: 0.7rem;
    color: #6b7280;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==================== AGENTS ==================== */

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.agent-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.25rem;
}

.agent-card.online {
    border-left: 3px solid var(--success);
}

.agent-card.offline {
    border-left: 3px solid var(--danger);
}

.agent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.agent-header h5 {
    margin: 0;
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 1rem;
}

.agent-body {
    margin-bottom: 1rem;
}

.agent-info {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-tertiary);
    font-size: 0.875rem;
}

.agent-info .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.agent-info .value {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.agent-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    color: #721c24;
    font-size: 0.875rem;
}

/* ==================== LOADING ==================== */

.loading-progress circle:last-child {
    stroke: var(--primary-blue);
}

#blazor-error-ui {
    background: #f8d7da;
    border-top: 2px solid var(--danger);
    color: #721c24;
}

/* ==================== SCROLLBAR ==================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

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

/* ==================== UTILITIES ==================== */

.page,
main,
article,
.content,
.container,
.container-fluid {
    background: transparent;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--primary-blue) !important;
}

/* ==================== DOCS ==================== */

.docs-container {
    display: flex;
    gap: 1rem;
}

.docs-sidebar {
    min-width: 260px;
}

.doc-plaintext {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.search-results .snippet mark {
    background: #fff3cd;
    padding: 0 2px;
}

/* ==================== AGENT OS SECTION ==================== */

.agent-os-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 1rem;
}

.os-icon {
    flex-shrink: 0;
}

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

.os-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.os-version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

/* ==================== LOGIN ==================== */

.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.login-header {
    background: var(--primary-blue-dark);
    padding: 2.5rem 2rem;
    text-align: center;
    color: white;
}

.login-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.login-logo-container i {
    font-size: 2.5rem;
    color: #fff;
    opacity: 0.95;
}

.login-header h1 {
    color: white;
    margin: 0;
    font-size: 2.5rem;
    letter-spacing: -0.02em;
}

.login-header .subtitle {
    margin: 0.5rem 0 0;
    opacity: 0.8;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.login-body {
    padding: 2rem;
}

.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.login-divider span {
    margin: 0 1rem;
}

.google-login-section {
    margin-bottom: 1rem;
}

.login-footer {
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.login-footer p {
    margin: 0;
    font-size: 0.75rem;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .xaidra-sidebar {
        position: fixed;
        left: -240px;
        top: 64px;
        height: calc(100vh - 64px);
        z-index: 99;
        transition: left 0.3s;
    }

    .xaidra-sidebar.open {
        left: 0;
    }

    .header-title {
        display: none;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }
}

/* ==================== LANDING PAGE ==================== */

.landing-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, #0d1b2a 100%);
    padding: 2rem;
}

.landing-content {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.brand-hero {
    margin-bottom: 3rem;
    color: white;
}

.hero-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 15px rgba(255,255,255,0.2));
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    font-weight: 300;
}

.auth-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.auth-card-body {
    padding: 3rem 2.5rem;
}

.auth-card-body h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.google-btn-container {
    min-height: 50px;
    margin-top: 2rem;
}

.auth-card-footer {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.legacy-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.legacy-link:hover {
    color: var(--primary-blue);
}
