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

:root {
    /* Curtin University Official Corporate Colors */
    --curtin-grey: #919296;
    --curtin-gold: #B58C10;
    --curtin-black: #000000;

    --primary-color: var(--curtin-grey);
    --accent-color: var(--curtin-gold);
    --secondary-color: #64748b;
    --svg-grey: #64748b;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: var(--curtin-black);
    --text-secondary: #475569;
    --code-bg: #f1f5f9;
    --cqi-blue: #1353B3;
    --cqi-hover: #0d3d8a;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
}

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

header {
    background: var(--curtin-grey);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: flex-end;
    gap: 2rem;
}

.curtin-logo {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.curtin-logo:first-child img {
    height: 60px;
    width: auto;
}

.curtin-logo:last-child img {
    height: calc((60px + 0.85rem + 0.3rem) * 1.40);
    width: auto;
    object-fit: contain;
    transform: translateY(-2px);
}

.school-info {
    font-size: 0.85rem;
    margin-top: 0.3rem;
    opacity: 0.95;
}

.header-text {
    flex-grow: 1;
}

.lucap-logo {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    margin-left: auto;
}

.lucap-logo img {
    height: 128px;
    width: auto;
    margin-bottom: 5px;
}

header h1 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

header p {
    opacity: 0.95;
    font-size: 0.85rem;
    font-weight: 300;
}

nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    padding: 0;
}

nav li {
    margin: 0;
}

nav a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

nav a:hover {
    color: var(--curtin-grey);
    background-color: var(--bg-color);
    border-bottom-color: var(--curtin-grey);
}

/* Collapse All Button */
.collapse-all-btn {
    background-color: var(--curtin-gold) !important;
    color: white !important;
    font-weight: 500;
    border-radius: 4px;
    padding: 0.75rem 1.25rem !important;
}

.collapse-all-btn:hover {
    background-color: #a07a0d !important;
    border-bottom-color: transparent !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.collapse-all-btn i {
    margin-right: 0.5rem;
}

/* REDCap Navigation Menu */
.redcap-nav {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 2rem;
    position: relative;
    z-index: 10;
}

.redcap-nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.redcap-nav li {
    margin: 0;
}

.redcap-nav a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
}

.redcap-nav a:hover {
    color: var(--curtin-grey);
    background-color: white;
    border-bottom-color: var(--curtin-gold);
}

main {
    padding: 3rem 0;
}

section {
    margin: 1rem 0;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    scroll-margin-top: 80px;
}

h2 {
    color: var(--curtin-grey);
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 500;
}

h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

h4 {
    color: var(--text-primary);
    font-size: 1.15rem;
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

/* Heading hierarchy within collapsible sections */
.collapsible-header h2,
.collapsible-header h3,
.collapsible-header h4 {
    margin: 0;
    padding: 0;
    border: none;
    font-weight: 500;
}

.collapsible-header h2 {
    font-size: 1.75rem;
}

.collapsible-header h3 {
    font-size: 1.4rem;
}

.collapsible-header h4 {
    font-size: 1.15rem;
    color: var(--text-secondary);
}

/* Section Icons */
.section-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
    margin-top: -0.125rem;
    color: var(--svg-grey);
}

/* Bootstrap Icons font sizes */
.collapsible-header h2 .section-icon {
    font-size: 24px;
    line-height: 1;
}

.collapsible-header h3 .section-icon {
    font-size: 20px;
    line-height: 1;
}

.collapsible-header h4 .section-icon {
    font-size: 18px;
    line-height: 1;
}

.collapsible-header:hover .section-icon {
    color: #6b6c6f;
}

.endpoint {
    background: var(--bg-color);
    border-left: 4px solid var(--curtin-grey);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--card-bg);
    font-size: 0.9rem;
}

thead {
    background: var(--bg-color);
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 500;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    background: var(--bg-color);
}

tbody tr:hover {
    background-color: #fef3c7;
}

