:root {
    --primary-color: #547471;
    --secondary-color: #A09D92;
    --primary-color-hover: #90b1ad;
    --secondary-color-hover: #c8c4b7;
    --font-size: 16px;
    --spacing: 10px;
}

h2,
h3 {
    margin: 0;
}

body {
    font-family: Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    color: rgb(114, 114, 114)
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 999;
}

.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background-color: rgba(255, 250, 250, 0.26);
    border-radius: 15px;
    backdrop-filter: blur(5px);
    height: 250px;
    width: 25%;
}

.spinner {
    width: 100px;
}

.text-loader {
    color: white;
    font-size: 25px;
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    position: relative;
    min-width: 260px;
    max-width: 350px;
    padding: 14px 18px;
    border-radius: 10px;
    background: white;
    font-family: Arial, sans-serif;
    font-size: 14px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    animation: toastIn 0.3s ease;
    border-left: 5px solid;
}

.toast.success {
    color: #16a34a;
    border-left-color: #16a34a;
}

.toast.error {
    color: #dc2626;
    border-left-color: #dc2626;
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    animation: progress 5s linear forwards;
    opacity: 0.5;
}

.toast.success .toast-progress {
    background: #16a34a;
}

.toast.error .toast-progress {
    background: #dc2626;
}

@keyframes progress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.history-overlay,
.modification-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

.history-modal,
.modification-modal {
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: fadeIn .2s ease;
}

.history-header,
.modification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 22px;
    border-bottom: 1px solid #f0f0f0;
}

.history-header h3,
.modification-header h3 {
    margin: 0;
    font-size: clamp(14px, 2vw, 20px);
    color: var(--primary-color);
}

.history-close,
.modification-close {
    border: none;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
    color: var(--primary-color);
    transition: .2s;
}

.history-close:hover,
.modification-close:hover {
    color: var(--primary-color-hover);
    transform: scale(1.1);
}

