/* GENERAL STYLES - Form Container */
.devis-form-container {
    max-width: 900px; /* Increased max-width for more spacious layout */
    margin: 40px auto;
    padding: 35px; /* Increased padding */
    background: #ffffff; /* Clean white background */
    border-radius: 15px; /* More rounded corners */
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); /* Softer, larger shadow */
    font-family: 'Segoe UI', 'Roboto', Arial, sans-serif; /* Modern, readable font stack */
    color: #34495e; /* Darker, sophisticated text color */
    line-height: 1.6;
}

.devis-form-container h2 {
    text-align: center;
    color: #2c3e50; /* Darker blue for headings */
    margin-bottom: 25px;
    font-size: 2.8em; /* Larger main title */
    font-weight: 700;
    letter-spacing: -0.02em; /* Slightly tighter letter spacing */
}

.devis-form-container .form-description {
    text-align: center;
    color: #7f8c8d; /* Muted grey for description */
    margin-bottom: 40px;
    font-size: 1.15em;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* FORM SECTIONS (FIELDSETS) */
.form-section {
    border: 1px solid #e0e0e0; /* Lighter border */
    border-radius: 10px; /* Slightly rounded */
    padding: 25px 30px; /* More padding inside sections */
    margin-bottom: 35px; /* More space between sections */
    background-color: #fcfcfc; /* Very light off-white for sections */
    transition: box-shadow 0.3s ease; /* Smooth transition for hover effect */
}

.form-section:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.08); /* Subtle shadow on hover */
}

.form-section legend {
    font-size: 1.6em; /* Larger legend font */
    font-weight: 600;
    color: #3498db; /* Bright blue for legends */
    padding: 0 15px; /* Padding for the legend */
    margin-bottom: 20px;
    background: #ffffff; /* Match form container background */
    border-radius: 8px;
    display: inline-block; /* Allows padding and margin to apply better */
    transform: translateY(-50%); /* Move legend slightly up */
    margin-left: 15px;
}

/* FLEXIBLE GROUP LAYOUT */
.flex-group {
    display: flex;
    flex-wrap: wrap;
    gap: 25px; /* More space between fields */
    margin-bottom: 20px;
}

.flex-group > div {
    flex: 1;
    min-width: 280px; /* Increased min-width for larger fields */
    position: relative; /* For error message positioning */
}

/* LABELS AND INPUTS */
label {
    display: block;
    margin-bottom: 10px; /* More space between label and input */
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select {
    width: 100%;
    padding: 14px 18px; /* More padding for inputs */
    border: 1px solid #dcdcdc; /* Lighter border color */
    border-radius: 8px; /* More rounded input fields */
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fefefe; /* Slightly off-white input background */
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: #3498db; /* Focus color */
    box-shadow: 0 0 12px rgba(52,152,219,0.3); /* Enhanced shadow on focus */
    outline: none;
}

/* DYNAMIC COLIS DETAILS */
.colis-item-dynamic {
    border-top: 1px solid #f0f0f0; /* Lighter separator */
    padding-top: 25px;
    margin-top: 25px;
    position: relative;
    padding-left: 20px;
}
.colis-item-dynamic:first-of-type {
    border-top: none; /* No top border for the first dynamic item */
    padding-top: 0;
    margin-top: 0;
    padding-left: 0;
}


.colis-item-dynamic h3 {
    font-size: 1.4em;
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db; /* Underline for colis title */
    padding-bottom: 5px;
    display: inline-block; /* Shrink underline to content width */
}

/* "ADD COLIS" BUTTON */
#add-colis-btn {
    background-color: #2ecc71; /* Green for add action */
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05em;
    margin-top: 25px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    font-weight: 600;
}

#add-colis-btn:hover {
    background-color: #27ae60;
    transform: translateY(-2px);
}

/* DELIVERY OPTIONS (CHECKBOXES) */
.delivery-options {
    display: flex;
    flex-direction: column;
    gap: 15px; /* More space between checkboxes */
    margin-top: 20px;
}

.delivery-options div {
    display: flex;
    align-items: center;
    background-color: #f9f9f9; /* Light background for each option */
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid #eee;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.delivery-options div:hover {
    background-color: #eaf6fd; /* Light blue on hover */
    border-color: #cce9ff;
}

.delivery-options input[type="checkbox"] {
    width: auto;
    margin-right: 12px; /* More space */
    transform: scale(1.3); /* Slightly larger checkboxes */
    accent-color: #3498db; /* Highlight color for checked state */
}

.delivery-options label {
    margin-bottom: 0;
    font-weight: normal;
    color: #333;
    cursor: pointer;
    font-size: 1.05em;
}

/* SUBMIT BUTTON */
button[type="submit"] {
    display: block;
    width: 100%;
    padding: 18px 25px; /* Larger button */
    background-color: #3498db; /* Primary blue */
    color: white;
    border: none;
    border-radius: 10px; /* More rounded */
    font-size: 1.4em; /* Larger font */
    font-weight: bold;
    cursor: pointer;
    margin-top: 40px; /* More space above button */
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 5px 15px rgba(52,152,219,0.3); /* Subtle shadow for the button */
}

