/* ThirdGuardian Main Stylesheet */

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

/* ========================================
   CSS Custom Properties for Dark Mode
   ======================================== */

:root {
    /* Brand Colors - Consistent Across Themes */
    --brand-gradient-start: #667eea;
    --brand-gradient-end: #764ba2;
    --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Primary Colors */
    --primary-blue: #3498db;
    --primary-blue-hover: #2980b9;
    --primary-blue-light: rgba(52, 152, 219, 0.1);

    /* Background Colors */
    --bg-body: #f5f5f5;
    --bg-card: #ffffff;
    --bg-card-secondary: #f9fafb;
    --bg-hover: #f8f9fa;
    --bg-overlay: rgba(0, 0, 0, 0.5);

    /* Text Colors */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;

    /* Border Colors */
    --border-primary: #e5e7eb;
    --border-secondary: #dee2e6;
    --border-light: #ced4da;
    --border-highlight: #f0f0f0;

    /* Shadow Colors */
    --shadow-sm: rgba(0, 0, 0, 0.06);
    --shadow-md: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --shadow-xl: rgba(0, 0, 0, 0.2);

    /* Status Badge Colors */
    --status-success-bg: #28a745;
    --status-success-text: white;
    --status-warning-bg: #ffc107;
    --status-warning-text: #000000;
    --status-info-bg: #17a2b8;
    --status-info-text: white;
    --status-purple-bg: #6f42c1;
    --status-purple-text: white;
    --status-inactive-bg: #6c757d;
    --status-inactive-text: white;

    /* Severity/Priority Colors */
    --severity-critical: #dc2626;
    --severity-high: #ea580c;
    --severity-medium: #f59e0b;
    --severity-low: #6b7280;

    /* Alert Colors */
    --alert-success-bg: #d4edda;
    --alert-success-border: #c3e6cb;
    --alert-success-text: #155724;
    --alert-success-light-bg: #f0fdf4;
    --alert-success-light-border: #86efac;
    --alert-error-bg: #f8d7da;
    --alert-error-border: #f5c6cb;
    --alert-error-text: #721c24;
    --alert-error-light-bg: #fef2f2;
    --alert-error-light-border: #fca5a5;
    --alert-info-bg: #d1ecf1;
    --alert-info-border: #bee5eb;
    --alert-info-text: #0c5460;
    --alert-info-light-bg: #f0f9ff;
    --alert-info-light-border: #3498db;
    --alert-warning-bg: #fef3c7;
    --alert-warning-border: #fbbf24;
    --alert-warning-text: #92400e;

    /* Sidebar Colors */
    --sidebar-bg-start: #2c3e50;
    --sidebar-bg-end: #34495e;
    --sidebar-bg: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-text: rgba(255, 255, 255, 0.9);
    --sidebar-text-muted: rgba(255, 255, 255, 0.7);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(52, 152, 219, 0.2);

    /* Stat Card Accent Colors */
    --stat-blue: #3498db;
    --stat-orange: #f59e0b;
    --stat-purple: #8b5cf6;
    --stat-green: #10b981;
    --stat-red: #ef4444;
    --stat-cyan: #06b6d4;

    /* Link Colors */
    --link-color: #2563eb;
    --link-hover: #1d4ed8;
    --link-visited: #7c3aed;

    /* Tab Colors */
    --tab-border: #e5e7eb;
    --tab-text: #6b7280;
    --tab-text-hover: #111827;
    --tab-hover-bg: #f9fafb;
    --tab-active-color: #2563eb;
    --tab-badge-bg: #e5e7eb;
    --tab-badge-text: #374151;
    --tab-badge-active-bg: #dbeafe;
    --tab-badge-active-text: #1e40af;

    /* Stepper Colors */
    --stepper-inactive-bg: #e0e0e0;
    --stepper-inactive-text: #666666;
    --stepper-active-bg: #3498db;
    --stepper-active-text: white;
    --stepper-complete-bg: #28a745;
    --stepper-complete-text: white;

    /* Form Colors */
    --form-bg: #ffffff;
    --form-border: #ced4da;
    --form-text: #333333;
    --form-placeholder: #6c757d;
    --form-disabled-bg: #f3f4f6;

    /* Button Colors */
    --btn-bg: white;
    --btn-border: #ccc;
    --btn-text: #333;

    /* Notification Colors */
    --notification-bell-bg: #3b82f6;
    --notification-bell-text: white;
    --notification-unread-bg: #eff6ff;
    --notification-badge-bg: #dc2626;

    /* Login Page Colors */
    --login-title-text: #2c3e50;
    --login-subtitle-text: #666666;
    --login-help-text: #666666;
    --login-box-bg: white;

    /* Scrollbar Colors */
    --scrollbar-track-bg: #f5f5f5;
    --scrollbar-thumb-bg: #cbd5e1;
    --scrollbar-thumb-hover-bg: #94a3b8;
}

