/**
 * Forest Declaration Custom Charts - Chart Tabs Styling
 */


:root {
    --primary: #005756;
    --accent: #820263;
    --neutral-orange: #c44601;
    --neutral-blue: #00f;
    --neutral-fourthiary: hsla(0, 0%, 46%, .25);
    --neutral-tertiary: #dcdcdc;
    --neutral-secondary: #a9a9a9;
    --neutral-grey: #757575;
}

/* Chart wrapper */
.fdcc-chart-wrapper {
    width: 100%;
    background-color: #fff;
    position: relative;
    padding-top: 1em;
    padding-bottom: 1em;
    margin-top: 1.6em;
    margin-bottom: 1.6em;
}

/* Chart tabs container */
.fdcc-chart-tabs {
    display: flex;
    flex-wrap: wrap;
}

/* Chart tab buttons */
button.fdcc-chart-tab {
    font-size: 13px;
    padding: 0.6em 1em;
    margin-right: 5px;
    cursor: pointer;
    color: var(--neutral-grey);
    background-color: #f8f8f8;
    border: 1px solid var(--neutral-grey);
    border-bottom: none;
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease-in;
}

button.fdcc-chart-tab:hover {
    color: #fff;
    background-color: var(--accent);
    border-color: var(--accent);
}

button.fdcc-chart-tab.active {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);

}

/* 
 * Chart container 
 * Set visibility, responsiveness and positoning.
 */


.fdcc-chart-type-container {
    position: relative;
    width: 100%;
    padding: 15px;
    border-width: 1px;
    border-color: var(--neutral-grey);
    border-style: solid;
    box-sizing: border-box;

    max-height: 0;
    opacity: 0;
    display: none;
    transition: all 0.3s ease-in-out;
    /* Hide until active */
}

.fdcc-chart-type-container.active {
    display: block;
    max-height: 2000px !important;
    opacity: 1 !important;
    /* Show when active */
}

/* Make sure chart containers are responsive */
.fdcc-chart-container {
    position: relative;
    width: 100%;
    height: auto;
    padding-top: 1em;
}

/**
 * Chart no data
 *
 */

 .fdcc-no-data-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    width: 100%;
    text-align: center;
    transition:opacity 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.fdcc-no-data-message p {
    color: var(--neutral-grey);
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
}

.fdcc-no-data-message.no-geo-data{
    opacity: 0;
}

/* Add new rule to hide tooltip when no-data message is shown */
.fdcc-chart-container:has(.fdcc-no-data-message.visible) .fdcc-tooltip.single-geo-tooltip {
    opacity: 0 !important;
    pointer-events: none !important;
}

/**
 *  Chart Type Header Styling
 * 
 */

/* Chart type header (inside each chart container) */
.fdcc-chart-type-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
}

/* Multiple logos container */
.fdcc-chart-type-logos {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex: 0 0 100%;
    padding-bottom: 10px;
}

/* Individual logo */
.fdcc-chart-type-logo {
    display: flex;
    align-items: center;
    height: 50px;
}

.fdcc-chart-type-logo img {
    max-height: 100%;
    max-width: 110px;
    height: auto;
}

/* Title in chart type header */
.fdcc-chart-type-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--neutral-grey);
}

/* Chart visualization area - specific target for D3 charts */
.fdcc-chart-visualization {
    width: 100%;
    height: 400px;
    /* Specific height for the visualization area */
}

/* Control areas above charts - geo selectors, etc. */
.fdcc-chart-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1em;
    margin-bottom: 10px;
}

/* Filter and country selectors styling */
.fdcc-geo-select,
.fdcc-year-select {
    margin-bottom: 15px;
    background-color: #fff;
}

.fdcc-select-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1em;
}


.fdcc-select-wrapper {
    width: 100%;
}

.fdcc-select-controls .fdcc-select-label,
.fdcc-chart-controls .fdcc-no-data-indicator {
    text-transform: uppercase;
    line-height: 1;
}

.fdcc-select-controls .fdcc-select-label{
    font-size: 8px;
}

.fdcc-chart-controls .fdcc-no-data-indicator{
    font-size: 10px;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}
.fdcc-chart-controls .fdcc-no-data-indicator.visible{
    display: flex !important;
}

.fdcc-chart-controls .fdcc-no-data-indicator .fdcc-no-data-countries{
    font-size: 13px;
}


