:root {
    --sidebar-width: 260px;
    --primary-color: #1a365d;
    --primary-light: #2b6cb0;
    --theme-nav-background: var(--primary-color);
    --theme-nav-text: #ffffff;
    --theme-sidebar-background: #212529;
    --theme-sidebar-text: #ffffff;
    --theme-page-background: #f8f9fa;
    --theme-section-background: #e9ecef;
    --theme-section-text: #212529;
    --theme-footer-background: #212529;
    --theme-footer-text: #ffffff;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--theme-page-background);
}

.dashboard-layout #page-content-wrapper {
    background-color: var(--theme-page-background);
}

.public-layout {
    background-color: var(--theme-page-background);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s;
    flex-shrink: 0;
}

.sidebar .nav-link {
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    margin-bottom: 0.125rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-user-card {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-brand-title {
    letter-spacing: 0.04em;
    font-weight: 700;
}

#wrapper.toggled .sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
}

/* Stat cards */
.stat-card {
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

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

.stat-icon.bg-primary { background-color: var(--primary-color) !important; }

/* Auth layout */
.auth-layout {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* Public layout */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    min-height: var(--home-hero-min-height, auto);
    display: flex;
    align-items: center;
}

.navbar-brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.site-public-navbar {
    background-color: var(--theme-nav-background) !important;
    color: var(--theme-nav-text);
}

.site-public-navbar .navbar-brand,
.site-public-navbar .nav-link {
    color: var(--theme-nav-text) !important;
}

.site-public-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.35);
}

.site-public-navbar .navbar-toggler-icon {
    filter: invert(1);
}

.menu-brand-image-nav {
    display: inline-block;
}

.sidebar-brand-block .menu-brand-image-sidebar {
    display: block;
    margin-bottom: 0.5rem;
}

.sidebar .menu-brand-subtitle {
    color: color-mix(in srgb, var(--theme-sidebar-text) 70%, transparent);
}

.auth-brand-block .navbar-brand-content {
    justify-content: center;
}

.page-section-header {
    background: var(--theme-section-background);
    color: var(--theme-section-text);
}

.page-section-site-name {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.page-section-tagline {
    opacity: 0.8;
}

.site-footer {
    background: var(--theme-footer-background);
    color: var(--theme-footer-text);
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-light);
    --bs-btn-hover-border-color: var(--primary-light);
}

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

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

.btn-outline-primary {
    --bs-btn-color: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-color);
    --bs-btn-hover-border-color: var(--primary-color);
}

.researcher-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.researcher-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.profile-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.content-section {
    line-height: 1.8;
}

.homepage-feature-grid {
    display: grid;
    grid-template-columns: minmax(0, var(--home-first-width, 75fr)) minmax(0, var(--home-second-width, 25fr));
    gap: var(--home-feature-gap, 1.5rem);
    min-height: var(--home-feature-min-height, 430px);
    max-width: var(--home-container-max-width, 1320px);
    margin-left: auto;
    margin-right: auto;
}

.homepage-secondary-content {
    max-width: var(--home-container-max-width, 1320px);
    margin-left: auto;
    margin-right: auto;
}

.homepage-highlights-panel,
.homepage-publication-panel {
    min-width: 0;
}

.highlight-slide-grid {
    display: grid;
    grid-template-columns: repeat(var(--visible-items), minmax(0, 1fr));
    gap: 1rem;
    min-height: var(--home-slider-card-min-height, 390px);
}