button[type="submit"]:hover {
    background-color: #2980b9; /* Darker blue on hover */
    transform: translateY(-3px); /* Lift effect */
    box-shadow: 0 8px 20px rgba(52,152,219,0.4);
}

button[type="submit"].loading {
    background-color: #95a5a6; /* Grey for loading state */
    cursor: not-allowed;
    opacity: 0.8;
    transform: translateY(0); /* Remove lift effect when loading */
    box-shadow: none;
}

/* ERROR MESSAGES AND FIELDS */
.error-message {
    color: #e74c3c; /* Bright red for errors */
    font-size: 0.88em;
    margin-top: 8px; /* More space */
    display: block;
    font-weight: 500;
}

input.input-error,
select.input-error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 8px rgba(231,76,60,0.4) !important;
}

/* -------------------------------------- */
/* MODAL (POP-UP) STYLES - Enhanced */
/* -------------------------------------- */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7); /* Darker overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px); /* Subtle blur effect for background */
}

.modal-content {
    background-color: #fff;
    padding: 40px; /* More padding */
    border: none;
    width: 90%;
    max-width: 550px; /* Slightly wider modal */
    box-shadow: 0 15px 40px rgba(0,0,0,0.4); /* More prominent shadow */
    animation-name: animatetop;
    animation-duration: 0.6s; /* Slower animation for smoothness */
    border-radius: 18px; /* More rounded corners */
    position: relative;
    text-align: center;
    box-sizing: border-box;
    transform: scale(0.95); /* Initial scale for bounce effect */
    transition: transform 0.2s ease-out;
}

/* Keyframe for modal entry animation */
@keyframes animatetop {
    from {transform: translateY(-100px) scale(0.8); opacity: 0;}
    to {transform: translateY(0) scale(1); opacity: 1;}
}

/* Close button for modal */
.close-button {
    color: #888;
    font-size: 38px; /* Larger close button */
    font-weight: bold;
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    color: #333;
}

.modal-header {
    padding-bottom: 20px;
    margin-bottom: 25px;
    border-bottom: 1px solid #ececec;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50; /* Dark blue for modal title */
    font-size: 2.2em;
    font-weight: 700;
}

.modal-body-content {
    padding: 15px 0;
    font-size: 1.25em; /* Larger and more prominent message */
    line-height: 1.8;
    color: #555;
    margin-bottom: 30px;
}

.modal-body-content.success {
    color: #27ae60; /* Success green */
    font-weight: 600;
}

.modal-body-content.error {
    color: #e74c3c; /* Error red */
    font-weight: 600;
}

.modal-footer {
    padding-top: 20px;
    border-top: 1px solid #ececec;
    text-align: center;
}

#modalCloseButton {
    background-color: #3498db; /* Primary blue for modal button */
    color: white;
    padding: 16px 35px; /* Larger button */
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.15em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 10px rgba(52,152,219,0.2);
}

#modalCloseButton:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52,152,219,0.3);
}

/* RESPONSIVE DESIGN - MEDIA QUERIES */
@media (max-width: 900px) {
    .devis-form-container {
        max-width: 95%;
        margin: 30px auto;
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .devis-form-container h2 {
        font-size: 2.2em;
    }
    .form-section legend {
        font-size: 1.4em;
    }
    .flex-group {
        flex-direction: column;
        gap: 18px;
    }
    .flex-group > div {
        min-width: 100%;
    }
    input[type="text"], input[type="email"], input[type="tel"], input[type="number"], select {
        padding: 12px 15px;
        font-size: 0.95em;
    }
    #add-colis-btn, button[type="submit"] {
        font-size: 1em;
        padding: 14px 20px;
    }
    .modal-content {
        padding: 30px;
        width: 95%;
    }
    .modal-header h2 {
        font-size: 1.8em;
    }
    .modal-body-content {
        font-size: 1.1em;
    }
    #modalCloseButton {
        padding: 12px 25px;
        font-size: 1em;
    }
    .colis-item-dynamic {
        padding-left: 0; /* Remove left padding on small screens */
    }
}

@media (max-width: 480px) {
    .devis-form-container {
        padding: 18px;
        margin: 20px auto;
    }
    .devis-form-container h2 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    .devis-form-container .form-description {
        font-size: 1em;
        margin-bottom: 25px;
    }
    .form-section {
        padding: 15px;
        margin-bottom: 25px;
    }
    .form-section legend {
        font-size: 1.2em;
        padding: 0 10px;
        margin-left: 10px;
    }
    label {
        font-size: 0.9em;
        margin-bottom: 6px;
    }
    input[type="text"], input[type="email"], input[type="tel"], input[type="number"], select {
        padding: 10px 12px;
        font-size: 0.9em;
    }
    .colis-item-dynamic h3 {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    #add-colis-btn, button[type="submit"] {
        padding: 10px 15px;
        font-size: 0.9em;
        margin-top: 25px;
    }
    .delivery-options div {
        padding: 10px 15px;
    }
    .delivery-options input[type="checkbox"] {
        transform: scale(1.1);
    }
    .delivery-options label {
        font-size: 0.95em;
    }
    .modal-content {
        padding: 25px;
    }
    .modal-header h2 {
        font-size: 1.6em;
    }
    .modal-body-content {
        font-size: 1em;
        margin-bottom: 20px;
    }
    #modalCloseButton {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}