/* ============================================
   OurCare Dashboard - Single Question Layout
   Based on Figma Design
   ============================================ */

/* Design Tokens */
:root {
    /* Colors */
    --primary-purple: #4D5DD9;
    --primary-purple-dark: #6550FF;
    --accent-cyan: #01DBFF;
    --accent-green: #6DF2B9;
    --accent-pink: #FF4F8B;
    --accent-yellow: #FFC107;
    --accent-purple: #673AB7;
    --accent-orange: #FD7045;
    --accent-blue: #286EE2;
    --accent-lime: #86E749;
    --accent-magenta: #B150C2;
    --border-gray: #B5B4C8;
    --bg-light: #F2F1FD;
    --bg-white: #FFFFFF;
    --text-black: #000000;
    --text-white: #FFFFFF;
    
    /* Typography */
    --font-primary: 'Poppins', sans-serif;
    --font-secondary: 'Outfit', sans-serif;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
}

/* Global overflow prevention */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* Base Layout */
.question-page {
    position: relative;
    width: 100%;
    min-height: 100vh;
    background: var(--bg-white);
    overflow-x: hidden;
    max-width: 100vw;
}

/* Navigation Bar */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    width: 100%;
    max-width: 100vw;
    height: 72px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-gray);
    overflow-x: hidden;
}

.nav-logo {
    font-family: var(--font-primary);
    font-style: normal;
    font-weight: 700;
    font-size: 32px;
    line-height: 102%;
    letter-spacing: -0.04em;
    color: var(--primary-purple);
}

.nav-search {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px 8px 16px;
    gap: 11px;
    width: 731px;
    max-width: 100%;
    height: 36px;
    background: var(--bg-white);
    border: 1px solid var(--border-gray);
    border-radius: 40px;
    box-sizing: border-box;
    flex-shrink: 1;
}

.nav-search input {
    flex: 1;
    border: none;
    outline: none;
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 14px;
    line-height: 102%;
    color: var(--text-black);
}

.nav-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
}

.nav-dropdown {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    color: var(--text-black);
}

.nav-button {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 10px 16px;
    gap: 4px;
    width: 93px;
    height: 36px;
    border: 1px solid var(--primary-purple);
    border-radius: 39px;
    background: transparent;
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    color: var(--primary-purple);
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-button:hover {
    background: var(--primary-purple);
    color: var(--text-white);
}

/* Side Navigation */
.side-nav {
    position: fixed;
    left: 0;
    top: 72px;
    width: 300px;
    max-width: 100%;
    height: calc(100vh - 72px);
    background: var(--bg-light);
    padding: 27px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.side-nav-item {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 14px;
    line-height: 102%;
    color: var(--text-black);
    cursor: pointer;
    padding: 6px 0 6px 16px;
    transition: color 0.3s ease;
}

/* First item (All Responses) should not be indented */
.side-nav-item:first-child {
    padding-left: 0;
    font-weight: 500;
}

.side-nav-item.active {
    font-weight: 600;
    color: var(--primary-purple);
}

.side-nav-item:hover {
    color: var(--primary-purple);
}

/* Question Header */
.question-header {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 24px 12px 24px;
    gap: 16px;
    width: calc(100% - 300px);
    max-width: calc(100vw - 300px);
    margin-left: 300px;
    margin-top: 72px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-gray);
    overflow-x: hidden;
}

.question-breadcrumb {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 16px;
    line-height: 140%;
    color: var(--primary-purple);
    flex-wrap: wrap;
    max-width: 100%;
}

.question-breadcrumb-item {
    color: var(--text-black);
}

.question-title {
    font-family: var(--font-primary);
    font-style: normal;
    font-weight: 600;
    font-size: 36px;
    line-height: 102%;
    color: var(--text-black);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Main Content Area */
.main-content {
    width: calc(100% - 300px);
    max-width: calc(100vw - 300px);
    margin-left: 300px;
    padding: 0px 12px 24px 12px;
    background: var(--bg-white);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Section Headers */
.section-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    margin-left: 40px;
}

.section-title {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 24px;
    line-height: 120%;
    color: var(--text-black);
}

.section-subtitle {
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 16px;
    line-height: 102%;
    color: var(--text-black);
    text-align: right;
}

/* Chart Container */
.chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 40px;
    margin-left: -20px;
    box-sizing: border-box;
    /* Ensure the chart area never becomes its own vertical scroll container */
    overflow-x: hidden;
    overflow-y: visible;
}

.chart-wrapper-container {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: flex-start;
    width: 100%;
}

.chart-wrapper-container .legend {
    align-self: flex-start;
    margin-top: 0;
}

/* Align legend with chart area (below title) for demographic charts */
.demographic-section .chart-wrapper-container .legend {
    margin-top: 40px;
}

/* Chart Disclaimer */
.chart-disclaimer {
    margin-top: 16px;
    margin-left: 20px;  /* Compensate for chart-container's -20px margin */
    font-family: var(--font-primary);
    font-size: 12px;
    line-height: 1.5;
    color: #666666;
    font-style: italic;
    padding: 0;
}

.percentile-grid {
    position: relative;
    width: 100%;
    height: 364px;
    margin-bottom: 24px;
}

.percentile-grid-lines {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    gap: 52px;
    position: absolute;
    left: 22px;
    right: 23px;
    top: 0;
    bottom: 24px;
}

.percentile-line {
    width: 100%;
    height: 0;
    opacity: 0.5;
    border: 1px solid var(--border-gray);
    transform: rotate(90deg);
}

.percentile-labels {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.percentile-label {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 14px;
    line-height: 102%;
    text-align: center;
    color: var(--text-black);
}

/* Demographic Breakdown */
.demographic-section {
    margin-bottom: 60px;
}

.demographic-section .chart-container {
    margin-left: -15px;
}

.demographic-chart-title {
    margin-left: 40px;
}

.demographic-title {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 18px;
    line-height: 120%;
    color: var(--text-black);
    margin-bottom: 16px;
}

.demographic-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    margin-left: 0;
    margin-right: 0;
}


.demographic-chart {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
}

.demographic-label {
    position: absolute;
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    text-align: right;
    color: var(--text-black);
}

/* Bar Chart Colors */
.bar-color-1 { background: var(--primary-purple-dark); }
.bar-color-2 { background: var(--accent-green); }
.bar-color-3 { background: var(--accent-pink); }
.bar-color-4 { background: var(--accent-yellow); }
.bar-color-5 { background: var(--accent-purple); }
.bar-color-6 { background: var(--accent-orange); }
.bar-color-7 { background: var(--accent-blue); }
.bar-color-8 { background: var(--accent-lime); }
.bar-color-9 { background: var(--accent-magenta); }
.bar-color-10 { background: var(--accent-cyan); }

/* Legend */
.legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 200px;
    flex-shrink: 0;
    margin-top: 0;
}

