/* Base Styles */
* {
    font-family: 'Rubik', Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    color: #fff;
    line-height: 1.6;
    background: url('images/background.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(18, 18, 18, 0.6);
    z-index: -1;
}

label {
    display: block;
    margin-top: 20px;
    margin-bottom: 5px;
    font-weight: bold;
    color: #fff;
    text-align: left;
}

/* Layout - Header */
.app-header {
    background-color: rgba(18, 18, 18);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo img {
    height: 50px;
    max-width: 100%;
    object-fit: contain;
}

.nav-buttons {
    display: flex;
    gap: 16px;
    align-items: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 6px 12px;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    position: relative;
    overflow: hidden;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #ffffff;
    transform: scaleX(0);
    transform-origin: bottom left;
    transition: transform 0.3s ease-out;
}

.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-buttons {
    align-items: stretch;
}

.lang-wrapper {
    position: relative;
}

#languageSelect {
    position: absolute;
    right: 0;
    top: auto;
    bottom: -5px;
    background-color: white;
    color: black;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: clamp(0.8rem, 1vw, 1rem);
    z-index: 100;
}

/* Layout - Main Content */
.container {
    max-width: 1200px;
    margin: 80px auto 40px 60px;
    padding: 20px;
    border-radius: 10px;
    text-align: left;
    display: flex;
    margin-left: 5%;
    margin-top: 10%;
    flex-direction: column;
    align-items: flex-start;
}

.main-text {
    margin-bottom: 12px;
    font-family: 'Rubik', sans-serif;
    font-size: clamp(1rem, 1.4vw + 0.5rem, 1.6rem);
    text-align: left;
    margin-right: 20vh;
    max-width: 80%;
    animation: fadeInOpacity 1.2s ease forwards;
}

.select-group {
    display: flex;
    margin-top: 10px;
    flex-wrap: wrap;
}

.select-group select {
    border: 1px solid #333232;
    background-color: #fff;
    color: #000;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px;
    flex-grow: 1;
    min-width: 150px;
}

#districtSelect {
    border-right: none;
}

#concelhoSelect {
    border-radius: 0;
    border-right: none;
}

#locateMeButton img {
    max-width: 100%;
    height: auto;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
}

.modal {
    display: none;
    position: absolute;
    top: 50%;
    right: 1.25rem;
    transform: translateY(-50%);
    width: min(90vw, 34.375rem);
    height: auto;
    overflow-y: auto;
    padding: 0 1.25rem;
    z-index: 999;
    flex-shrink: 0;
    animation: fadeInOpacity 0.5s ease forwards;
}

.modal-content {
    background: linear-gradient(145deg, #ffffff, #f7f7f7);
    border-radius: 1rem;
    box-shadow:
            0 0.75rem 1.25rem rgba(0, 0, 0, 0.2),
            0 0.5rem 0.625rem rgba(0, 0, 0, 0.1);
    padding: 1.875rem;
    transition: all 0.4s ease;
    position: relative;
    padding-top: 4.5rem;
}

.icon_modal {
    width: 1.25rem;
    height: auto;
    margin-right: 0.3125rem;
}

.close-button, .share-button {
    position: absolute;
    color: #888;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    z-index: 10;
    width: 2.8rem;
    height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.close-button {
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.875rem;
}

.share-button-container {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
}

.share-button {
    background-color: transparent;
    color: #888;
    font-size: 1em;
}

.share-button .share-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: invert(0.5);
    vertical-align: middle;
    transition: filter 0.3s ease;
}

.close-button:hover, .share-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #555;
}

.share-button:hover .share-icon {
    filter: invert(0.3);
}

.modal-content h2 {
    color: #2c3e50;
    font-weight: 600;
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.625rem;
}

.modal-content a{
    color: #555;
}

.modal-content p {
    color: #555;
    line-height: 1.7;
    text-align: center;
    font-size: clamp(1rem, 1.2vw, 1.1rem);
}

.modal-content h3 {
    color: #444;
    font-weight: 500;
}

.symbols-legend {
    color:black;
    text-align: center;
    justify-content: center;
    align-self: center;
}

.indications-list li {
    padding: 0.5rem 0.75rem;
    list-style: none;
    color: black;
    background-color: rgba(239, 239, 239, 0.56);
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.3s;
}

.indications-list li:hover {
    background-color: #e0e0e0;
}

.legend {
    background-color: #f8f8f8;
    border-radius: 0.625rem;
    padding: 0.75rem;
    border: 1px solid #ddd;
}

.legend p {
    color: #555;
}

.legend p .symbol {
    margin-right: 0.5rem;
    font-size: clamp(0.8em, 1vw, 1em);
}

