/**
 * Refactored Stylesheet for PQRDS Form
 * Version 2.2
 * Uses modern CSS (Flexbox) and adds styles for dynamic states.
 */

/* =====================================================================
   1. Global & Base Styles
   ===================================================================== */

html {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px; /* A slightly larger base size for readability */
    color: #333;
    background-color: #ffffff;
}

a {
    color: #3399FF;
    text-decoration: none;
}

a:visited {
    color: #703DBC;
}

a:hover, a:active, a:focus {
    color: #386F26;
    text-decoration: underline;
}

img {
    border: none;
    outline: none;
    max-width: 100%;
    height: auto;
}

h1, h3 {
    font-family: Calibri, serif;
    color: #006666;
    line-height: 1.2;
    margin: 0 0 12px 0;
}

h1 { font-size: 1.6em; }
h3 { font-size: 1.2em; }

/* =====================================================================
   2. Main Form Container & Layout
   ===================================================================== */

.formulario {
    max-width: 850px;
    margin: 15px auto;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #F2F2F2;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 90vh;
    overflow-y: auto;
}

fieldset {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: #fff;
}

legend {
    font-weight: bold;
    color: #333;
    padding: 0 10px;
}

.form-header {
    text-align: center;
}

.form-actions-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 5px;
    margin: 15px 0;
    border-top: 2px double #006666;
    border-bottom: 2px double #006666;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -12.5px;
}

/* =====================================================================
   3. Form Elements (Inputs, Labels, Buttons)
   ===================================================================== */

.form-group, .form-row {
    margin-bottom: 10px;
}

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

.form-grid > .form-group {
    width: 50%; 
    padding: 0 12.5px;
    margin-bottom: 12px;
}

.form-group label {
    margin-bottom: 4px;
    font-weight: bold;
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    color: #333;
    font-size: 1em;
    transition: box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

input[type="text"]:hover,
input[type="email"]:hover,
select:hover,
textarea:hover {
    border-color: #999;
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #0885c7;
    box-shadow: 0 0 8px rgba(8, 133, 199, 0.4);
}

/* NEW: Style for locked (readonly) fields */
.user-data-field[readonly] {
    background-color: #f2f2f2;
    cursor: not-allowed;
    color: #666;
}

.oblig label:before {
    color: red;
    content: "* ";
}

/* =====================================================================
   4. Specific Sections (Banner, Message, CAPTCHA, Footer)
   ===================================================================== */

/* NEW: Styles for the user status message box */
#userStatus {
    margin: 10px 0 15px 0;
    padding: 12px;
    border-radius: 4px;
    font-weight: bold;
    display: none; /* Hidden by default, shown by JS */
    border: 1px solid transparent;
}
.status-info { background-color: #e7f3fe; color: #31708f; border-color: #bce8f1; }
.status-success { background-color: #dff0d8; color: #3c763d; border-color: #d6e9c6; }
.status-warning { background-color: #fcf8e3; color: #8a6d3b; border-color: #faebcc; }
.status-error { background-color: #f2dede; color: #a94442; border-color: #ebccd1; }


.centered-banner {
    text-align: center;
    margin: 20px 0;
}

.full-width {
    width: 100%;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
}

.captcha-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 15px 0;
    margin-top: 10px;
}

.captcha-image img {
    border: 1px solid #ccc;
    width: 150px;
    height: 45px;
    display: block;
}

.captcha-input-area input[type="text"] {
    font-size: 1.4em;
    text-align: center;
    letter-spacing: 2px;
}

.form-footer {
    text-align: center;
    padding: 12px;
    border-bottom: 2px double #006666;
    margin: 15px 0;
    font-size: 0.9em;
    color: #555;
    line-height: 1.5;
}

.form-footer input[type="submit"],
.form-footer input[type="reset"] {
    padding: 8px 18px;
    font-size: 1.0em;
    cursor: pointer;
    border: 1px solid #005555;
    background-color: #006666;
    color: white;
    border-radius: 5px;
    margin: 10px;
}

.form-footer input[type="reset"] {
    background-color: #eee;
    color: #333;
    border-color: #bbb;
}

/* =====================================================================
   5. Responsive Design for Mobile Devices
   ===================================================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .formulario {
        margin: 10px;
        padding: 15px;
    }

    .form-grid > .form-group {
        width: 100%;
    }

    .form-actions-bar {
        flex-direction: column;
        gap: 15px;
    }
}