:root {
    --green: #00751F;
    --white: #FFF;
    --gray: #f9f9f9;
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    font-size: 1rem;
}

header h1 {
    margin: 0;
    text-align: center;
    background: var(--green);
    color: var(--white);
}

#pageContent {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 10px 60px;
}

.panel-left,
.panel-right {
    width: 100%;
}

/* Infos */
#infos {
    /* display: none; */
    width: 100%;
    margin: 0 auto 10px;
    padding: 10px;
    font-size: 0.9rem;
    border: 1px solid var(--green);
    border-radius: 6px;
    background: var(--gray);
    transition: opacity 0.3s ease-in-out;
}

/* Liste descriptive */
#infos .infos-list {
    margin: 0;
    padding: 0;
}

#infos .info-row {
    display: flex;
    align-items: flex-start;
}

#infos dt {
    flex: 0 0 80px;
    font-weight: 600;
    color: var(--green);
}

#infos dd {
    flex: 1;
    margin: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

#infos .adresse dd {
    line-height: 1.4;
}

/* Buttons */
#buttons-1 button,
#buttons-2 button,
.coords-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    gap: 6px;

    font-size: 1rem;
    line-height: 1.2;
    border-radius: 6px;
    cursor: pointer;
}

#buttons-2 {
    display: none;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    position: relative;
    top: -1px;
}

/* Couleurs par action */
.btn-locate .icon {
    fill: #00751F;
}

/* vert */
.btn-save .icon {
    fill: #1565c0;
}

/* bleu */
.btn-map .icon {
    fill: #d32f2f;
}

/* rouge */
.btn-refresh.icon {
    fill: #6a1b9a;
}

/* violet */
/* Map */
#map {
    position: relative;
    width: 100%;
    height: 240px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#map.loading {
    background: rgba(0, 0, 0, 0.03);
}

#question {
    font-size: 15em;
    color: var(--green);
}

/* Spinner */
.spinner {
    width: 64px;
    height: 64px;
    border: 6px solid rgba(0, 117, 31, 0.2);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: none;
}

.italic {
    font-style: italic;
}

.gras {
    font-weight: 600;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

aside {
    border: 1px solid var(--green);
    border-radius: 6px;
}

/* Table */
#table-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#tableau {
    width: auto;
    /* 👈 clé */
    min-width: max-content;
    max-width: 900px;
    /* garde la largeur naturelle */
    border-collapse: collapse;
    border: 1px solid var(--green);
    margin-left: 0;
}

#tableau th,
#tableau td {
    padding: 6px 8px;
    font-size: 0.85rem;
    padding-top: 4px;
    padding-bottom: 4px;
    vertical-align: middle;
    border-collapse: collapse;
    border: 1px solid var(--green);
}

#tableau th {
    background: var(--green);
    color: var(--white);
}

#tableau td.adresse {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 320px;
}

#tableau th:not(.adresse),
#tableau td:not(.adresse) {
    white-space: nowrap;
}

#tableau td.date {
    text-align: center;
}

/* #tableau td:nth-child(3),
#tableau td:nth-child(4),
#tableau td:nth-child(5) {
    white-space: nowrap;
} */
#tableau td.coords {
    white-space: nowrap;
}

/* Valeurs lat / lon */
.coords-values {
    display: flex;
    flex-direction: row;
    gap: 4px;
    font-size: 0.8rem;
}

/* Actions */
.coords-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    align-items: center;

}

.coords-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    padding: 0 6px;
    font-size: 0.75rem;
    line-height: 1;
    margin-bottom: 2px;
}

#footer {
    background: var(--green);
    height: 40px;
    width: 100%;
    bottom: 0;
    color: var(--white);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.85rem;
}

/* Boutons compacts */
.pagination button {
    min-width: 28px;
    height: 26px;
    padding: 0 6px;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: 4px;
    margin: 0;
}

.pagination span {
    display: inline-flex;
    align-items: center;
    height: 24px;
    line-height: 1;
    white-space: nowrap;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination .dots {
    padding: 0 4px;
    opacity: 0.6;
    user-select: none;
}

/* Mobile adjustments */
@media (max-width: 575px) {
    #infos {
        font-size: 0.85rem;
    }

    #infos dt {
        flex-basis: 80px;
    }

    /* #tableau td:nth-child(2) {
        max-width: 200px;
    } */
    .pagination .page-num,
    .pagination .first,
    .pagination .last {
        display: none;
    }

    .pagination {
        gap: 4px;
        font-size: 0.75rem;
    }

    .pagination button {
        min-width: 24px;
        height: 24px;
        padding: 0 4px;
        font-size: 0.7rem;
    }
}

/* Tablet 576px+ */
@media (min-width:576px) {
    aside {
        max-width: 100%;
        height: 420px;
        margin: 0 auto;
    }

    #map {
        height: 100%;
    }

    .table-wrapper {
        display: flex;
        justify-content: center;
    }

    #footer {
        position: fixed;
    }

    .pagination {
        justify-content: center;
    }
}

/* Desktop 768px+ */
@media(min-width:768px) {
    #pageContent {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        column-gap: 20px;
        row-gap: 20px;
        width: 90%;
        margin: 0 auto;
    }

    .panel-left {
        grid-column: 1;
        grid-row: 1;
        min-height: 420px;
    }

    .panel-right {
        grid-column: 2;
        grid-row: 1;
    }

    #table-container {
        grid-column: 1/-1;
        grid-row: 2;
    }
}

@media (min-width: 992px) {
    .table-wrapper {
        display: flex;
        justify-content: center;
    }

    #tableau td.adresse {
        max-width: 600px;
        /* 👈 plus d’air */
    }
}

.toast-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.25);
}

.toast-overlay.bottom {
    align-items: flex-end;
    background: transparent;
    pointer-events: none;
}

.toast-box {
    background: #fff;
    padding: 14px 18px;
    border-radius: 10px;
    min-width: 200px;
    max-width: 90vw;
    text-align: center;
    font-size: 0.95rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    border: 2px solid var(--green);
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.2s ease;
    margin-bottom: 60px;
    /* utile pour bottom */
}

.toast-overlay.show .toast-box {
    transform: scale(1);
    opacity: 1;
}

.toast-overlay.success .toast-box {
    border-color: var(--green);
}

.toast-overlay.error .toast-box {
    border-color: #C1272D;
}