html {
    height: 100%; /* Ensures the html element takes up the full viewport height */
    overflow: hidden; /* Prevents any scrolling on the root element */
}

body {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    height: 100%; /* Ensures the body takes up the full height of the html element */
    /* min-height: 100vh; is no longer strictly necessary when height: 100% is on html/body */
    background-color: #2c3e50;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #ecf0f1;
    overflow: hidden; /* This is the key change: hides both horizontal and vertical scrollbars */
    position: relative;
    /* Removed padding-bottom: 5px; as it could introduce unwanted scroll space */
}

/* --- Search Bar Container (always visible) --- */
#search-bar-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    gap: 8px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s ease, padding 0.3s ease;
}

/* --- Search Input (Always visible by default) --- */
#search-input {
    min-width: 0;
    border: 2px solid transparent;
    color: #ecf0f1;
    font-size: 1.1em;
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
    box-sizing: border-box;

    max-width: 220px;
    padding: 10px 15px;
    opacity: 1;
    pointer-events: auto;
    transition: max-width 0.4s ease-out, padding 0.4s ease-out, opacity 0.3s ease-out 0.1s;
}

#search-input::placeholder {
    color: rgba(236, 240, 241, 0.6);
}

#search-input:focus {
    border-color: #3498db;
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Autocomplete Suggestions (Hidden by default, using max-height/opacity for collapse animation) --- */
.autocomplete-suggestions {
    border: 1px solid #ccc;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    position: absolute;
    background-color: #333;
    color: #eee;
    z-index: 100;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    top: calc(100% + 8px);
    left: 10px;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out 0.1s, padding 0.4s ease-out;
    display: none;
}

/* Styles for when the autocomplete suggestions are visible */
.autocomplete-suggestions.is-visible {
    max-height: 200px;
    padding: 8px 15px;
    opacity: 1;
    pointer-events: auto;
    display: block;
}

.autocomplete-suggestion-item.selected-suggestion {
    background-color: #3f51b5;
    color: white;
}

.autocomplete-suggestion-item {
    padding: 8px 15px;
    cursor: pointer;
}

.autocomplete-suggestion-item:hover {
    background-color: #555;
}

/* --- Main Content Wrapper --- */
#main-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
    gap: 10px;
    /* Removed margin-top from here, as it's now controlled by the overall flex distribution */
}

/* --- City Name --- */
#ville {
    font-size: 2.2em;
    font-weight: bold;
    text-shadow: 1.5px 1.5px 4.5px rgba(0,0,0,0.5);
    z-index: 20;
    text-align: center;
    width: 80%;
    min-width: 250px;
    margin: 0;
}

/* --- Digital Time Display --- */
#heure {
    font-size: 2.2em;
    font-weight: bold;
    text-shadow: 1.5px 1.5px 4.5px rgba(0,0,0,0.5);
    z-index: 20;
    margin: 0;
}

/* --- Clock Container (MAIN SCALING ELEMENT) --- */
#horloge {
    position: relative;
    width: 450px;
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    display: none; /* Hidden by default, shown on city search by JS */

    transform: scale(var(--clock-scale, 1));
    transform-origin: center center;

    --clock-scale: 1; /* Default scale for larger screens */
    margin: 0;
}

#horlogeBG {
    width: 300px;
    height: 300px;
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: relative;
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 45px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* --- Hour Marks (Numbers and Lines) --- */
.hour-mark-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: 0 0;
    transform: rotate(var(--rotation));
    z-index: 6;
}

.hour-number, .hour-line {
    position: absolute;
    left: 0;
}

.hour-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #ecf0f1;
    top: -155px;
    transform: translateX(-50%) rotate(calc(-1 * var(--rotation)));
}

.hour-line {
    width: 3px;
    height: 10px;
    background-color: #ecf0f1;
    border-radius: 2px;
    top: -140px;
    transform: translateX(-50%);
}

/* --- Clock Hands (Aiguilles) --- */
#centre {
    width: 15px;
    height: 15px;
    background-color: #34495e;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.aiguille {
    position: absolute;
    background-color: #ecf0f1;
    top: 50%;
    left: 50%;
    transform-origin: 50% 100%;
    border-radius: 3px;
}

#aigHr {
    width: 7px;
    height: 25%;
    background-color: #f39c12;
    z-index: 7;
    border: 1px solid rgb(205, 130, 0);
}

#aigMin {
    width: 6px;
    height: 35%;
    background-color: #6f7477;
    z-index: 8;
    border: 1px solid black;
}

#aigSec {
    width: 3px;
    height: 40%;
    background-color: #e74c3c;
    z-index: 9;
    border: 1px solid darkred;
}

/* --- Sun and Moon --- */
#sun, #moon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    z-index: 5;
    animation: none;
    transition: transform 0.1s linear;
}

