/**
 * Contract Signing System Public CSS
 */
.contracts-wp-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.contracts-wp-form-container {
    flex: 1;
    min-width: 300px;
}

.contracts-wp-preview-container {
    flex: 1;
    min-width: 300px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    height: 800px; /* Fixed height instead of max-height */
    display: flex;
    flex-direction: column;
}

.contracts-wp-form {
    max-width: 800px;
    width: 100%; /* Ensure the form takes full width up to max-width */
}

.form-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Explicitly define two equal columns */
    grid-auto-flow: row; /* Ensures items flow row by row */
    gap: 15px 20px; /* Vertical gap 15px, horizontal gap 20px */
    margin-bottom: 20px;
    width: 100%; /* Ensure the grid takes full width */
    box-sizing: border-box; /* Include padding in width calculation */
    padding: 0;
    clear: both;
}

.form-group {
    margin-bottom: 15px;
    position: relative;
    width: 100%; /* Ensure each form group takes full width of its grid cell */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Special styling for form groups inside the grid */
.form-fields-grid > .form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
}

/* Ensure select teacher and signature sections span full width */
.full-width-field {
    grid-column: 1 / -1 !important; /* Use !important to ensure this rule takes precedence */
    width: 100%;
}

/* Improve spacing between form elements */
.form-fields-grid .form-group {
    padding: 0 5px;
    display: flex;
    flex-direction: column;
    /* Debug styling (remove for production) */
    /* border: 1px dashed rgba(0, 115, 170, 0.3); */
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    margin-top: 2px;
    min-height: 36px; /* Ensure consistent height */
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

/* Make textarea fields span both columns */
.form-group.textarea-field {
    grid-column: 1 / -1;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 2px rgba(0,115,170,0.8);
}

.signature-container {
    margin-top: 20px;
}

#signature-pad {
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    width: 100%;
    height: 200px;
    margin-bottom: 10px;
}

#clear-signature {
    padding: 5px 10px;
    background-color: #0073aa;
    color: #fff;
    border: 1px solid #005177;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#clear-signature:hover {
    background-color: #005177;
}

.form-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#submit-contract {
    padding: 10px 20px;
    background-color: #ff7706;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#submit-contract:hover {
    background-color: #e06600;
}

/* Picture Agreement Section */
.picture-agreement-section {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 15px;
    margin: 20px 0;
    position: relative;
}

.picture-agreement-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
}

.picture-agreement-label input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
    width: auto;
}

.picture-agreement-text {
    flex: 1;
}

.picture-terms-link {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
    margin-left: 5px;
}

.picture-terms-link:hover {
    text-decoration: underline;
    color: #005a87;
}

/* Optional indicator */
.picture-agreement-section::before {
    content: "Optional:";
    font-size: 12px;
    font-weight: bold;
    color: #666;
    display: block;
    margin-bottom: 8px;
}
#form-messages {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    margin-bottom: 20px;
}

.error-message strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.error-message pre {
    background-color: #fff;
    padding: 10px;
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    margin-top: 10px;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.contract-preview {
    line-height: 1.6;
    overflow-y: auto;
    flex: 1; /* Take up available space in the flex container */
    padding-right: 10px;
    border: 1px solid #e0e0e0;
    background-color: #fff;
    padding: 15px;
    margin-top: 10px;
}

/* Responsive adjustments */
/* Tablet layout */
@media (max-width: 992px) and (min-width: 769px) {
    .form-fields-grid {
        gap: 12px;
    }
}

/* Mobile layout */
@media (max-width: 768px) {
    .contracts-wp-container {
        flex-direction: column;
    }
    
    .form-fields-grid {
        grid-template-columns: 1fr; /* Switch to single column on mobile */
        gap: 10px;
    }
    
    /* Ensure all form groups take full width on mobile */
    .form-group, 
    .form-group.textarea-field,
    .full-width-field {
        grid-column: 1;
        width: 100%;
    }
}