/* Layout - Footer */
.app-footer {
    background-color: rgb(18, 18, 18);
    color: #fff;
    padding: 1.25rem 2.5rem;
    margin-top: 50vh;
    font-family: 'Rubik', sans-serif;
    text-align: center;
    box-shadow: 0 -0.125rem 0.3125rem rgba(0, 0, 0, 0.5);
}

.footer-logos {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 0.9375rem;
    flex-wrap: wrap;
}

.footer-logos > div {
    height: 3.75rem;
    width: 7.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.footer-logos a {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

.footer-logos img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: filter 0.3s ease;
    cursor: pointer;
}

.app-footer hr {
    border: none;
    height: 0.125rem;
    background-color: #ffffff;
    margin: 0.9375rem auto;
    max-width: 48.125rem;
}

.footer-info p {
    margin: 0.5rem 0;
    font-size: clamp(0.8rem, 1vw, 0.9rem);
    max-width: 37.5rem;
    margin-left: auto;
    margin-right: auto;
}

.footer-info a {
    color: #e64;
}

.footer-columns {
    display: flex;
    justify-content: center;
    gap: 3.75rem;
    flex-wrap: wrap;
    margin: 1.875rem 0;
    font-size: clamp(0.85rem, 1.1vw, 0.95rem);
}

.footer-column {
    min-width: 10rem;
    text-align: left;
}

.footer-column h4 {
    font-size: clamp(0.9rem, 1.2vw, 1rem);
    margin-bottom: 0.625rem;
    font-weight: bold;
    color: #fff;
}

.footer-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-column li {
    margin-bottom: 0.5rem;
}

.footer-column a {
    color: #ddd;
    text-decoration: none;
    transition: color 0.3s ease;
}

.app-mobile-footer {
    display: none;
}

/* Layout - Fire Risk Guide Section */
.fire-risk-guide {
    color: #fff;
    padding: 2.5rem;
    max-width: 62.5rem;
    margin: 3.75rem auto;
    border-radius: 0.75rem;
    font-family: 'Rubik', sans-serif;
}

.modal-division {
    width: 100%;
    height: 0.1875rem;
    background-color: #bdbdbd;
    margin-top: 0;
}

.fire-risk-icons {
    display: flex;
    gap: 0.3125rem;
    justify-content: center;
    margin: 0.5rem 0;
}

.fire-risk-icons .fire-icon {
    width: clamp(1rem, 5vw, 4rem);
    height: clamp(1rem, 5vw, 4rem);
    object-fit: contain;
    vertical-align: middle;
    transition: filter 0.2s;
}

.fire-risk-icons .fire-icon:hover {
    filter: brightness(1.2) drop-shadow(0 0 0.25rem orange);
}

.fire-risk-guide h2 {
    font-size: clamp(2rem, 3.5vw, 2.7rem);
    text-align: left;
    margin-bottom: 0;
}

.risk-block {
    margin-bottom: 1.875rem;
}

.risk-block h3 {
    font-size: clamp(1.6rem, 2.5vw, 2rem);
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
}

.risk-block ul {
    padding-left: 1.25rem;
    list-style-type: disc;
}

.risk-block ul ul {
    list-style-type: circle;
    margin-top: 0.375rem;
}

.risk-block li {
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
}

.risk-block p {
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    line-height: 1.6;
    justify-content: center;
}

/* Components */
#districtSelect,
#concelhoSelect,
#locateMeButton,
#buttonResult {
    height: 6.5vh;
    animation: fadeInOpacity 1.2s ease forwards;
    font-family: 'Rubik', sans-serif;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    padding: 10px 14px;
}

#districtSelect,
#concelhoSelect {
    width: 17vw;
    text-align: center;
}

#buttonResult {
    background-color: #1f1e1e;
    color: whitesmoke;
    border: none;
    width: clamp(60px, 6vw, 100px);
    cursor: pointer;
    border-radius: 0 12px 12px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#locateMeButton {
    background-color: #fff;
    color: white;
    border: 1px solid #333232;
    border-right: none;
    width: clamp(40px, 3vw, 70px);
    text-align: center;
    align-items: center;
    cursor: pointer;
    border-radius: 12px 0 0 12px;
    transition: background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Risk Level Colors */
.risk-color {
    display: inline-block;
    width: clamp(1rem, 2vw, 1.25rem);
    height: clamp(1rem, 2vw, 1.25rem);
    border-radius: 50%;
    margin-right: 0.625rem;
    vertical-align: middle;
}

.risk-level-1 {
    background-color: #4CAF50;
}

.risk-level-2 {
    background-color: #FFEB3B;
}

