/* CSS Variables */
:root {
    --primary-color: #0771B1;
    --secondary-color: #064479;
    --accent-color: #F4F4F4;
    --gray-light: #F8F9FA;
    --white: #FFFFFF;
    --background-color: #FFFFFF;
    --text-color: #3b3b3b;
    --font-family: 'Montserrat';
    --transition-duration: 0.3s;
    --header-height: 134px;
    --header-mobile-height: 100px;
    --header-sm-height: 80px;
    --title-section-height: 72px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--background-color);
}

/* Container principal */
.app-container {
    width: 100%;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Content container */
#content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    margin-top: calc(var(--header-height) + var(--title-section-height));
    position: relative;
    z-index: 1;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
}

#primaryContentContainer {
    width: 100%;
    min-width: fit-content;
    background: var(--background-color);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#primaryContent {
    width: 100%;
    padding: 20px;
    min-width: fit-content; /* Match container's min-width */
}

/* Footer Elements */
.footer-bar {
    width: 100%;
    min-height: 149px;
    background: var(--secondary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-top: auto;
    padding: 20px;
}

.footer-text {
    color: var(--background-color);
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
    max-width: 80%;
    margin: 0 auto;
    padding: 0 20px;
    z-index: 1;
}

.footer-image {
    position: absolute;
    right: 0;
    top: 0;
    width: 151px;
    height: 149px;
    object-fit: contain;
    z-index: 0;
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--accent-color);
    padding: 8px;
    cursor: pointer;
}

/* Content sections */
.content-section {
    margin-bottom: 2rem;
    width: 100%;
}

/* Chart container */
.chart-container {
    width: 100%;
    margin-bottom: 2rem;
    overflow-x: auto;
}

/* Table styles */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Title styles */
.content-section h2 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Clean any old styles that might interfere */
table {
    width: 100%;
    margin-bottom: 1rem;
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
    #content {
        margin-top: calc(120px + 72px + 20px);
        padding: 10px;
    }
}

/* Style the fieldset and legend for clarity */
fieldset {
    border: 1px solid #ccc;
    /* Optional: adds a border to the fieldset */
    padding: 10px;
    margin-bottom: 15px;
}

legend {
    font-weight: bold;
}

/* Ensure label and input are aligned horizontally */
fieldset label {
    display: flex;
    /* Align elements in a row */
    align-items: center;
    /* Vertically align text and radio button */
    justify-content: space-between;
    /* Push input to the left and label text to the right */
    gap: 10px;
    /* Space between radio and text */
    margin-bottom: 10px;
    /* Space between rows */
}

/* Adjust radio button appearance */
fieldset input[type="radio"] {
    margin: 0;
    /* Removes default spacing */
    width: 14px;
    /* Adjusts size for consistency */
    height: 14px;
    cursor: pointer;
    /* Pointer for better UX */
}

/* Utilities */
.clear {
    clear: both;
}

/*Overwrites*/

.ui-widget-header {
    border: none !important;
    background: none !important;
}

.ui-state-default.ui-corner-top.ui-tabs-selected.ui-state-active,
.ui-widget-content .ui-tabs-selected {
    border: none !important;
    background: var(--secondary-color) !important;
}

.ui-state-default.ui-corner-top.ui-tabs-selected.ui-state-active a,
.ui-widget-content .ui-tabs-selected a {
    color: var(--white) !important;
    text-decoration: none;
}

/* Default State Styles */
.ui-widget-content .ui-state-default,
.ui-widget-content .ui-state-hover {
    border: none !important;
    background: var(--white) !important;
}

.ui-widget-content .ui-state-default a {
    color: var(--primary-color) !important;
    text-decoration: none;
}

.ui-widget-content .ui-state-hover {
    background: var(--secondary-color) !important;
}

.ui-widget-content .ui-state-hover a {
    color: var(--white) !important;
    text-decoration: none;
}

.row {
    display: flex;
    /* Enables the flexbox layout */
    flex-direction: row;
    /* Aligns items in a row */
    gap: 10px;
    /* Optional: adds spacing between items */
    align-items: center;
    /* Aligns items vertically in the row */
}

form li {
    list-style-type: none;
    /* Removes the bullet points */
    margin: 0;
    /* Optional: Removes any extra margin */
    padding: 0;
    /* Optional: Removes any extra padding */
}

/* Utility Classes */
.scroll-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.no-wrap {
    white-space: nowrap;
}

/* Overwrites for jQuery UI elements */
.ui-widget-header {
    border: none !important;
    background: none !important;
}


@media screen and (max-width: 768px) {
    body {
        overflow-x: auto;
        /* Enable horizontal scroll for entire body on mobile */
    }

    #content {
        margin-top: calc(var(--header-mobile-height) + var(--title-section-height) + 20px);
        padding: 10px;
        overflow-x: auto;
        /* Enable horizontal scroll */
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    #primaryContentContainer {
        width: max-content;
        min-width: 100%;
    }

    #primaryContent {
        width: max-content;
        min-width: 100%;
    }

    /* Ensure tables don't break layout */
    table {
        width: max-content;
        min-width: 100%;
    }

    /* Handle horizontal scroll for form elements */
    fieldset {
        width: max-content;
        min-width: 100%;
    }

    .footer-bar {
        min-height: 120px;
        padding: 15px;
    }

    .footer-text {
        font-size: 14px;
        max-width: 90%;
        padding: 0 60px;
    }

    .footer-image {
        width: 120px;
        height: 120px;
        opacity: 0.3;
        /* Hace la imagen más sutil en mobile */
    }
}

@media screen and (max-width: 480px) {

    :root {
        --header-height: var(--header-sm-height);
    }

    #content {
        margin-top: calc(var(--header-sm-height) + var(--title-section-height) + 20px);
        padding: 8px;
    }

    .footer-text {
        font-size: 13px;
        max-width: 100%;
        padding: 0 40px;
    }

    .logo {
        width: 120px;
    }

    .footer-bar {
        min-height: 100px;
        padding: 10px;
    }


    .footer-image {
        width: 100px;
        height: 100px;
    }
}

@media screen and (max-width: 360px) {
    .footer-bar {
        min-height: 90px;
    }

    .footer-text {
        font-size: 12px;
        padding: 0 30px;
    }

    .footer-image {
        width: 90px;
        height: 90px;
    }
}

/* ====== layout.css tablet additions ====== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    #content {
        padding: 15px;
        margin-top: calc(var(--header-height) + var(--title-section-height) + 10px);
    }

    #primaryContentContainer {
        width: 100%;
        min-width: 750px;
    }

    .footer-bar {
        min-height: 130px;
    }

    .footer-text {
        max-width: 85%;
        font-size: 15px;
    }

    .footer-image {
        width: 130px;
        height: 130px;
    }

    /* Improve form layouts for tablets */
    fieldset {
        padding: 15px;
    }

    .row {
        flex-wrap: wrap;
        gap: 15px;
    }
}

/* Desktop header fixes for 1920x1080 and similar resolutions */
@media screen and (min-width: 1367px) {
    #content {
        margin-top: calc(var(--header-height) + var(--title-section-height));
        padding: 20px;
        position: relative;
        z-index: 1;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .header-page-title-section,
    .header-page-title-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .header-container {
        max-width: 100%;
        width: 100%;
    }
    
    /* Ensure charts and tables don't overflow */
    .chart-container,
    table {
        max-width: 100%;
        overflow-x: auto;
    }

    .scroll-container {
        overflow-x: auto;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .chart-container,
    .table-responsive {
        max-width: 100%;
        margin: 0 auto;
    }
}