/* Modern form styling for CKAN collaboration extension - Portal Version */

/* Form container integration with portal */
.containerform {
    max-width: none;
    margin: 0;
    padding: 40px;
    background: white;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

/* Header styling */
.containerform h1 {
    color: #0077d4;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
}

/* Form intro section */
.form-intro {
    background: #e3f2fd;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 4px solid #0077d4;
}

.form-intro p {
    color: #1565c0;
    line-height: 1.6;
    margin-bottom: 15px;
    text-align: justify;
    font-size: 15px;
}

.form-intro p:last-child {
    margin-bottom: 0;
}

/* Form sections */
.form-section {
    margin: 30px 0;
    padding: 25px;
    background: #f8fafe;
    border-radius: 8px;
    border-left: 4px solid #0077d4;
}

.form-section h3 {
    color: #0077d4;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.form-section h3::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    background: #0077d4;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Labels */
label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

label.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
}

/* Form inputs - BASE STYLES - Scoped to avoid conflicts */
.containerform input[type="text"],
.containerform input[type="email"],
.containerform input[type="password"],
.containerform input[type="number"],
.containerform select,
.containerform textarea {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background: #ffffff;
    font-family: inherit;
    height: 48px;
}

/* Textarea specific height */
.containerform textarea {
    height: auto;
    min-height: 100px;
    resize: vertical;
}

/* Select specific styling */
.containerform select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.containerform input[type="text"]:focus,
.containerform input[type="email"]:focus,
.containerform input[type="password"]:focus,
.containerform input[type="number"]:focus,
.containerform select:focus,
.containerform textarea:focus {
    outline: none;
    border-color: #0077d4;
    box-shadow: 0 0 0 3px rgba(0, 119, 212, 0.1);
    background: #fafbfc;
}

/* Small helper text - FIXED POSITIONING */
small {
    display: block;
    margin-bottom: 10px;
    margin-top: -15px;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
    font-style: italic;
}

/* Form rows - CRITICAL FIX FOR ALIGNMENT */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 25px;
    align-items: start;
}

/* CRITICAL: Each column in form-row should have consistent structure */
.form-row > div {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Ensure labels in grid rows have consistent spacing */
.form-row label {
    margin-bottom: 8px;
    order: 1;
}

/* Small text in grid rows */
.form-row small {
    order: 2;
    margin-top: -5px;
    margin-bottom: 8px;
}

/* Inputs in grid rows */
.containerform .form-row input,
.containerform .form-row select {
    order: 3;
    height: 48px;
    margin-bottom: 10px;
}

/* Error messages and status in grid rows */
.form-row .field-error,
.form-row .password-strength,
.form-row #match-message {
    order: 4;
    margin-top: -5px;
    margin-bottom: 0;
    min-height: 20px;
    font-size: 12px;
    padding-left: 5px;
}

/* Password match message specific styling */
#match-message {
    font-weight: 500;
    font-size: 12px;
    min-height: 20px;
    margin-bottom: 0;
}

/* Success and error message styles */
.success-message {
    color: #4caf50;
    font-weight: 500;
}

.error-message {
    color: #d32f2f;
    font-weight: 500;
}

/* Gender other field styling */
#genderOtherText {
    margin-top: 15px;
    border-color: #ffb74d;
    display: none;
}

/* Organization fields */
#newOrganizationField,
#newGroupField {
    margin-top: 25px;
    padding: 25px;
    background: #fff3e0;
    border-radius: 8px;
    border: 1px solid #ffb74d;
    display: none;
}

#newOrganizationField label,
#newGroupField label {
    color: #e65100;
    font-weight: 600;
}

/* Organization select styling */
#organizationType {
    font-weight: 500;
}

/* Checkbox container */
.checkbox-container {
    display: flex;
    align-items: flex-start;
    margin: 30px 0;
    padding: 25px;
    background: #e8f5e8;
    border-radius: 8px;
    border-left: 4px solid #4caf50;
}

.checkbox-container input[type="checkbox"] {
    width: auto;
    height: auto;
    margin-right: 15px;
    margin-top: 3px;
    transform: scale(1.3);
    accent-color: #4caf50;
}

.checkbox-container label {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #2e7d32;
}

/* reCAPTCHA container styling */
.g-recaptcha {
    margin: 25px 0;
    display: flex;
    justify-content: center;
}

/* Submit button */
input[type="submit"] {
    background: linear-gradient(135deg, #0077d4 0%, #0065b4 100%);
    color: white;
    padding: 16px 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 119, 212, 0.3);
    margin-top: 25px;
    height: auto;
    min-height: 56px;
}

input[type="submit"]:hover {
    background: linear-gradient(135deg, #0065b4 0%, #004c8c 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 119, 212, 0.4);
}

input[type="submit"]:active {
    transform: translateY(0);
}

/* Loading state for submit button */
input[type="submit"].loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

input[type="submit"].loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Disabled input styling */
input:disabled,
select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #ddd;
}

/* Age input specific styling */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Field error styling */
.field-error {
    color: #d32f2f;
    font-size: 12px;
    display: none;
    padding-left: 5px;
}

.field-error.show {
    display: block;
}

.password-strength {
    font-size: 12px;
    padding-left: 5px;
}

.password-strength.weak {
    color: #d32f2f;
}

.password-strength.medium {
    color: #ff9800;
}

.password-strength.strong {
    color: #4caf50;
}

/* Placeholder styling */
::placeholder {
    color: #999;
    opacity: 1;
}

:-ms-input-placeholder {
    color: #999;
}

::-ms-input-placeholder {
    color: #999;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    /* Reset order for mobile */
    .form-row > div {
        display: block;
    }
    
    .form-row label,
    .form-row small,
    .form-row input,
    .form-row select,
    .form-row .field-error,
    .form-row .password-strength,
    .form-row #match-message {
        order: unset;
    }
    
    .containerform {
        padding: 20px;
    }
    
    .form-section {
        padding: 20px;
        margin: 20px 0;
    }
    
    .checkbox-container {
        padding: 20px;
    }
    
    input[type="submit"] {
        padding: 14px 20px;
        min-height: 50px;
    }
}

/* Accessibility improvements */
input:invalid {
    border-color: #d32f2f;
}

input:valid {
    border-color: #e1e5e9;
}

/* Focus styles for better accessibility */
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-section {
        border-left-width: 6px;
    }
    
    input, select, textarea {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ADDITIONAL FIXES FOR SPECIFIC ELEMENTS */

/* Ensure consistent spacing for all form elements */
.form-section > *:last-child {
    margin-bottom: 0;
}

/* Better spacing for single column elements */
.form-section > input:not(.form-row input),
.form-section > select:not(.form-row select),
.form-section > textarea:not(.form-row textarea) {
    margin-bottom: 25px;
}

/* Improve label spacing for non-grid elements */
.form-section > label:not(.form-row label) {
    margin-top: 5px;
}

/* Better visual hierarchy for section-level small text */
.form-section > small:not(.form-row small) {
    font-size: 13px;
    margin-top: -5px;
    margin-bottom: 20px;
    display: block;
}

/* Organization dropdown improvements */
select[name="organization_name"],
select[name="organizationType"],
select[name="user_role"] {
    font-weight: 500;
}

/* Gender select improvements */
select[name="gender"] {
    margin-bottom: 15px;
}