.risk-level-3 {
    background-color: #FF9800;
}

.risk-level-4 {
    background-color: #F44336;
}

.risk-level-5 {
    background-color: #9C27B0;
}

/* Symbol Colors */
.symbol.allowed {
    color: #4CAF50;
}

.symbol.forbidden {
    color: #F44336;
}

.symbol.info {
    color: #2196F3;
}

.footer-icons {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 25rem;
    margin: 0 auto;
    gap: 2.5rem;
}

.footer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    cursor: pointer;
}

.footer-icon img {
    width: 1.875rem;
    height: 1.875rem;
    filter: brightness(0) invert(1);
    transition: opacity 0.3s ease;
}

/* States */
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.lang-btn {
    background: none;
    border: none;
    color: white;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    cursor: pointer;
    padding: 0.375rem;
    transition: background 0.3s;
}

.lang-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.select-group select:focus {
    outline: none;
    box-shadow: none;
    border-color: #333232;
}

#locateMeButton:hover {
    background-color: #cecece;
}

#concelhoSelect:disabled {
    background-color: #e0e0e0;
    color: #7a7a7a;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Hover and focus for close and share buttons */
.close-button:hover,
.share-button:hover {
    color: black;
    text-decoration: none;
}

.footer-logos img:hover {
    filter: brightness(0.8) invert(0.7);
}

.footer-column a:hover {
    color: #e64;
}

.footer-icon:hover img {
    opacity: 0.7;
}

/* Animations */
@keyframes fadeInOpacity {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Language Modal Styles */
.language-modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0); /* Changed to transparent for PC */
    display: flex;
    align-items: center;
    justify-content: center;
}

.language-modal-content {
    background: #fff;
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    border-radius: 1rem;
    max-width: 520px;
    width: 95vw;
    position: relative;
    box-sizing: border-box;
}

.language-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: #222;
    cursor: pointer;
    line-height: 1;
}

.languages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 1.2rem;
    margin-top: 2.5rem;
}

.language-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border-radius: .5rem;
    padding: .7rem .2rem;
    transition: background .15s;
    border: 2px solid transparent;
}

.language-option img {
    width: 38px;
    height: 28px;
    object-fit: contain;
    margin-bottom: 0.45rem;
    border-radius: 3px;
    background: #eee;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.language-option span {
    font-size: .96rem;
    text-align: center;
    color: #222;
}


/* Media Queries */

/* Tablet and smaller screens (up to 900px) */
@media (max-width: 56.25rem) {
    body {
        flex-direction: column;
        background-size: 240%;
    }

    .app-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.75rem 1rem;
    }

    .nav-buttons {
        gap: 0.5rem;
        margin-top: 0;
        display: flex;
    }

    .container {
        margin: 2.5rem auto 1.25rem;
        padding: 1rem;
        align-items: center;
    }

    .main-text {
        margin-right: 0;
        text-align: center;
        max-width: 90%;
    }

    .select-group {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        width: auto;
    }

    .select-group select,
    #locateMeButton,
    #buttonResult {
        width: auto;
        flex-grow: 1;
        margin-bottom: 0;
        max-width: none;
        min-width: unset;
    }

    #districtSelect,
    #concelhoSelect {
        border-right: none;
        border-radius: 0;
        width:100%;
    }

    #locateMeButton {
        display: flex;
        border-radius: 0.75rem 0 0 0.75rem;
    }

    #buttonResult {
        border-radius: 0 0.75rem 0.75rem 0;
    }

    .modal {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        height: auto;
        margin-top: 0;
        margin-bottom: 0;
        padding: 0;
        max-height: 90vh;
        overflow-y: auto;
        right: auto;
    }

    .modal-content {
        position: relative;
        transform: none;
        width: 100%;
        margin-top: 0;
        margin-bottom: 0;
        max-width: none;
        padding: 1.5rem;
        max-height: 80vh;
        overflow-y: auto;
        padding-top: 4rem;
    }

    .share-button-container {
        top: 0.75rem;
        left: 0.75rem;
        padding-left: 0.75rem;
    }

    .legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3125rem;
        font-size: 0.9em;
    }

    .app-footer {
        margin-top: 5rem;
        padding: 1rem 1.5rem;
    }

    .footer-logos>div {
        margin-left: 0;
    }

    .footer-columns {
        justify-content: space-around;
        gap: 1.5rem;
    }

    .footer-column {
        min-width: unset;
        text-align: center;
    }

    .fire-risk-guide {
        max-width: 90%;
        margin: 2rem auto;
        padding: 1rem;
    }

    .fire-risk-icons .fire-icon {
        width: clamp(1rem, 6vw, 3rem);
        height: clamp(1rem, 6vw, 3rem);
    }
}