.fdcc-no-data-indicator button,
.fdcc-select-controls button {
    flex: 0 0 fit-content;
    background: transparent;
    text-transform: uppercase;
    font-size: 10px;
    padding: 5px 8px;
    color: var(--neutral-grey);
    border: 1px solid var(--neutral-grey);
    border-radius: 4px;
}

.fdcc-select-controls button:disabled {
    opacity: 0;
    height: 0;
}

.fdcc-select-controls .fdcc-select-label span{
    display: inline-block;
    width: 50px;
}

.fdcc-select-controls .ts-wrapper {
    margin-bottom: 0;
}

.fdcc-chart-container .ts-dropdown .option.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    background-color: #f5f5f5 !important;
}

/* fix padding when removing x icon */
.fdcc-chart-container .ts-wrapper.multi .ts-control>div {
    padding: 2px 6px !important;
}

@media (max-width: 768px) {
    .fdcc-chart-type-header {
        flex-direction: column;
        align-items: flex-start;
        padding-bottom: 2em;
    }

    .fdcc-chart-type-logos {
        justify-content: center;
        width: 100%;
    }

    /* Adjust the chart controls for smaller screens */
    .fdcc-chart-controls {
        flex-wrap: wrap;
        flex-direction: column;
    }

    .fdcc-select-controls {
        flex-direction: column;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .fdcc-select-controls button {
        flex: 0 0 fit-content;
        width: auto;
    }

    .fdcc-chart-controls .fdcc-no-data-indicator {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
    }

    .fdcc-no-data-indicator .fdcc-reset-all-btn {
        flex: 0 0 fit-content;
        width: auto;
        margin: 0;
    }


}

/**
 * Grid lines
 **/

 .fdcc-chart-container .grid-line {
    stroke: var(--neutral-grey);
    stroke-width: 0.5;
    shape-rendering: 3px, 3px;
}

/**
 * Download button styling.
 **/

.fdcc-chart-download {
    position: absolute;
    bottom: -10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.fdcc-chart-download:hover {
    background-color: #f8f8f8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.fdcc-chart-download svg {
    width: 16px;
    height: 16px;
}

/**
 * Global tooltip  and hover points styles
 **/

.fdcc-tooltip {
    position: absolute;
    background-color: #fff;
    padding: 10px 14px;
    border-radius: 2px;
    font-size: 12px;
    pointer-events: none;
    min-width: 120px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s;
}

/* Hover points */
.hover-points circle {
    pointer-events: none;
    transition: opacity 0.2s;
    background-color: #fff;
}

/**
* Global axis and ais label styles
**/


.fdcc-chart-container .tick text {
    font-size: 12px;
    font-weight: 500;
}

.fdcc-chart-container .y-axis-label {
    font-size: 15px;
    fill: var(--neutral-grey);
}


.fdcc-chart-container .y-axis .tick line,
.fdcc-chart-container .x-axis .tick line,
.fdcc-chart-container .y-axis .domain,
.fdcc-chart-container .x-axis .domain{
    opacity: 0;
}

/**
 * Embed button styling.
 **/

.fdcc-chart-embed {
    position: absolute;
    bottom: -10px;
    right: 40px; /* Position to the left of download button */
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.fdcc-chart-embed:hover {
    background-color: #f8f8f8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.fdcc-chart-embed svg {
    width: 16px;
    height: 16px;
}

/**
 * Embed modal styling.
 **/

.fdcc-embed-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fdcc-embed-modal.active {
    opacity: 1;
    visibility: visible;
}

.fdcc-embed-modal-content {
    background-color: #fff;
    border-radius: 4px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.fdcc-embed-modal.active .fdcc-embed-modal-content {
    transform: translateY(0);
}

.fdcc-embed-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fdcc-embed-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.fdcc-embed-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--neutral-grey);
}

.fdcc-embed-modal-body {
    padding: 20px;
}

.fdcc-embed-code {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid var(--neutral-secondary);
    border-radius: 4px;
    font-family: monospace;
}

.fdcc-embed-actions {
    display: flex;
    align-items: center;
    margin-top: 15px;
}

.fdcc-copy-embed-code {
    background-color: var(--primary, #005756);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.fdcc-embed-copy-success {
    color: #4CAF50;
    margin-left: 10px;
    font-weight: 500;
}

/* Loading overlay for charts */

.fdcc-chart-loading-overlay {
  position: absolute;
  top: -15px;
  left: -15px;
  right: -15px;
  bottom: -15px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.fdcc-chart-loading-overlay.fade-out {
  opacity: 0;
}

.fdcc-chart-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 87, 86, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}