/* Unmapped CSV fields styling */
tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr.unmapped-field {
    background-color: #f3f4f6;
    border-left: 3px solid #d1d5db;
}

tbody tr.unmapped-field td {
    color: #6b7280;
}

tbody tr.unmapped-field code {
    color: #6b7280;
    background-color: #e5e7eb;
}

tbody tr.unmapped-field:hover {
    background-color: #e5e7eb;
}

tbody tr:not(.unmapped-field):hover {
    background-color: #f0fdf4;
}

tbody tr:not(.unmapped-field) {
    border-left: 3px solid transparent;
}

code {
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    color: #e11d48;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-checkbox {
    background: #8b5cf6;
    color: white;
}

.badge-dropdown {
    background: #3b82f6;
    color: white;
}

.badge-radio {
    background: #6366f1;
    color: white;
}

.badge-text {
    background: #6b7280;
    color: white;
}

.badge-descriptive {
    background: #94a3b8;
    color: white;
}

.alert {
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 4px;
    margin: 1rem 0;
    border-left: 4px solid;
    position: relative;
}

.alert::before {
    font-family: 'bootstrap-icons';
    position: absolute;
    left: 1rem;
    font-size: 1.2rem;
}

.alert-info {
    background: #e8e8e9;
    border-color: var(--curtin-grey);
    color: var(--curtin-black);
}

.alert-info::before {
    content: "\f431"; /* bi-info-circle */
    color: var(--curtin-grey);
}

.alert-warning {
    background: #fef3c7;
    border-color: var(--warning-color);
    color: #92400e;
}

.alert-warning::before {
    content: "\f33a"; /* bi-exclamation-triangle */
    color: var(--warning-color);
}


.collapsible-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    margin-bottom: 1.5rem;
    user-select: none;
}

.collapsible-header:hover h2 {
    color: #6b6c6f;
}

.collapsible-header:hover h3,
.collapsible-header:hover h4 {
    color: #6b6c6f;
}

.collapsible-toggle {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
    color: var(--curtin-grey);
}

.collapsible-toggle.collapsed {
    transform: rotate(-90deg);
}

.collapsible-content {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease-in-out;
}

.collapsible-content.expanded {
    display: block;
    max-height: 5000px;
    opacity: 1;
    pointer-events: auto;
    transition: all 0.3s ease-in-out;
}

footer {
    background: var(--curtin-black);
    color: white;
    padding: 0;
    margin-top: 4rem;
}

.curtin-footer {
    background-color: var(--curtin-black);
    color: #ffffff;
    padding: 0.25rem 0 0 0;
}

.curtin-footer h4 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: #ffffff;
}

.curtin-footer p {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
    opacity: 0.9;
}

.curtin-footer a {
    color: #ffffff;
    text-decoration: none;
    opacity: 0.9;
}

.curtin-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

.footer-info {
    margin-bottom: 0.25rem;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: 0.1rem;
}

.footer-links a {
    display: inline-block;
}

.copyright {
    background-color: #303030;
    padding: 0.2rem 0;
    text-align: center;
    font-size: 0.85rem;
}

.copyright p {
    margin: 0;
    opacity: 0.8;
}

.index-col {
    font-weight: 500;
    color: var(--secondary-color);
    text-align: left;
    width: 45px;
    font-size: 0.85rem;
}

.type-col {
    text-align: left;
    width: 120px;
}

.badge-link {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s, box-shadow 0.2s;
}

.badge-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.badge-link .badge {
    cursor: pointer;
}

/* Download Template Button */
.download-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--curtin-grey) 0%, #6b6c6f 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.download-template-btn:hover {
    background: linear-gradient(135deg, var(--curtin-gold) 0%, #a07a0d 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    color: white;
}

.download-template-btn i {
    font-size: 1.2rem;
}

/* CSV Upload Zone Styles */
.csv-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.csv-upload-zone:hover {
    border-color: var(--curtin-grey);
    background: #f9fafb;
}

.cqi-col {
    text-align: left;
    width: 140px;
}

