/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Header and navigation */
header {
    background-color: #1f2937;
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: block;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: #374151;
}

/* Navigation dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s;
    font-size: 1rem;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover {
    background-color: #374151;
}

.nav-dropdown-arrow {
    font-size: 0.6rem;
    transition: transform 0.3s;
}

.nav-dropdown:hover .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 200px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 0.5rem 0;
}

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

.nav-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.nav-dropdown-item:hover {
    background-color: #f3f4f6;
}

/* Compact Data Coverage Badge in Nav */
.nav-data-coverage {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 1rem;
}

.data-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    color: #93c5fd;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: default;
}

.data-badge-icon {
    font-size: 0.9rem;
}

.data-badge-text {
    font-weight: 500;
}

/* User menu and authentication */
.nav-user {
    display: flex;
    align-items: center;
}

/* Login/Register buttons for unauthenticated users */
.auth-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-login {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.btn-login:hover {
    background-color: #374151;
}

.btn-register {
    background-color: #3b82f6;
    color: white;
    text-decoration: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.btn-register:hover {
    background-color: #2563eb;
}

/* User menu dropdown */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid #374151;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.user-menu-toggle:hover {
    background-color: #374151;
    border-color: #4b5563;
}

.user-icon {
    font-size: 1.25rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.user-menu-toggle:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown menu */
.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 240px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.user-dropdown-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.user-dropdown-email {
    color: #6b7280;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    color: #374151;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
}

.dropdown-icon {
    font-size: 1.1rem;
}

.dropdown-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.5rem 0;
}

.logout-btn {
    color: #dc2626;
    border-radius: 0 0 8px 8px;
}

.logout-btn:hover {
    background-color: #fee2e2;
}

/* Container layout */
.container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Full-width container (no sidebar) */
.container.container-full {
    grid-template-columns: 1fr;
    max-width: 1600px;
}

/* Sidebar (legacy - kept for backward compatibility) */
.sidebar {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.sidebar h3 {
    margin-bottom: 1rem;
    color: #1f2937;
}

#data-coverage p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

/* Main content */
.main-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 600px;
}

.main-content h2 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.main-content hr {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

/* Filters */
.filters {
    margin-bottom: 2rem;
}

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

.filter-col {
    display: flex;
    flex-direction: column;
}

.filter-col label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.filter-col input,
.filter-col select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}

.filter-col input:focus,
.filter-col select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Checkbox dropdown */
.checkbox-dropdown {
    position: relative;
    width: 100%;
}

.checkbox-dropdown .dropdown-toggle {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: white;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}

.checkbox-dropdown .dropdown-toggle:hover {
    border-color: #9ca3af;
}

.checkbox-dropdown .dropdown-toggle:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.checkbox-dropdown .dropdown-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkbox-dropdown .dropdown-arrow {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    transition: transform 0.2s;
}

.checkbox-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.checkbox-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow: hidden;
}

.checkbox-dropdown.open .dropdown-menu {
    display: flex;
    flex-direction: column;
}

.checkbox-dropdown .dropdown-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.checkbox-dropdown .dropdown-header button {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.checkbox-dropdown .dropdown-header button:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.checkbox-dropdown .dropdown-search {
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.checkbox-dropdown .search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.checkbox-dropdown .search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.checkbox-dropdown .dropdown-options {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.checkbox-dropdown .dropdown-option {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.checkbox-dropdown .dropdown-option:hover {
    background-color: #f3f4f6;
}

.checkbox-dropdown .dropdown-option input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.checkbox-dropdown .dropdown-option label {
    flex: 1;
    cursor: pointer;
    margin-bottom: 0;
    font-weight: normal;
}

.checkbox-dropdown .loading {
    text-align: center;
    padding: 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.checkbox-dropdown .no-results {
    text-align: center;
    padding: 1rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

.advanced-filters {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: 4px;
}

.advanced-filters summary {
    cursor: pointer;
    font-weight: 500;
    color: #1f2937;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* Metrics */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background-color: #f9fafb;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.metric-card h4 {
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
}

/* Tables */
.table-container {
    margin: 2rem 0;
}

table.display {
    width: 100% !important;
}

table.display tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

table.display tbody tr:hover {
    background-color: #f3f4f6;
}

/* Charts */
.chart-container {
    margin: 2rem 0;
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: 8px;
}

/* Export section */
.export-section {
    margin: 2rem 0;
}

/* Navigation cards */
.nav-card {
    background-color: #f9fafb;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s;
}

.nav-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.nav-card h4 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.nav-card p {
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Help section */
.help-section {
    margin-top: 2rem;
    padding: 1rem;
    background-color: #f0f9ff;
    border-radius: 4px;
    border-left: 4px solid #3b82f6;
}

.help-section summary {
    cursor: pointer;
    font-weight: 500;
    color: #1f2937;
}

.help-content {
    margin-top: 1rem;
}

.help-content h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

.help-content ul {
    margin-left: 1.5rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background-color: #10b981;
}

.toast-error {
    background-color: #ef4444;
}

.toast-info {
    background-color: #3b82f6;
}

/* Loading spinner */
.spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .nav-data-coverage {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-link {
        text-align: center;
    }

    .nav-dropdown-toggle {
        width: 100%;
        justify-content: center;
    }

    .nav-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background-color: #374151;
        margin-top: 0.5rem;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-dropdown:hover .nav-dropdown-menu,
    .nav-dropdown.active .nav-dropdown-menu {
        max-height: 500px;
    }

    .nav-dropdown-item {
        color: #d1d5db;
        padding: 0.5rem 1rem;
        text-align: center;
    }

    .nav-dropdown-item:hover {
        background-color: #4b5563;
    }

    .nav-user {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .user-menu {
        width: 100%;
    }

    .user-menu-toggle {
        width: 100%;
        justify-content: center;
    }

    .user-dropdown {
        right: auto;
        left: 0;
        width: 100%;
    }

    .auth-links {
        width: 100%;
        justify-content: center;
    }

    .user-name {
        max-width: 200px;
    }

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

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

/* Badge styles for Research Lab */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 12px;
    text-align: center;
    white-space: nowrap;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

/* Info boxes */
.info-box {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.info-warning {
    background-color: #fef3c7;
    border-color: #f59e0b;
    color: #78350f;
}

.info-info {
    background-color: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
}

/* Empty and error states */
.empty-state, .error-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #6b7280;
    font-size: 1.1rem;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #d1d5db;
    margin: 2rem 0;
}

.error-state {
    color: #dc2626;
    background-color: #fee2e2;
    border-color: #fca5a5;
}

/* Risk category metric cards */
.metric-card.metric-extreme {
    border-left: 4px solid #dc2626;
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%);
}

.metric-card.metric-high {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #ffffff 100%);
}

.metric-card.metric-medium {
    border-left: 4px solid #eab308;
    background: linear-gradient(135deg, #fef9c3 0%, #ffffff 100%);
}

.metric-card.metric-low {
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #ffffff 100%);
}

/* Metric change indicators */
.metric-change {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.metric-change.positive {
    color: #10b981;
}

.metric-change.negative {
    color: #ef4444;
}