.highlight-card,
.publication-feed-panel {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.highlight-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.highlight-card-image {
    width: 100%;
    height: var(--home-slider-image-height, 180px);
    object-fit: cover;
    background: #e5eaf1;
}

.highlight-card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.highlight-card-body h3 {
    font-size: 1.05rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.highlight-card-body p {
    color: #475569;
    font-size: 0.93rem;
    flex: 1;
}

.highlight-header-actions {
    display: flex;
    gap: 0.5rem;
}

.highlight-header-actions .btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.highlight-control {
    width: 42px;
}

.highlight-control .carousel-control-prev-icon,
.highlight-control .carousel-control-next-icon {
    background-color: rgba(15, 23, 42, 0.75);
    border-radius: 999px;
    background-size: 55%;
}

.publication-feed-panel {
    padding: 1rem;
}

.publication-feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: var(--home-feed-height, 360px);
    overflow: auto;
}

.publication-feed-item {
    display: block;
    text-decoration: none;
    border-bottom: 1px solid #e5eaf1;
    padding-bottom: 0.75rem;
}

.publication-feed-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.publication-feed-title {
    display: block;
    color: #111827;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.publication-feed-item small {
    color: #64748b;
}

/* Researcher profile template */
.researcher-profile-page {
    background: #f5f7fb;
}

.researcher-profile-hero,
.researcher-detail-table {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.researcher-identity-panel {
    background: #eef3f8;
    border-right: 1px solid #dde3ec;
    display: flex;
    flex-direction: column;
}

.researcher-photo-wrap {
    aspect-ratio: 1 / 1;
    background: #d9e2ec;
}

.researcher-photo,
.researcher-photo-placeholder {
    width: 100%;
    height: 100%;
}

.researcher-photo {
    object-fit: cover;
    display: block;
}

.researcher-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 5rem;
}

.researcher-contact {
    border-top: 1px solid #d4dde8;
    padding: 1rem;
    background: #fff;
}

.researcher-contact-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.researcher-contact-link,
.researcher-contact-line {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    color: #1f2937;
    text-decoration: none;
    word-break: break-word;
}

.researcher-contact-link:hover {
    color: var(--primary-light);
}

.researcher-summary-panel {
    padding: clamp(1.25rem, 3vw, 2rem);
    display: flex;
    flex-direction: column;
}

.researcher-summary-panel h1 {
    font-size: clamp(1.75rem, 3vw, 2.4rem);
    line-height: 1.15;
    margin-bottom: 0.5rem;
    color: #111827;
}

.researcher-position {
    color: #475569;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.researcher-name {
    font-family: Arial, "Helvetica Neue", Helvetica, "Liberation Sans", "DejaVu Sans", sans-serif;
    font-weight: 800;
}

.researcher-meta-lines {
    color: #475569;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.researcher-card-meta {
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.55;
}

.researcher-brief {
    color: #334155;
    margin-bottom: 1rem;
}

.researcher-focus {
    border-top: 1px solid #e5eaf1;
    padding-top: 1rem;
}

.researcher-focus h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.75rem;
}

.research-interest-list {
    padding-left: 1.25rem;
}

.research-interest-list li + li {
    margin-top: 0.35rem;
}

.researcher-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1.25rem;
}

.researcher-detail-tabs {
    display: grid;
    grid-template-columns: repeat(var(--detail-tab-count, 1), minmax(0, 1fr));
    border-bottom: 1px solid #dde3ec;
    background: #f8fafc;
}

.researcher-detail-tabs .nav-item {
    min-width: 0;
}

.researcher-detail-tabs .nav-link {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-right: 1px solid #dde3ec;
    border-radius: 0;
    color: #334155;
    font-weight: 600;
    white-space: normal;
}

.researcher-detail-tabs .nav-item:last-child .nav-link {
    border-right: 0;
}

.researcher-detail-tabs .nav-link.active {
    color: #fff;
    background: var(--primary-color);
}

.researcher-detail-content {
    position: relative;
    height: clamp(280px, 45vh, 520px);
    padding: 0;
    overflow: hidden;
}

.researcher-detail-content .tab-pane {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: clamp(1rem, 2vw, 1.5rem);
    line-height: 1.75;
}

.researcher-detail-content .tab-pane.active {
    display: block;
}

.researcher-publication-item {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5eaf1;
}

.researcher-publication-item:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: 0;
}

.researcher-publication-item h3 {
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.apa-citation {
    padding-left: 1.75rem;
    text-indent: -1.75rem;
    line-height: 1.7;
}

/* Dark theme */
[data-bs-theme="dark"] .auth-card {
    background: #1a1a2e;
}

[data-bs-theme="dark"] .sidebar {
    background-color: #0d1117 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 1000;
        margin-left: calc(-1 * var(--sidebar-width));
    }

    #wrapper.toggled .sidebar {
        margin-left: 0;
    }

    #page-content-wrapper {
        width: 100% !important;
    }

    .researcher-identity-panel {
        border-right: 0;
        border-bottom: 1px solid #dde3ec;
    }

    .researcher-photo-wrap {
        aspect-ratio: 4 / 3;
    }

    .researcher-detail-tabs {
        grid-template-columns: repeat(min(var(--detail-tab-count, 1), 2), minmax(0, 1fr));
    }

    .highlight-slide-grid {
        grid-template-columns: 1fr;
    }

    .homepage-feature-grid {
        grid-template-columns: 1fr;
    }

    .researcher-detail-tabs .nav-link {
        border-bottom: 1px solid #dde3ec;
    }
}

@media (max-width: 480px) {
    .researcher-detail-tabs {
        grid-template-columns: 1fr;
    }

    .researcher-detail-tabs .nav-link {
        border-right: 0;
    }
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
}

/* Organization tree */
.org-tree h5 {
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
}

/* Component builder */
.component-item {
    cursor: default;
    transition: background-color 0.2s, opacity 0.2s;
}

.faculty-directory-group {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.faculty-directory-group:last-child {
    border-bottom: 0;
}

.researcher-card-meta div + div {
    margin-top: 0.15rem;
}

.component-item.component-hidden {
    opacity: 0.65;
    background-color: rgba(0, 0, 0, 0.03);
}

.component-handle {
    cursor: grab;
}

.component-ghost {
    opacity: 0.4;
    background: #e9ecef;
}