[data-theme="dark"] {
    /* Dark Mode Color Overrides */

    /* Keep Brand Gradient Unchanged */

    /* Background Colors */
    --bg-body: #0f172a;
    --bg-card: #1a2030;
    --bg-card-secondary: #1e2836;
    --bg-hover: #252f3f;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Border Colors */
    --border-primary: #334155;
    --border-secondary: #475569;
    --border-light: #475569;
    --border-highlight: #2d3748;

    /* Shadow Colors */
    --shadow-sm: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.4);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --shadow-xl: rgba(0, 0, 0, 0.6);

    /* Status Badges - Adjusted for Dark Mode Visibility */
    --status-success-bg: #059669;
    --status-success-text: white;
    --status-warning-bg: #d97706;
    --status-warning-text: white;
    --status-info-bg: #0e7490;
    --status-info-text: white;
    --status-purple-bg: #7c3aed;
    --status-purple-text: white;
    --status-inactive-bg: #52525b;
    --status-inactive-text: white;

    /* Alert Colors for Dark Mode */
    --alert-success-bg: #064e3b;
    --alert-success-border: #065f46;
    --alert-success-text: #6ee7b7;
    --alert-success-light-bg: #064e3b;
    --alert-success-light-border: #059669;
    --alert-error-bg: #7f1d1d;
    --alert-error-border: #991b1b;
    --alert-error-text: #fca5a5;
    --alert-error-light-bg: #7f1d1d;
    --alert-error-light-border: #dc2626;
    --alert-info-bg: #164e63;
    --alert-info-border: #155e75;
    --alert-info-text: #67e8f9;
    --alert-info-light-bg: #164e63;
    --alert-info-light-border: #0ea5e9;
    --alert-warning-bg: #713f12;
    --alert-warning-border: #92400e;
    --alert-warning-text: #fde68a;

    /* Sidebar Colors - Darker in Dark Mode */
    --sidebar-bg-start: #0f172a;
    --sidebar-bg-end: #1e293b;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --sidebar-border: rgba(255, 255, 255, 0.05);
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --sidebar-text-muted: rgba(255, 255, 255, 0.6);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(52, 152, 219, 0.3);

    /* Link Colors - Brighter for Dark Mode */
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    --link-visited: #a78bfa;

    /* Tab Colors */
    --tab-border: #334155;
    --tab-text: #94a3b8;
    --tab-text-hover: #f1f5f9;
    --tab-hover-bg: #1e293b;
    --tab-active-color: #60a5fa;
    --tab-badge-bg: #334155;
    --tab-badge-text: #cbd5e1;
    --tab-badge-active-bg: #1e3a8a;
    --tab-badge-active-text: #93c5fd;

    /* Stepper Colors */
    --stepper-inactive-bg: #334155;
    --stepper-inactive-text: #94a3b8;
    --stepper-active-bg: #3b82f6;
    --stepper-active-text: white;
    --stepper-complete-bg: #059669;
    --stepper-complete-text: white;

    /* Form Colors */
    --form-bg: #1e293b;
    --form-border: #475569;
    --form-text: #f1f5f9;
    --form-placeholder: #64748b;
    --form-disabled-bg: #0f172a;

    /* Button Colors */
    --btn-bg: #1e293b;
    --btn-border: #475569;
    --btn-text: #f1f5f9;

    /* Notification Colors */
    --notification-bell-bg: #3b82f6;
    --notification-bell-text: white;
    --notification-unread-bg: #1e3a8a;
    --notification-badge-bg: #dc2626;

    /* Login Page Colors */
    --login-title-text: #f1f5f9;
    --login-subtitle-text: #cbd5e1;
    --login-help-text: #94a3b8;
    --login-box-bg: #1e293b;

    /* Scrollbar Colors */
    --scrollbar-track-bg: #1a2030;
    --scrollbar-thumb-bg: #475569;
    --scrollbar-thumb-hover-bg: #64748b;
}

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