.history-content,
.modification-content {
    padding: 5px 10px 22px;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table thead th {
    text-align: left;
    padding: 14px 10px;
    font-size: clamp(10px, 2vw, 14px);
    color: var(--primary-color);
    font-weight: 600;
}

.history-table tbody tr {
    transition: .2s;
}

.history-table tbody tr:hover {
    background: #fafafa;
}

.history-table tbody td {
    padding: 16px 10px;
    border-bottom: 1px solid #ececec;
    font-size: clamp(10px, 2vw, 14px);
    color: #333;
    vertical-align: top;
}

.history-comment {
    max-width: 300px;
    white-space: pre-wrap;
}

.history-loading,
.history-empty {
    padding: 30px;
    text-align: center;
    color: #777;
}

.history-badge {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: clamp(10px, 2vw, 14px);
    font-weight: 600;
    white-space: nowrap;
}

/* Green */
.badge-validation {
    background: rgba(52, 199, 89, 0.12);
    color: #1f9d55;
}

/* Red */
.badge-refus {
    background: rgba(255, 59, 48, 0.12);
    color: #d92d20;
}

/* Orange / Yellow */
.badge-retour {
    background: rgba(255, 149, 0, 0.14);
    color: #c77700;
}

/* Blue */
.badge-saisie {
    background: rgba(0, 122, 255, 0.12);
    color: #0066d6;
}

/* Fallback */
.badge-default {
    background: #f2f2f2;
    color: #666;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(.97);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================ Login ============================ */
.login-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    font-size: 30px;
    color: #93938b;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    font-weight: 500;
    width: 340px;
    position: relative;
}

.login-header::after {
    position: absolute;
    top: 105px;
    right: -10px;
    content: "";
    border-right: 4px solid #93938b;
    height: 600px;
}

.users-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-body {
    font-family: Arial, sans-serif;
    background-color: var(--primary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    height: 100vh;
    margin: 0;
    gap: 30px;

}

.login-container {
    background-color: #ffffffab;
    backdrop-filter: blur(5px);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 300px;
}

.login-container h2 {
    color: #333;
    margin: 20px 0;
    text-align: center;
}

.login-input {

    padding: 10px;

    border: 1px solid #ccc;
    border-radius: 4px;
    border-bottom: 1px solid;
}

.login-input:focus {
    outline: none;
    border-bottom: 1px solid rgb(29, 26, 15) !important;
}

.login-submit {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.login-submit:hover {
    background-color: var(--primary-color-hover);
    /* Darker yellow on hover */
}

.footer {
    text-align: center;
    font-size: 0.8em;
    color: #666;
    margin-top: 20px;
}

.login-err {
    margin-top: 20px;
    padding-left: 30px;
    color: rgb(243, 103, 103);
    font-style: italic;
}

/* ============================ Commercial saisie ============================ */
.page-title {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: bold;
    margin: 0 20px 20px 20px;
    text-decoration: underline;
    text-underline-offset: 10px;
}

header {
    background-color: white;
    color: var(--primary-color);
    text-align: center;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;


}

header h1 {
    font-size: clamp(14px, 2vw, 20px);
}

.header-logo {
    height: clamp(40px, 10vw, 80px);

}

.settings-username {
    margin: 0 20px;
    color: var(--primary-color);
    font-size: clamp(12px, 2vw, 20px);
}

.deco-btn {
    background-color: var(--secondary-color);
    font-size: clamp(10px, 2vw, 18px);
    border: none;
    cursor: pointer;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;

}

nav {
    display: flex;
    background-color: var(--primary-color);
    overflow: auto;
    font-size: 18px;
    height: 50px;
}

.actif {
    background-color: var(--secondary-color);
    color: white;
}

nav a:hover:not(.actif) {
    background-color: var(--secondary-color);
    color: white;
}

nav a {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: clamp(14px, 2vw, 18px);
}


.page-suivi,
.page-validation {
    display: none;
}

main {
    background-color: rgb(241, 241, 241);
    min-height: calc(100vh - 170px);
    padding: 20px 0;
}

section {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 20px 10px;
    margin: 0 20px 20px 20px;
}

.item-box {
    display: flex;
    gap: 20px;
    justify-content: flex-start;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    width: 250px;
    height: auto;
    padding: 0;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    background-color: white;
    ;
}

fieldset legend {
    font-size: clamp(12px, 2vw, 16px);
    margin: 0 auto;
    color: #5f5f5f;
}

fieldset input {
    background-color: transparent;
    border: none;
    width: 100%;
    height: 28px;
    appearance: none;
    text-align: center;
    font-size: clamp(12px, 2vw, 16px);
    cursor: pointer;
}

fieldset select {
    background-color: transparent;
    border: none;
    width: 100%;
    height: 28px;
    appearance: none;
    text-align: center;
    font-size: clamp(12px, 2vw, 16px);
    cursor: pointer;
}

fieldset textarea {
    background-color: transparent;
    border: none;
    width: 100%;
    height: 100%;
    appearance: none;
    text-align: center;
    font-size: clamp(12px, 2vw, 16px);
    cursor: pointer;
}

.small-item-box {
    width: 150px;
}

.big-item-box {
    width: 100%;
}

fieldset input:focus,
fieldset textarea:focus {
    outline: none;
    border: none;
}

.inputs-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    /* justify-content: center; */
    margin: 20px 0;
}

.separator {
    margin: 10px 0;
    width: 100%;
    border-bottom: 1px solid rgb(162, 162, 162);
}

section h2 {
    font-size: clamp(16px, 2vw, 20px);
}

section h3 {
    font-size: clamp(14px, 2vw, 18px);
}

/* ============================ Stepper ============================ */
.stepper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 70%;
    position: relative;
}

.step {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    /* align-items: center; */
}

/* LINE BETWEEN STEPS */
.step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 18px;
    /* left: 50%; */
    width: 100%;
    height: 4px;
    background: #d6d6d6;
    z-index: 1;
}

/* DONE LINE */
.step.done:not(:last-child)::after {
    background: var(--primary-color-hover);
}

.circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: white;
    border: 4px solid #d6d6d6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
    position: relative;
    transition: 0.3s;
    font-size: clamp(12px, 2vw, 16px);
}

/* DONE */
.step.done .circle {
    background: var(--primary-color);
    border-color: var(--primary-color-hover);
    color: white;
}

/* CURRENT */
.step.current .circle {
    background: var(--secondary-color);
    border-color: var(--secondary-color-hover);
    color: white;
}

.label {
    margin-top: 12px;
    /* text-align: center; */
    font-size: clamp(12px, 2vw, 16px);
    color: #666;
    /* max-width: 120px; */
}

/* REJECTED */
.step.rejected .circle {
    background: #e65353;
    border-color: #f19292;
    color: white;
}

.step.rejected .label {
    color: #e65353;
    font-weight: bold;
}