/* Mobile (up to 600px) */
@media (max-width: 37.5rem) {
    body {
        padding-bottom: 3.75rem;
        background-size: 240%;
    }

    .app-header {
        flex-direction: column;
        align-items: center;
        height: auto;
        padding-bottom: 0.75rem;
    }

    .nav-buttons {
        display: none;
    }

    .lang-wrapper {
        width: 100%;
        text-align: center;
        margin-top: 0.5rem;
    }

    #languageSelect {
        position: absolute;
        bottom: 3.75rem;
        right: 0.625rem;
        background-color: white;
        color: black;
        padding: 0.375rem;
        border-radius: 0.375rem;
        border: 1px solid #ccc;
        font-size: 0.875rem;
        z-index: 2000;
        width: auto;
        top: auto;
        transform: none;
    }

    .container {
        margin-left: 0;
        padding: 0.625rem;
        margin-top: 5vh;
        align-items: flex-start;
    }

    .main-text {
        max-width: 100%;
        text-align: left;
        margin-bottom: 0.75rem;
    }

    .select-group {
        flex-direction: column;
        width: 100%;
    }

    .select-group select,
    #locateMeButton,
    #buttonResult {
        width: 100%;
        border-radius: 0.375rem;
        margin-bottom: 0.625rem;
        font-size: clamp(0.9rem, 3vw, 1.1rem);
        height: 3.125rem;
    }

    #districtSelect,
    #concelhoSelect {
        border-right: 1px solid #ccc;
        border-radius: 0.375rem;
    }

    #locateMeButton {
        display: none;
    }

    #buttonResult {
        border-radius: 0.375rem;
    }

    .legend {
        font-size: 0.8em;
    }

    .app-footer {
        display: none;
    }

    .app-mobile-footer {
        background-color: rgba(18, 18, 18, 1);
        color: white;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0.75rem 1.5rem;
        box-shadow: 0 -0.125rem 0.3125rem rgba(0, 0, 0, 0.4);
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 1001;
        height: 3.75rem;
    }

    .app-mobile-footer .footer-icon {
        padding: 0.375rem;
    }

    .app-mobile-footer .footer-icon img {
        width: 1.5rem;
        height: 1.5rem;
    }

    .lang-btn {
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
    }

    .language-modal {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .language-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        overflow-y: auto;
        padding: 4.5rem 1.5rem 4rem;
        position: absolute;
    }

    .language-modal-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        font-size: 2rem;
        color: #222;
        cursor: pointer;
        line-height: 1;
        z-index: 2010;
    }

    .languages-grid {
        margin-top: 1rem;
    }

    .fire-risk-guide {
        max-width: 95%;
        margin: 0 auto;
        padding: 0.9375rem;
        box-sizing: border-box;
    }

    .risk-block ul {
        padding-left: 1.25rem;
    }

    .risk-block ul ul {
        padding-left: 0.9375rem;
    }

    .risk-block h2 {
        font-size: clamp(1.5rem, 5vw, 1.8rem);
        margin-bottom: 0.625rem;
    }

    .risk-block h3 {
        font-size: clamp(1.3rem, 4vw, 1.6rem);
        margin-bottom: 0.625rem;
        padding-bottom: 0.3125rem;
        border-bottom: 1px solid #eee;
    }

    .risk-block li {
        font-size: clamp(1rem, 3vw, 1.1rem);
        margin-bottom: 0.5rem;
        line-height: 1.5;
    }

    .risk-block p {
        font-size: clamp(1rem, 3vw, 1.1rem);
        line-height: 1.6;
        margin-bottom: 0.625rem;
    }
}


/* Media Query for screens between 601px and 1400px */
@media (min-width: 601px) and (max-width: 1400px) {
    .modal {
        margin-top: 5vh;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: min(95vw, 45rem);
        height: auto;
        max-height: 75vh;
        overflow-y: auto;
        right: auto;
        padding: 0;
    }

    .modal-content {
        width: 100%;
        background-color: maroon;
        padding: 1.5rem;
        box-sizing: border-box;
        max-height: none;
        padding-top: 4rem;
    }

    .share-button-container {
        top: 0.75rem;
        left: 0.75rem;
    }

    .language-modal {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: min(95vw, 35rem);
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
        background: rgba(0, 0, 0, 0); /* Changed to transparent for PC */
    }

    .language-modal-content {
        width: 100%;
        padding: 1.5rem;
        box-sizing: border-box;
        max-height: none;
        border-radius: 1rem;
        overflow-y: hidden;
    }
}