.cqi-empty {
    color: #9ca3af;
    font-size: 1.1rem;
}

.search-box {
    margin: 1rem 0;
    padding: 0.75rem;
    width: 100%;
    max-width: 400px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.search-box:focus {
    outline: none;
    border-color: var(--curtin-grey);
    box-shadow: 0 0 0 0.2rem rgba(145, 146, 150, 0.25);
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.mapping-card {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mapping-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    border-color: var(--curtin-gold);
}

.mapping-source,
.mapping-target {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mapping-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0;
    letter-spacing: 0.3px;
    line-height: 1;
}

.csv-field {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    line-height: 1.3;
}

.csv-field a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.csv-field a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.csv-field a code {
    cursor: pointer;
}

.field-index {
    display: inline-block;
    background: var(--curtin-grey);
    color: white;
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.2;
}

.csv-field code,
.redcap-field code {
    font-size: 0.8rem;
    line-height: 1.3;
}

.redcap-field {
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.redcap-field code {
    color: #0ea5e9;
    font-weight: 500;
}

.mapping-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0.25rem;
}

.mapping-transformation {
    margin-top: 0.3rem;
}

.transformation-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid #fbbf24;
}

/* CQI Section Styles */
.cqi-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--card-bg);
}

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

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

.cqi-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.cqi-table tbody tr:hover {
    background-color: #f0f9ff;
}

.cqi-field-list {
    line-height: 1.8;
}

.cqi-field-link {
    color: var(--cqi-blue);
    text-decoration: none;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    transition: all 0.2s;
    display: inline-block;
}

.cqi-field-link:hover {
    background-color: #e0f2fe;
    color: var(--cqi-hover);
    text-decoration: underline;
}

.cqi-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--cqi-blue);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    margin-left: 0.3rem;
    transition: all 0.2s;
    cursor: pointer;
}

.cqi-badge:hover {
    background: var(--cqi-hover);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(19, 83, 179, 0.3);
}

.cqi-badges {
    display: inline-flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    align-items: center;
}

/* REDCap Lookup Data Styles */
.lookup-field-container {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border-left: 4px solid var(--curtin-grey);
    border-radius: 4px;
}

.lookup-field-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.lookup-field-header h5 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}


.badge-lookup-type {
    background: var(--curtin-gold);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
}

.lookup-value-count {
    background: var(--success-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.lookup-values-table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.lookup-values-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 0.9rem;
}

.lookup-values-table thead {
    background: var(--bg-color);
    position: sticky;
    top: 0;
}

.lookup-values-table th,
.lookup-values-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.lookup-values-table th {
    font-weight: 500;
    color: var(--text-primary);
}

.lookup-values-table tbody tr:hover {
    background-color: #fef3c7;
}

.lookup-code-col {
    width: 120px;
    font-weight: 500;
}

.lookup-label-col {
    width: auto;
}

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

    .curtin-logo img {
        height: 50px;
    }

    nav ul {
        flex-direction: column;
    }

    section {
        padding: 1.5rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem;
    }

    .index-col {
        width: 40px;
    }

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

    .mapping-card {
        flex-direction: column;
        text-align: center;
    }

    .mapping-arrow svg {
        transform: rotate(90deg);
    }

    .lookup-field-container {
        padding: 1rem;
    }

    .lookup-code-col {
        width: 80px;
    }
}

/* Highlight effect for navigated rows */
@keyframes highlightFade {
    0% { background-color: rgba(255, 193, 7, 0.3); }
    100% { background-color: transparent; }
}

@keyframes highlightFadeYellow {
    0% { background-color: #fef3c7; }
    100% { background-color: transparent; }
}

@keyframes highlightFadeBlue {
    0% { background-color: #dbeafe; }
    100% { background-color: transparent; }
}

.highlight-row {
    animation: highlightFade 2s ease-out;
}

.highlight-flash {
    animation: highlightFadeYellow 2s ease-out;
}

.highlight-flash-blue {
    animation: highlightFadeBlue 2s ease-out;
}