.step.current .label {
    color: #111;
    font-weight: bold;
}

.step.done .label {
    color: var(--primary-color);
}

.btn {
    font-weight: 700;
    border: none;
    border-radius: 0.2rem;
    color: white;
    padding: 0.6rem 1rem;
    margin-bottom: 0.3rem;
    cursor: pointer;
    background-color: var(--primary-color);
    text-align: center;
}

.btn:hover {
    background-color: var(--primary-color-hover);
}

.btn-secondary {
    font-weight: 700;
    border: none;
    border-radius: 0.2rem;
    color: white;
    padding: 0.6rem 1rem;
    margin-bottom: 0.3rem;
    cursor: pointer;
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: var(--secondary-color-hover);
}

.btn-third {
    font-weight: 700;
    border: 2px solid var(--primary-color);
    border-radius: 0.2rem;
    color: var(--primary-color);
    padding: 0.6rem 1rem;
    margin-bottom: 0.3rem;
    cursor: pointer;
    background-color: white;
}

.btn-third:hover {
    border-color: var(--primary-color-hover);
    color: var(--primary-color-hover);
}

.input-error {
    border: 2px solid rgb(230, 83, 83);
}

fieldset legend.err {

    color: rgb(230, 83, 83);
}

/* ============================ Suivi demande ============================ */
.search-container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 20px 10px;
    margin: 0 20px 20px 20px;
    display: flex;
    justify-content: center;
}

.validee {
    border-left: 10px solid rgb(48, 197, 48);
}

.encours {
    border-left: 10px solid rgb(40, 109, 221);

}

.retournee {
    border-left: 10px solid rgb(221, 170, 40);

}

.refusee {
    border-left: 10px solid rgb(221, 40, 40);

}

.search-box {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.list-search {
    width: 100%;
    height: 40px;
    border-radius: 20px;
    padding-left: 20px;
    font-size: 17px;
    border: none;
    background-color: rgb(240, 240, 240);
    outline: 1px solid var(--primary-color);
}

/* common icon style */
.search-icon,
.clear-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    cursor: pointer;
    opacity: 0.6;
    transition: 0.2s;
}

.search-icon {
    right: 10px;
}

.clear-icon {
    right: 10px;
    display: none;
}

.search-icon:hover,
.clear-icon:hover {
    opacity: 1;
}



.demande {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.demande-text {
    color: var(--primary-color);
    font-size: clamp(12px, 2vw, 16px);
}

.demande-text span {
    font-weight: bold;
    color: rgb(111, 111, 111);
}

.demande-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 200px;
    font-size: clamp(12px, 2vw, 16px);
}

.demande-section {
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.demande-header {
    cursor: pointer;
    position: relative;
}

.arrow {
    position: absolute;
    top: -10px;
    transition: transform 0.3s ease;
    font-size: 16px;
    user-select: none;
    color: var(--primary-color);
}

.historique {
    position: absolute;
    top: -10px;
    right: -2px;
    transition: transform 0.3s ease;
    user-select: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

.historique:hover {
    transform: scale(1.1);

}

.demande-section.open .arrow {
    transform: rotate(90deg);
}

.detail-demande {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    padding: 0 12px;
}

.details-demande {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.demande-section.open .detail-demande {
    max-height: 2000px;
    /* big enough for content */
    padding: 12px;
}

/* ============================ Validation demande ============================ */
.actions {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.validation_comment {
    text-align: left;
    padding-left: 10px;
}
.dg-comm-container{
    display: flex;
}

/* ============================Responsive ============================ */
@media screen and (max-width: 600px) {
    .loader-container {
        width: 70%;
    }

    nav {
        display: flex;
        justify-content: center;
    }

    .label {
        text-align: center;
    }

    .circle {
        width: 25px;
        height: 25px;
    }

    section {
        margin: 10px;
    }

    .item-box {
        width: 100%;
    }

    .stepper {
        width: 100%;
    }

    .demande {
        flex-direction: column;
        gap: 20px;
    }

    .demande-info {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        margin: 10px
    }

    .step {
        align-items: center;
    }

    .step:not(:last-child)::after {
        left: 50%;
        top: 15px;
    }

    .history-table thead th {
        padding: 14px 5px;
    }

    .history-table tbody td {
        padding: 16px 5px;
    }

    .historique {
        height: 20px;
        width: 20px;
    }
    .dg-comm-container{
        flex-direction: column;
    }

}