{% if sections %}
<style>
    .title-header, .footer{
        background-color: #3DB2DD;
        color: white;
        padding: 5px;
    }

    .title-header h3{
        margin-top: 10px;
        margin-bottom: 0;

    }

    .brand-logo{
        width: 100%;
        max-width: 100px;
        float: right;
    }

    .section-header{
        color: #7f7f7f;
        background-color: #dceef4;
        padding-bottom: 5px;
        padding-top: 5px;
        margin-bottom: 0px;
    }

    .sub-section-container{
        padding-left: 0px;
        padding-right: 0px;
    }

    .sub-section-container .section-header{
        border-right: 2px solid #7f7f7f;
    }

    .sub-section-container:last-child .section-header{
        border-right: 0px;
    }

    .sub-section-container .section-header{
        padding-left: 15px;
    }

    .number-element{
        color: #1eb1ed;
        font-size: 18pt;
        font-weight: bold;
    }

    .section-container{
        padding-bottom: 15px;
    }

    .people-section .number-element{
        font-size: 30pt;
    }

    .people-item{
        display: inline-block;
        margin: 20px 15px 0 15px;
    }

    .people-item .icon-container{
        display: inline-block;
        vertical-align: top;
        width: 100px;
        height: 100px;
    }

    .people-item .text-container{
        display: inline-block;
        vertical-align: top;
        margin: 0 15px;
    }

    .vulnerability-section .icon-container, .minimum-needs-section .icon-container{
        width: 100px;
        height: 100px;
        margin-left: auto;
        margin-right: auto;
        margin-top: 20px;
        display: flex;
    }

    .icon-container img{
        margin: auto;
        max-width: 100%;
        max-height: 100%;
    }

    .header-element{
        color: #7f7f7f;
        font-size: 14pt;
        font-weight: bold;
    }

    .header-note-element{
        color: #8490a8;
        font-size: 10pt;
        max-width: 270px;
    }

    .small-header{
        font-size: 8pt;
        margin-left: 10px;
    }

    .percentage-element{
        color: #dceef4;
        font-size: 18pt;
        font-weight: bold;
    }

    .unit-element{
        color: #7f7f7f;
        font-style: italic;
    }

    #population-chart{
        padding-bottom: 16px;
    }

    .total-value, .slice-value, .slice-percentage {
        font-weight: bold;
        font-size: 12pt;
    }

    .total-value-header{
        font-size: 12pt;
    }

    .chart-title{
        font-size: 14px;
        font-weight: bold;
        color: #7f7f7f;
    }

    .legend-label{
        font-size: 8pt;
        font-weight: bold;
        margin-right: 8px;
    }

{% if sections['population_chart']['context'] %}
    {% for slice in sections['population_chart']['context'].slices %}
    .hazard-class.label-class-{{ sections.population_chart.css_label_classes[loop.index] }}{
        width: 8px;
        height: 8px;
        display: inline-block;
        margin: 0 8px;
        background-color: {{ slice.fill }};
    }
    {% endfor %}
{% endif %}

</style>

<div class="row title-header">
    <div class="col-xs-9 col-md-9">
        <h3>{{ title|capitalize }}</h3>
    </div>
    <div class="col-xs-3 col-md-3">
        <img class="brand-logo" src="{{ brand_logo }}" title="InaSAFE" alt="InaSAFE" />
    </div>
</div>

<div class="row">
    <div class="col-xs-12 col-md-4 chart-section section-container">
        <div id="population-chart">
            <div class="chart-title">{{ sections.population_chart.context.title|capitalize }}</div>
            <img src="{{ sections.population_chart.img_path }}">
            {% if sections['population_chart']['context'] %}
            <div>
                {% for slice in sections['population_chart']['context'].slices %}
                    {% if slice.label %}
                    <span class="legend-label">
                        <span class="hazard-class label-class-{{ sections.population_chart.css_label_classes[loop.index] }}"></span>
                        {{ slice.label }}
                    </span>
                    {% endif %}
                {% endfor %}
            </div>
            {% endif %}
        </div>
    </div>
    <div class="col-xs-12 col-md-8 people-section section-container">
        {# People section #}
        <div class="row">
            <div class="col-md-12">
                <h5 class="section-header">{{ sections.people.header|capitalize }}</h5>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-md-12">
                {% for item in sections['people']['items'] %}
                <span class="people-item">
                    <span class="icon-container">
                        <img src="{{ resource }}{{ item.icon }}" />
                    </span>
                    <span class="text-container">
                        <div class="">
                            <div class="number-element">
                                {{ item.number }}
                            </div>
                        </div>
                        <div class="">
                            <div class="header-element">
                                {{ item.header|capitalize }}
                            </div>
                        </div>
                        <div class="">
                            <div class="header-note-element">
                                {% if item.header_note %}
                                {{ item.header_note }}
                                {% endif %}
                            </div>
                        </div>
                    </span>
                </span>
                {% endfor %}
            </div>
        </div>
    </div>
    {% if sections['vulnerability']['items'] %}
    <div class="col-xs-12 col-md-8 vulnerability-section section-container">
        {# Vulnerability section #}
        <div class="row">
            <div class="col-md-12">
                <h5 class="section-header">{{ sections.vulnerability.header|capitalize }}
                    <span class="small-header">{{ sections.vulnerability.small_header|capitalize }}</span>
                </h5>
            </div>
        </div>
        <div class="row">
            {% for item in sections['vulnerability']['items'] %}
                <div class="sub-section-container {{ item.bootstrap_column }}">
                    <div class="section-header">
                        <h6>{{ item.group_header }}</h6>
                    </div>
                    <div class="row">
                    {% for element in item['items'] %}
                        <div class="{{ item.element_column }}">
                            <div class="icon-container">
                                <img src="{{ element.icon }}" />
                            </div>
                            <div class="number-element text-center">
                                {{ element.number }}
                            </div>
                            <div class="percentage-element text-center">
                                {{ element.percentage }}%
                            </div>
                            <div class="header-element text-center">
                                {{ element.header|capitalize }}
                            </div>
                        </div>
                    {% endfor %}
                    </div>
                </div>
            {% endfor %}
        </div>
    </div>
    {% endif %}
    <div class="col-xs-12 col-md-12 minimum-needs-section section-container">
        {# Minimum needs section #}
        <div class="row">
            <div class="col-md-12">
                <h5 class="section-header">{{ sections.minimum_needs.header|capitalize }}
                    <span class="small-header">{{ sections.minimum_needs.small_header|capitalize }}</span>
                </h5>
            </div>
        </div>
        <div class="row">
            {% for item in sections['minimum_needs']['items'] %}
            <div class="col-xs-3 col-md-2">
                <div class="icon-container">
                    <img src="{{ item.icon }}" />
                </div>
                <div class="number-element text-center">
                    {{ item.number }}
                </div>
                <div class="unit-element text-center">
                    {{ item.unit }}
                </div>
                <div class="header-element text-center">
                    {{ item.header|capitalize }}
                </div>
            </div>
            {% endfor %}
        </div>
    </div>
</div>
{% endif %}