.legend-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
}

.legend-color {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.legend-label {
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    color: var(--text-black);
}

/* Tooltip */
.tooltip {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 19px 0;
    gap: 10px;
    position: absolute;
    background: var(--bg-white);
    box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    z-index: 1000;
}

.tooltip-content {
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    text-align: right;
    color: var(--text-black);
}

.tooltip-arrow {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--bg-white);
    transform: rotate(-90deg);
}

/* Footer */
.data-footer {
    width: calc(100% - 300px);
    max-width: calc(100vw - 300px);
    margin-left: 300px;
    height: auto;
    min-height: 199px;
    background: var(--text-black);
    padding: 37px 12px;
    margin-top: 60px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 100%;
    box-sizing: border-box;
}

.footer-logos {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 37px;
    flex-wrap: wrap;
    max-width: 100%;
}

.footer-divider {
    width: 100%;
    height: 0;
    border: 1px solid var(--text-white);
}

.footer-links {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 34px;
    flex-wrap: wrap;
    max-width: 100%;
}

.footer-link {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: 14px;
    line-height: 102%;
    color: var(--primary-purple);
    text-decoration: none;
}

.footer-copyright {
    font-family: var(--font-secondary);
    font-weight: 400;
    font-size: 14px;
    line-height: 140%;
    letter-spacing: 0.06em;
    color: var(--text-white);
}

/* Responsive Design */
@media (max-width: 1440px) {
    .main-content,
    .question-header {
        width: calc(100% - 300px);
        max-width: calc(100vw - 300px);
    }
}

@media (max-width: 1200px) {
    .nav-search {
        width: 100%;
        max-width: 500px;
    }
    
    .nav-actions {
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .side-nav {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .side-nav.open {
        transform: translateX(0);
    }
    
    .main-content,
    .question-header {
        width: 100%;
        max-width: 100vw;
        margin-left: 0;
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .nav-search {
        width: 100%;
        max-width: 100%;
        min-width: 200px;
    }
    
    .nav-bar {
        padding: 16px;
        flex-wrap: wrap;
        height: auto;
        min-height: 72px;
    }
    
    .nav-actions {
        width: 100%;
        margin-top: 12px;
        justify-content: flex-start;
    }
    
    .question-header {
        padding: 24px 16px;
    }
    
    .data-footer {
        width: 100%;
        max-width: 100vw;
        margin-left: 0;
        padding: 24px 16px;
    }
    
    /* Footer Links Mobile - Vertical and left-aligned */
    .footer-links-mobile {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px;
    }
    
    /* Shared Legend - Show on mobile */
    .shared-demographic-legend {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 12px 16px;
        padding: 0 0 24px 0;
        margin: 0;
    }
    
    .shared-demographic-legend .legend-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: calc(50% - 8px);
        min-width: 140px;
    }
    
    .shared-demographic-legend .legend-color {
        width: 14px;
        height: 14px;
        border-radius: 2px;
        flex-shrink: 0;
    }
    
    .shared-demographic-legend .legend-label {
        font-family: var(--font-primary);
        font-weight: 500;
        font-size: 12px;
        line-height: 102%;
        color: var(--text-dark);
    }
    
    /* Hide individual chart legends on mobile - only show the shared legend at the top */
    .demographic-section .legend {
        display: none !important;
    }
    
    /* Stack demographic header vertically on mobile */
    .demographic-header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    #optionSelectorContainer {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    #optionSelectorContainer label {
        margin-right: 0 !important;
        margin-bottom: 4px;
    }
    
    #optionSelectorContainer select {
        width: 100% !important;
        min-width: unset !important;
    }
    
    /* Reduce margins and padding on mobile to maximize space for labels */
    .section-header {
        margin-left: 8px;
    }
    
    .chart-wrapper-container {
        gap: 8px;
    }
    
    /* Remove left padding from chart wrapper - we're using y-axis width instead */
    .chart-wrapper {
        padding-left: 0;
        margin-left: 0;
    }
    
    .chart-container {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Ensure disclaimer is visible and not covered on mobile */
    .chart-disclaimer {
        margin-left: 16px;
        padding-right: 16px;
    }
}

/* Additional mobile breakpoint for 480px */
@media (max-width: 480px) {
    .main-content {
        padding-left: 4px;
        padding-right: 4px;
    }
    
    .section-header {
        margin-left: 4px;
    }
    
    .chart-wrapper-container {
        gap: 4px;
    }
    
    .chart-disclaimer {
        margin-left: 12px;
        padding-right: 12px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