/* ========================================
   Scrollbar Styling - Theme-Aware
   ======================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track-bg);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-bg);
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

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

/* Firefox */
* {
    scrollbar-color: var(--scrollbar-thumb-bg) var(--scrollbar-track-bg);
    scrollbar-width: thin;
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* All links show as unclicked (visited links use same color as regular links) */
a:visited {
    color: var(--link-color);
}

/* ========================================
   Tabs
   ======================================== */

.admin-dashboard .tab-nav {
    display: flex;
    border-bottom: 2px solid var(--tab-border);
    margin-bottom: 1.5rem;
}

.admin-dashboard .tab-link {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--tab-text);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* Align with the nav border */
    transition: all 0.2s ease-in-out;
}

.admin-dashboard .tab-link:hover {
    background-color: var(--tab-hover-bg);
    color: var(--tab-text-hover);
}

.admin-dashboard .tab-link.active {
    color: var(--tab-active-color);
    border-bottom-color: var(--tab-active-color);
    font-weight: 600;
}

.admin-dashboard .tab-content {
    display: none;
}

.admin-dashboard .tab-content.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Admin grid specific styles */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.admin-card {
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-card-secondary));
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

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

.admin-card h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.admin-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.admin-card .btn {
    width: 100%;
    margin-top: auto;
}

.admin-card-placeholder {
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-card-secondary));
    border: 1px dashed var(--border-primary);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    opacity: 0.6;
}

.admin-card-placeholder p {
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Badge styles */
.badge-info {
    background: var(--status-info-bg);
    color: var(--status-info-text);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: var(--status-success-bg);
    color: var(--status-success-text);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-warning {
    background: #fff3e0;
    color: #c2410c;
    border: 1px solid #fdba74;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Top Navigation Bar */
.navbar {
    background: var(--brand-gradient);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 8px var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    letter-spacing: -0.5px;
}

/* Override general link colors for nav-brand - keep it white without underline */
.nav-brand:hover,
.nav-brand:visited,
.nav-brand:active {
    color: white;
    text-decoration: none;
}

/* Override general link colors for buttons - inherit button color */
.btn,
.btn:visited,
.btn:hover,
.btn:active,
button a,
button a:visited,
button a:hover,
button a:active {
    color: inherit;
    text-decoration: none;
}

.nav-user {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-user span {
    font-size: 0.9rem;
    opacity: 0.95;
}

.logout-btn {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    transition: background 0.3s;
    font-size: 0.9rem;
}

.logout-btn:hover,
.logout-btn:visited,
.logout-btn:active {
    color: white;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Hamburger Menu Toggle */
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-right: 1rem;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.menu-toggle:hover span {
    background: rgba(255,255,255,0.8);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.15) 100%);
    backdrop-filter: blur(20px) saturate(200%) contrast(120%);
    -webkit-backdrop-filter: blur(20px) saturate(200%) contrast(120%);
    border-right: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.5),
                inset 0 -1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.2), transparent 70%);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: inset -10px -8px 0px -11px rgba(255, 255, 255, 0.8),
                inset 0px -9px 0px -8px rgba(255, 255, 255, 0.6),
                inset 20px 0px 40px rgba(255, 255, 255, 0.1);
    filter: blur(1px) brightness(120%);
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.85; }
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 2;
}

.sidebar-header h2 {
    color: white;
    font-size: 1.3rem;
    margin: 0;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    position: relative;
    z-index: 2;
}

