/* Common Styles */
*, *:before, *:after {
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    color: #384047;
    background-image: url('https://designvkp.com/wp-content/uploads/2015/07/pattern.png');
    background-position: 0 0;
    background-repeat: repeat;
    animation: animatedBackground 40s linear infinite;
    opacity: 0.9;
}

@keyframes animatedBackground {
    from { background-position: 0 0; }
    to { background-position: 100% 0; }
}

.container {
    width: 90%;
    max-width: 600px; /* Adjusted for better mobile display */
    margin: 20px auto; /* Added top and bottom margin for spacing */
    padding: 20px;
    background-color: #ffffff; /* White background for the form */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    border-radius: 8px; /* Rounded corners for a modern look */
}

h2, h4 {
    margin: 20px 0;
    font-weight: bold;
    font-size: 1.8em; /* Increased font size for better readability */
    text-align: left;
}

form {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Consistent spacing between form elements */
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 1em;
    margin-bottom: 5px;
}

.form-control, .form-select, textarea {
    font-size: 1em;
    padding: 12px; /* Increased padding for better touch targets */
    background: rgba(255, 255, 255, 0.1);
    border: none;
    outline: 0;
    width: 100%;
    background-color: #e8eeef;
    color: #8a97a0;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03) inset;
    margin-bottom: 30px;
    border-radius: 4px;
}

textarea {
    resize: vertical; /* Allow vertical resizing */
    height: 100px; /* Default height */
}

.input-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
}

.input-group .form-control {
    flex: 1;
    width: 100%;
}

.input-group .form-select {
    width: 100%; /* Fixed width for the unit select */
}

button {
    padding: 14px 20px; /* Increased padding for better touch targets */
    cursor: pointer;
    background-color: #4bc970;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 1.1em; /* Slightly larger font for readability */
    transition: background-color 0.3s ease;
    width: 100%;
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.1) inset;
}

button:hover {
    background-color: #3ac162;
}

fieldset {
    margin-bottom: 30px;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 8px;
}

legend {
    font-size: 1.2em;
    margin-bottom: 10px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.number {
    background-color: #5fcf80;
    color: #fff;
    height: 30px;
    width: 30px;
    display: inline-block;
    font-size: 0.8em;
    margin-right: 10px;
    line-height: 30px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

/* Readonly Input Styling */
.form-control[readonly] {
    background-color: #e9ecef;
}

/* Error Styling */
.is-invalid {
    border-color: #dc3545;
    background-color: #f8d7da;
    color: #721c24; /* Text color for better contrast */
}

/* Text Alignment Based on Language */
.ltr {
    direction: ltr;
}

.ltr h2, .ltr h4 {
    text-align: left;
}

.rtl {
    direction: rtl;
}

.rtl h2, .rtl h4 {
    text-align: right;
}

/* Responsive Styles */

/* Tablets and Smaller Desktops */
@media (max-width: 768px) {
    .container {
        width: 95%;
        padding: 15px;
    }

    .input-group {
        flex-direction: column;
        width: 100%; /* Stack inputs vertically on smaller screens */
    }

    .input-group .form-select {
        width: 100%;
    }

    button {
        width: 100%;
    }

    h2, h4 {
        text-align: center;
        font-size: 1.6em; /* Slightly smaller font size on tablets */
    }

    fieldset {
        padding: 15px;
    }

    legend {
        font-size: 1.1em;
    }

    .number {
        height: 25px;
        width: 25px;
        font-size: 0.7em;
        margin-right: 8px;
        line-height: 25px;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    h2, h4 {
        font-size: 1.4em; /* Further reduction for very small screens */
    }

    button {
        padding: 16px 20px; /* Larger padding for easier tapping */
        font-size: 1.1em; /* Slightly larger font for readability */
    }

    .input-group {
        gap: 5px; /* Reduced gap to save space */
        width: 100%;
    }

    .form-control, .form-select {
        font-size: 1em; /* Ensure input text is readable */
    }

    /* Ensure labels are adequately sized */
    .form-label {
        font-size: 1em;
    }

    /* Adjust number badge size */
    .number {
        height: 25px;
        width: 25px;
        font-size: 0.7em;
        margin-right: 8px;
        line-height: 25px;
    }
}

/* Accessibility Enhancements */
.form-control:focus, .form-select:focus, button:focus {
    outline: 2px solid #80bdff;
    outline-offset: 2px;
}

/* Spinner alignment */
#currentLocation {
    display: flex;
    align-items: center;
}

#currentLocation .spinner-border {
    margin-right: 8px;
}

