:root {
    --bg-primary: #667eea;
    --bg-secondary: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #f0f0f0;
    --shadow-color: rgba(16, 24, 40, 0.05);
    
    /* New Premium Tokens */
    --primary-glow: hsla(262, 80%, 50%, 0.15);
    --primary-accent: hsl(262, 80%, 60%);
    --nav-glass-bg: rgba(255, 255, 255, 0.95);
    --nav-glass-border: rgba(255, 255, 255, 0.5);
    --nav-bg: var(--nav-glass-bg);
    --nav-border: var(--nav-glass-border);
    --nav-hover: rgba(102, 126, 234, 0.08);
    --transition-premium: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

[data-theme="dark"] {
    --bg-primary: #1f2937;
    --bg-secondary: #374151;
    --card-bg: rgba(31, 41, 55, 0.95);
    --text-primary: #f9fafb;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.4);
    
    /* Dark Mode Premium Tokens */
    --nav-glass-bg: rgba(15, 23, 42, 0.95);
    --nav-glass-border: rgba(255, 255, 255, 0.08);
    --nav-bg: var(--nav-glass-bg);
    --nav-border: var(--nav-glass-border);
    --nav-hover: rgba(255, 255, 255, 0.06);
    --primary-glow: hsla(262, 80%, 60%, 0.2);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    padding: 0;
}

/* Generalized Utility Backgrounds to match Tailwind logic */
body.bg-dashboard {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    transition: background 0.3s ease;
}

body.bg-organizations {
    background: #f9fafb;
    /* Tailwinds bg-gray-50 */
    transition: background 0.3s ease;
}

body.bg-organizations[data-theme="dark"],
[data-theme="dark"] body.bg-organizations {
    background: #111827;
    /* Tailwinds bg-gray-900 */
}

/* Navigation Bar Styles */
.navbar {
    background: var(--nav-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--nav-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    transition: var(--transition-premium);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 72px;
}

.nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    transition: var(--transition-premium);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .nav-brand {
    background: linear-gradient(135deg, #a78bfa 0%, #c084fc 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-brand:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

.nav-brand-icon {
    margin-right: 12px;
    font-size: 1.6rem;
    -webkit-text-fill-color: initial;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: var(--transition-premium);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--nav-hover);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--bg-primary);
    background: var(--nav-hover);
    font-weight: 600;
}

[data-theme="dark"] .nav-link.active {
    color: #a78bfa;
}

.nav-link-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
    opacity: 0.8;
}

.nav-link:hover .nav-link-icon {
    opacity: 1;
    transform: scale(1.1);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--nav-border);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: var(--transition-premium);
    z-index: 1001;
    padding: 8px;
    list-style: none;
}

.nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-premium);
    border-radius: 8px;
}

.nav-dropdown-item:hover {
    color: var(--text-primary);
    background: var(--nav-hover);
    transform: translateX(4px);
}

.nav-dropdown-item-icon {
    margin-right: 10px;
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.nav-toggle {
    display: none;
    background: var(--nav-hover);
    border: 1px solid var(--nav-border);
    color: var(--text-primary);
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: var(--transition-premium);
}

/* Dark mode toggle in navigation */
.nav-dark-mode-toggle {
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-premium);
    color: var(--text-primary);
    margin-left: 12px;
}

.nav-dark-mode-toggle:hover {
    transform: rotate(12deg) scale(1.05);
    background: var(--nav-hover);
    border-color: var(--bg-primary);
}

.nav-dark-mode-toggle svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px var(--shadow-color);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px var(--shadow-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

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

.status-not-configured {
    background: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

.health-details {
    margin-bottom: 15px;
}

.health-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.health-item:last-child {
    border-bottom: none;
}

.health-label {
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.health-value {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    transition: color 0.3s ease;
}

.refresh-btn {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 15px;
    width: 100%;
}

/* Dark mode button overrides for better contrast */
[data-theme="dark"] .refresh-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: 1px solid #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .refresh-btn:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Override button colors for specific buttons */
.refresh-btn[style*="background: #10b981"],
.refresh-btn[style*="background: #28a745"] {
    background: #28a745 !important;
}

.refresh-btn[style*="background: #ff9800"] {
    background: #ff9800 !important;
}

.refresh-btn[style*="background: #dc3545"] {
    background: #dc3545 !important;
}

/* Dark mode overrides for specific button colors */
[data-theme="dark"] .refresh-btn[style*="background: #10b981"],
[data-theme="dark"] .refresh-btn[style*="background: #28a745"] {
    background: #15803d !important;
    border: 1px solid #22c55e;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .refresh-btn[style*="background: #ff9800"] {
    background: #ea580c !important;
    border: 1px solid #f97316;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

[data-theme="dark"] .refresh-btn[style*="background: #dc3545"] {
    background: #b91c1c !important;
    border: 1px solid #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    transition: color 0.3s ease;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #f5c6cb;
}

.overall-status {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px var(--shadow-color);
    backdrop-filter: blur(10px);
    margin-bottom: 20px;
    text-align: center;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.overall-status h2 {
    color: var(--text-primary);
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.overall-status p,
.overall-status div:not(.overall-indicator) {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.overall-indicator {
    font-size: 48px;
    margin-bottom: 15px;
}

.overall-healthy {
    color: #28a745;
}

.overall-unhealthy {
    color: #dc3545;
}

.timestamp {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.3s ease;
}

/* Table Actions */
.action-link {
    color: #4f46e5;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    font-weight: 500;
    padding: 0;
    font-size: inherit;
    transition: color 0.2s ease;
}

.action-link:hover {
    color: #4338ca;
}

[data-theme="dark"] .action-link {
    color: #a5b4fc;
}

[data-theme="dark"] .action-link:hover {
    color: #818cf8;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 25px var(--shadow-color);
    overflow: hidden;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

[data-theme="dark"] .modal-icon {
    background-color: rgba(129, 140, 248, 0.1);
    color: #818cf8;
}

.modal-icon svg {
    width: 24px;
    height: 24px;
}

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

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.modal-footer {
    padding: 15px 20px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
}

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

.btn-secondary:hover {
    background: var(--bg-primary);
}

/* Alert Container Styles */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-alert {
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 300px;
    animation: slideIn 0.3s forwards;
    font-size: 0.95rem;
}

.toast-alert.hiding {
    animation: slideOut 0.3s forwards;
}

.toast-alert button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    padding: 0 0 0 15px;
    display: flex;
    align-items: center;
}

.toast-alert button:hover {
    opacity: 1;
}

.toast-alert svg {
    width: 20px;
    height: 20px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        border-top: 1px solid var(--nav-border);
        flex-direction: column;
        padding: 20px;
        box-shadow: 0 4px 12px var(--shadow-color);
        order: 3;
        width: 100%;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 12px 0;
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .nav-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        margin-left: 20px;
        margin-top: 10px;
    }

    .nav-toggle {
        display: block;
    }

    .nav-dark-mode-toggle {
        margin-left: 0;
        margin-top: 10px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }

    .dark-mode-toggle {
        position: static;
        margin: 0 auto 15px auto;
    }
}