/* Importing Google Fonts - Lexend, Trebuchet MS, and Roboto Mono */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;700&family=Trebuchet+MS&family=Roboto+Mono&display=swap');

/* General body styles */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f2f5;
    text-align: center;
    padding: 20px;
    margin: 0;
}

/* Loading Spinner Styles */
.spinner-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #1877f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.spinner-text {
    margin-top: 20px;
    font-family: 'Lexend', sans-serif;
    color: #1877f2;
    font-size: 1.1em;
}
@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form disabled state */
.form-disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Container for the form */
#form-container {
    background-color: white;
    padding: 50px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 80%;
    max-width: 1200px;
    margin: auto;
    text-align: left;
}

/* Form layout styles */
form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Form groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Styles for form labels */
form label,
.modal .form-group label {
    font-family: 'Lexend', 'Trebuchet MS', sans-serif;
    margin-bottom: 5px;
    font-weight: normal;
    color: #333;
    font-size: 1em;
}

/* General form inputs, selects, buttons */
form input[type="text"],
form input[type="number"],
form select,
form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-bottom: 10px;
}

form input,
form select,
form button {
    border: 1px solid #dadce0;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-family: 'Lexend', 'Trebuchet MS', sans-serif;
    font-size: 1em;
}


/* Number inputs */
input[type="number"] {
    min-width: 100px;
}

/* Textarea styles */
form textarea {
    border: 1px solid #dadce0;
    border-radius: 5px;
    transition: border-color 0.3s ease;
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    min-height: 100px;
    letter-spacing: -0.2px;
    line-height: 1.4;
    resize: vertical;
}

/* Focus states */
form input:focus,
form select:focus,
form textarea:focus {
    border-color: #1877f2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

/* Buttons inside the form */
form button,
button {
    background-color: #1877f2;
    color: white;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease;
    text-align: center;
    font-weight: bold;
    padding: 14px 24px;
    margin-top: 10px;
}
form button:hover,
button:hover {
    background-color: #155db2;
}

/* RESET form link style */
.button {
    display: inline-block;
    padding: 14px 24px;
    background-color: #dc3545;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 10px;
    text-align: center;
    transition: background-color 0.3s ease;
}
.button:hover {
    background-color: #c82333;
}

/* Validation and required fields */
.error {
    color: #d93025;
    font-size: 0.9em;
    margin-top: 4px;
    display: none;
}
.required::after {
    content: " *";
    color: #d93025;
}
.optional {
    color: #666;
    font-size: 0.9em;
    margin-left: 4px;
}

/* Checkbox container */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
.checkbox-container input[type="checkbox"] {
    margin-right: 10px;
}

/* ==========================
   MODAL STYLING
   ========================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1001; /* Above spinner */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 60%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: 'Lexend', 'Trebuchet MS', sans-serif;

    /* Center contents and make uniform form grouping. */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.modal-content h2 {
    font-family: 'Lexend', 'Trebuchet MS', sans-serif;
    margin-bottom: 20px;
    font-size: 1.4em;
    text-align: center;
}

/* Form groups inside the modal so that the fields align center with uniform width */
.modal-content .form-group {
    width: 80%;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

/* Make all modal text/password inputs uniform width/height */
.modal-content .form-group input[type="text"],
.modal-content .form-group input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin: 0;
    font-size: 1em;
    border: 1px solid #dadce0;
    border-radius: 5px;
    font-family: 'Lexend', 'Trebuchet MS', sans-serif;
}

/* The close buttons (x in top right corner) */
.close,
.close-response {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close:hover, .close:focus,
.close-response:hover, .close-response:focus {
    color: black;
    text-decoration: none;
}

/* ==========================
   RESPONSE MODAL
   ========================== */
#response-modal .modal-content {
    /* same structure as above but can be custom if needed */
    width: 60%;
    max-width: 700px;
}
.response-content {
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
}
#response-data {
    font-family: 'Roboto Mono', monospace;
    font-size: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #form-container {
        width: 90%;
        padding: 30px;
    }
    form input,
    form select,
    form textarea {
        font-size: 16px; /* Prevents zoom on mobile */
    }

    .modal-content {
        width: 90%;
        margin: 20% auto;
    }
}