.sidebar-link:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-left-color: rgba(52, 152, 219, 0.8);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3),
                0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.3) 0%, rgba(52, 152, 219, 0.15) 100%);
    border-left-color: rgba(52, 152, 219, 1);
    color: white;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
                inset 0 -1px 0 rgba(0, 0, 0, 0.2),
                0 4px 16px rgba(52, 152, 219, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Override general link colors for sidebar - keep them white */
.sidebar a,
.sidebar a:visited,
.sidebar a:hover {
    color: var(--sidebar-text);
}

.sidebar a:hover {
    text-decoration: none;
}

.sidebar .sidebar-link.active,
.sidebar .sidebar-link.active:visited {
    color: white;
}

.sidebar-icon {
    font-size: 1.3rem;
    margin-right: 1rem;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon-svg {
    width: 24px;
    height: 24px;
    color: var(--sidebar-text);
    stroke-width: 2;
}

/* ---- Sidebar collapsible group (Management, etc.) ---- */

.sidebar-group {
    /* No extra margin — blends with the link list */
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--sidebar-text);
    font-size: 1rem;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    text-align: left;
    gap: 0;
}

.sidebar-group-toggle:hover {
    background: var(--sidebar-hover-bg);
    border-left-color: var(--primary-blue);
}

.sidebar-group-toggle.open {
    background: var(--sidebar-hover-bg);
}

.sidebar-group-toggle .sidebar-icon {
    display: flex;
    align-items: center;
    margin-right: 0.75rem;
    opacity: 0.8;
    flex-shrink: 0;
}

.sidebar-group-toggle > span:nth-child(2) {
    flex: 1;
}

.sidebar-group-arrow {
    display: flex;
    align-items: center;
    margin-left: auto;
    opacity: 0.6;
    transition: transform 0.25s ease;
}

.sidebar-group-toggle.open .sidebar-group-arrow {
    transform: rotate(90deg);
}

.sidebar-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-group-items.open {
    max-height: 400px; /* large enough for any realistic sub-menu */
}

.sidebar-sub-link {
    padding-left: 3rem !important;
    font-size: 0.9rem;
}

/* ---- End sidebar group ---- */

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
}

.user-details {
    flex: 1;
}

.user-name {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

.user-email {
    color: var(--sidebar-text-muted);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 999;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1rem;
}

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.alert-success {
    background-color: var(--alert-success-bg);
    border-color: var(--alert-success-border);
    color: var(--alert-success-text);
}

.alert-error {
    background-color: var(--alert-error-bg);
    border-color: var(--alert-error-border);
    color: var(--alert-error-text);
}

.alert-info {
    background-color: var(--alert-info-bg);
    border-color: var(--alert-info-border);
    color: var(--alert-info-text);
}

.alert-danger {
    background-color: var(--alert-error-bg);
    border-color: var(--alert-error-border);
    color: var(--alert-error-text);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--btn-border);
    border-radius: 4px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
}

/* Ensure button elements match anchor elements */
button.btn {
    font-family: inherit;
    line-height: 1.5;
}

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

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 12px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    position: relative;
}

/* Dark mode glass effect only */
[data-theme="dark"] .stat-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1),
                inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

[data-theme="dark"] .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 100%);
    pointer-events: none;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 100%);
    pointer-events: none;
}

.stat-card-link {
    display: block;
}

.stat-card-link .stat-card {
    transition: all 0.2s ease;
}

.stat-card-link:hover .stat-card {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px var(--shadow-md);
}

/* Dark mode glass hover effect */
[data-theme="dark"] .stat-card-link:hover .stat-card {
    transform: translateY(-6px) scale(1.02);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.15),
                inset 0 -1px 0 rgba(255, 255, 255, 0.1),
                0 0 20px rgba(255, 255, 255, 0.1);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Section */
.section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    margin-bottom: 1rem;
}

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

.section-header h2 {
    margin: 0;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--bg-hover);
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-secondary);
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-secondary);
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-awaiting-requester {
    background-color: var(--status-warning-bg);
    color: var(--status-warning-text);
}

.badge-awaiting-third-party {
    background-color: var(--status-info-bg);
    color: var(--status-info-text);
}

.badge-awaiting-assessor {
    background-color: var(--status-purple-bg);
    color: var(--status-purple-text);
}