#sun {
    background: radial-gradient(circle at 60% 60%, #ffe066, #ffc107);
    box-shadow: 0 0 22px 7px rgba(255, 193, 7, 0.7);
}

#moon {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #ecf0f1, #bdc3c7);
    box-shadow: inset -7px -7px 15px rgba(0,0,0,0.3);
}

/* --- Digital Time Display --- */
#heure {
    font-size: 2.2em;
    font-weight: bold;
    text-shadow: 1.5px 1.5px 4.5px rgba(0,0,0,0.5);
    z-index: 20;
}

/* --- Responsive Scaling for the Clock (General Media Queries) --- */
@media (max-height: 700px) {
    #horloge {
        --clock-scale: 0.8;
    }
}

@media (max-height: 600px) {
    #horloge {
        --clock-scale: 0.7;
    }
}

@media (max-height: 500px) {
    #horloge {
        --clock-scale: 0.6;
    }
}

@media (max-width: 550px) {
    #horloge {
        --clock-scale: 0.7;
    }
}

@media (max-width: 550px) and (max-height: 700px) {
    #horloge {
        --clock-scale: 0.6;
    }
}

@media (max-width: 480px) or (max-height: 550px) {
    #horloge {
        --clock-scale: 0.5;
    }
    #ville {
        font-size: 1.8em;
    }
    #heure {
        font-size: 1.8em;
    }
}

@media (min-width: 1000px) and (min-height: 750px) {
    #horloge {
        --clock-scale: 1;
    }
}

/* ###################################################################### */
/* -------------------------------- Ecran -------------------------------- */
/* ###################################################################### */
@media (min-width: 1601px) {

    /* --- Main Content Wrapper Adjustments for Larger Screens --- */
    #main-content-wrapper {
        margin-top: 5%; /* Keep this if you want a top margin on very large screens */
    }

    footer {
        padding: 20px;
    }

}


/* ###################################################################### */
/* ------------------------------ Portables ------------------------------ */
/* ###################################################################### */
@media (min-width: 601px) and (max-width: 1600px) {

    /* --- Main Content Wrapper Adjustments for Smaller Screens --- */
    #main-content-wrapper {
        padding-top: 0px;
        padding-bottom: 25px;
    }

    /* --- Clock Scale Adjustment for "Portables" --- */
    #horloge {
        --clock-scale: 0.7;
        margin-top: 0px;
        margin-bottom: 0px;
    }

    /* --- Adjustments for City Name on Portables --- */
    #ville {
        font-size: 2em;
        margin-top: 0px;
        margin-bottom: 0px;
    }

    /* --- Adjustments for Digital Time Display on Portables --- */
    #heure {
        font-size: 2em;
        margin-top: 0px;
        margin-bottom: 0px;
    }

    /* Adjust search bar container position for smaller screens */
    #search-bar-container {
        top: 15px;
        left: 15px;
    }

    /* For smaller screens, ensure search input is always visible with appropriate width */
    #search-input {
        max-width: 200px;
        font-size: 1em;
    }

    footer {
        padding-bottom: 50px;
    }
}

/* ###################################################################### */
/* -------------------------------- Cell -------------------------------- */
/* ###################################################################### */
@media (max-width: 600px) {
    #main-content-wrapper {
        margin-top: 0%;
        padding-top: 15px;
        padding-bottom: 20px;
        justify-content: center;
        min-height: auto;
    }

    #horloge {
        --clock-scale: 0.6;
        margin-top: 15px;
        margin-bottom: 15px;
        width: 300px;
        height: 300px;
    }

    #ville {
        font-size: 1.8em;
        margin-top: 8px;
        margin-bottom: 8px;
        width: 90%;
        min-width: unset;
    }

    #heure {
        font-size: 1.8em;
        margin-top: 8px;
        margin-bottom: 8px;
    }

    #search-bar-container {
        position: static;
        width: 90%;
        margin: 10px auto;
        flex-direction: column;
        align-items: center;
        left: auto;
        top: auto;
        gap: 5px;
    }

    #search-input {
        width: 100%;
        max-width: 250px;
        font-size: 1em;
        padding: 8px 10px;
    }

    .autocomplete-suggestions {
        position: static;
        width: 100%;
        left: auto;
        top: auto;
        border-radius: 5px;
        border-top: 1px solid #ccc;
        margin-top: 5px;
    }

    .autocomplete-suggestion-item {
        padding: 6px 10px;
        font-size: 0.9em;
    }

    footer {
        padding: 10px;
        font-size: 0.75em;
    }
}

/* --- FOOTER STYLES --- */
footer {
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
    color: #696e74;
    text-align: center;
    font-size: 0.9em;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 50;
    margin-top: auto;
}

footer p {
    margin: 0;
    line-height: 1.5;
}

footer a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #ffffff;
}