.badge-complete {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
}

.badge-active {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
}

.badge-inactive {
    background-color: var(--status-inactive-bg);
    color: var(--status-inactive-text);
}

/* Questionnaire status badges */
.badge-not_started {
    background-color: var(--status-inactive-bg);
    color: var(--status-inactive-text);
}

.badge-in_progress {
    background-color: var(--status-info-bg);
    color: var(--status-info-text);
}

.badge-submitted {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
}

.badge-reviewed {
    background-color: var(--status-purple-bg);
    color: var(--status-purple-text);
}

/* Forms */
.form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem; /* Added this for consistency */
}

/* Bordered intake fields (yes_no fields) */
.intake-field-bordered {
    border: 1px solid var(--border-primary);
    padding: 1rem;
    border-radius: 8px;
    background: var(--bg-card-secondary);
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
}

.intake-field-bordered:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 2px 8px var(--shadow-sm);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-input, /* Added this */
.form-select /* Added this */ {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--form-border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--form-bg);
    color: var(--form-text);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--form-placeholder);
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Custom styles for data elements filter grid and actions */
.data-elements-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: stretch; /* All grid items same height */
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end; /* Align buttons to the bottom of the flex container */
}

.filter-actions .btn {
    flex: 1;
    text-align: center;
    height: 2.4375rem; /* Explicitly set height to match input fields */
    display: flex; /* Re-add flex to allow vertical centering of text */
    align-items: center; /* Vertically center text in button */
    justify-content: center; /* Horizontally center text in button */
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--login-box-bg);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px var(--shadow-xl);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    margin-bottom: 0.5rem;
    color: var(--login-title-text);
}

.login-box h2 {
    font-size: 1rem;
    color: var(--login-subtitle-text);
    margin-bottom: 2rem;
}

.help-text {
    text-align: center;
    margin-top: 1rem;
    color: var(--login-help-text);
    font-size: 12px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin: 0;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.detail-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-highlight);
}

.detail-section dl {
    margin: 0;
}

.detail-item dt { /* Added these rules */
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.detail-item dd { /* Added these rules */
    margin: 0;
}

.detail-section dt {
    font-weight: 600;
    margin-top: 0.25rem; /* Reduced from 0.75rem */
    color: var(--text-secondary);
}

.detail-section dd {
    margin-left: 0;
    margin-top: 0; /* Reduced from 0.25rem */
}

.detail-section dd input,
.detail-section dd select,
.detail-section dd textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--form-border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--form-bg);
    color: var(--form-text);
}

/* Choices.js wrapper in detail sections */
.detail-section dd .choices {
    width: 100%;
    max-width: 100%;
}

.detail-section dd .choices__inner {
    padding: 0.5rem;
    min-height: auto;
    font-size: 14px;
}

/* State Stepper */
.state-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    margin-bottom: 2rem;
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--stepper-inactive-bg);
    color: var(--stepper-inactive-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.step.active .step-icon {
    background-color: var(--stepper-active-bg);
    color: var(--stepper-active-text);
    animation: pulsate 2s ease-in-out infinite;
}

@keyframes pulsate {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--stepper-active-bg);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(52, 152, 219, 0);
    }
}

.step.completed .step-icon {
    background-color: var(--stepper-complete-bg);
    color: var(--stepper-complete-text);
}

.step-label {
    font-size: 12px;
    text-align: center;
    max-width: 100px;
}

/* Align "Complete" step (single word) with other 2-word steps by adding space below */
.step:last-child .step-label {
    padding-bottom: 1.2rem;
}

/* Remove padding when "Complete" step is active or completed */
.step:last-child.active .step-label,
.step:last-child.completed .step-label {
    padding-bottom: 0;
}

.step-connector {
    width: 60px;
    height: 2px;
    background-color: var(--stepper-inactive-bg);
    margin: 0 0.5rem;
    margin-bottom: 2rem;
}

.step.completed + .step-connector {
    background-color: var(--stepper-complete-bg);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ========================================
   Dark Mode Theme Toggle
   ======================================== */

.sidebar-theme-toggle {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--sidebar-border);
    border-bottom: 1px solid var(--sidebar-border);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--sidebar-hover-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
    font-weight: 500;
}

.theme-toggle-btn:hover {
    background: var(--sidebar-active-bg);
    border-color: var(--primary-blue);
}

.theme-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: all 0.3s;
}

.theme-icon-sun {
    display: block;
}

.theme-icon-moon {
    display: none;
}

[data-theme="dark"] .theme-icon-sun {
    display: none;
}

[data-theme="dark"] .theme-icon-moon {
    display: block;
}

.theme-toggle-text {
    flex: 1;
    text-align: left;
}

/* ── Tooltip ──────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.72rem;
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* Smooth Theme Transitions */
body,
.navbar,
.sidebar,
.sidebar-overlay,
.stat-card,
.section,
.detail-section,
.state-stepper,
.data-table,
.form,
.login-box,
.btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ========================================
   Choices.js Light and Dark Mode Support
   ======================================== */

/* Light mode - explicit white background */
.choices__inner {
    background-color: #ffffff !important;
    border-color: #ced4da !important;
    color: #333333 !important;
}

.choices__list--dropdown {
    background-color: #ffffff !important;
    border-color: #ced4da !important;
}

.choices__input {
    background-color: #ffffff !important;
    color: #333333 !important;
}

[data-theme="dark"] .choices__inner {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .choices__list--dropdown {
    background-color: #1e293b !important;
    border-color: #475569 !important;
}

[data-theme="dark"] .choices__item {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .choices__item--choice {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .choices__item--choice:hover,
[data-theme="dark"] .choices__item--choice.is-highlighted {
    background-color: var(--primary-blue);
    color: white;
}

[data-theme="dark"] .choices__input {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .choices__placeholder {
    color: #64748b !important;
}

/* Choices.js Selected Items - Remove blue background, make it match form controls */
.choices__item--selectable {
    background-color: transparent !important;
    border: none !important;
    color: #333333 !important;
    padding-left: 0 !important;
}

[data-theme="dark"] .choices__item--selectable {
    color: #f1f5f9 !important;
}

.choices__button {
    background-color: rgba(255, 255, 255, 0.3) !important;
    border-left-color: rgba(255, 255, 255, 0.3) !important;
    opacity: 0.8;
}

.choices__button:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.5) !important;
}

/* Dropdown highlight and focus states */
.choices__item--choice.is-highlighted {
    background-color: #3498db !important;
    color: white !important;
}

.choices.is-focused .choices__inner {
    border-color: #3498db !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

[data-theme="dark"] .choices.is-focused .choices__inner {
    border-color: #3498db !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2) !important;
}

/* Remove extra margin from Choices.js in form groups to eliminate gap before small text */
.form-group .choices {
    margin-bottom: 0 !important;
}

/* =====================
   LEGAL PROCESS STEPPER
   ===================== */
.legal-process-stepper {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.lp-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    position: relative;
}

.lp-step-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-primary);
    background: var(--bg-card);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.lp-step.lp-active .lp-step-icon {
    border-color: var(--primary-blue, #3498db);
    background: rgba(52,152,219,0.12);
    color: var(--primary-blue, #3498db);
}

.lp-step.lp-complete .lp-step-icon {
    border-color: var(--status-success-bg, #10b981);
    background: rgba(16,185,129,0.12);
    color: #10b981;
}

.lp-step-body {
    padding-bottom: 1.5rem;
    flex: 1;
}

.lp-step:last-child .lp-step-body {
    padding-bottom: 0;
}

.lp-step-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.lp-step.lp-active .lp-step-title,
.lp-step.lp-complete .lp-step-title {
    color: var(--text-primary);
}

.lp-step-desc {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.lp-step-meta {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.lp-connector {
    width: 2px;
    height: 1.5rem;
    background: var(--border-primary);
    margin-left: 15px;
    transition: background 0.2s;
}

.lp-connector-done {
    background: rgba(16,185,129,0.4);
}

[data-theme="dark"] .lp-step.lp-active .lp-step-icon {
    background: rgba(52,152,219,0.2);
}

[data-theme="dark"] .lp-step.lp-complete .lp-step-icon {
    background: rgba(16,185,129,0.2);
}
