/* Unified form controls for registration pages */

.register-page {
    --rf-primary: #4e73df;
    --rf-primary-dark: #2e59d9;
    --rf-border: #d1d3e2;
    --rf-border-hover: #b7bfe8;
    --rf-bg: #ffffff;
    --rf-bg-muted: #f8f9fc;
    --rf-text: #2c3e50;
    --rf-muted: #6c757d;
    --rf-radius: 0.5rem;
    --rf-height: 2.75rem;
    --rf-shadow-focus: 0 0 0 0.2rem rgba(78, 115, 223, 0.18);
    --rf-transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.register-form-fields {
    font-family: 'Noto Sans Thai', 'Mitr', sans-serif;
}

.register-form-fields .form-group {
    margin-bottom: 1.25rem;
}

.register-form-fields .col-form-label {
    color: var(--rf-text);
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.5;
    padding-top: calc(0.5rem + 1px);
    padding-bottom: 0.5rem;
}

@media (min-width: 992px) {
    .register-form-fields .col-form-label {
        text-align: right;
    }
}

.register-form-fields .form-text {
    font-size: 0.8125rem;
    color: var(--rf-muted);
    margin-top: 0.35rem;
}

/* Base control — text, email, tel, password, number */
.register-form-fields .form-control {
    display: block;
    width: 100%;
    min-height: var(--rf-height);
    height: var(--rf-height);
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--rf-text);
    background-color: var(--rf-bg);
    border: 1px solid var(--rf-border);
    border-radius: var(--rf-radius);
    box-shadow: none;
    transition: var(--rf-transition);
}

.register-form-fields textarea.form-control {
    min-height: 6.5rem;
    height: auto;
    resize: vertical;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
}

.register-form-fields select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.5rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236c757d' d='M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 12px 8px;
}

.register-form-fields .form-control:hover:not(:disabled):not([readonly]) {
    border-color: var(--rf-border-hover);
}

.register-form-fields .form-control:focus {
    color: var(--rf-text);
    background-color: var(--rf-bg);
    border-color: var(--rf-primary);
    outline: 0;
    box-shadow: var(--rf-shadow-focus);
}

.register-form-fields .form-control::placeholder {
    color: #adb5bd;
    opacity: 1;
}

.register-form-fields .form-control:disabled,
.register-form-fields .form-control[readonly] {
    background-color: var(--rf-bg-muted);
    border-color: #e3e6f0;
    color: #5a5c69;
    cursor: default;
    opacity: 1;
}

.register-form-fields .form-control.is-invalid,
.register-form-fields .was-validated .form-control:invalid {
    border-color: #e74a3b;
    padding-right: 0.875rem;
    background-image: none;
}

.register-form-fields .form-control.is-invalid:focus,
.register-form-fields .was-validated .form-control:invalid:focus {
    border-color: #e74a3b;
    box-shadow: 0 0 0 0.2rem rgba(231, 74, 59, 0.18);
}

.register-form-fields select.form-control.is-invalid,
.register-form-fields .was-validated select.form-control:invalid {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e74a3b' d='M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 12px 8px;
}

.register-form-fields .form-control.is-valid,
.register-form-fields .was-validated .form-control:valid {
    border-color: #1cc88a;
    padding-right: 0.875rem;
    background-image: none;
}

.register-form-fields .invalid-feedback {
    font-size: 0.8125rem;
    margin-top: 0.35rem;
}

.register-form-fields .form-row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.register-form-fields .form-row .form-control {
    width: 100%;
}

.register-form-fields .alert-info {
    border-radius: var(--rf-radius);
    border: 1px solid #c7ebff;
    font-size: 0.875rem;
}

.register-form-fields .form-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--rf-primary-dark);
    border-bottom: 2px solid #e3e6f0;
    padding-bottom: 0.5rem;
    margin: 1.5rem 0 1rem;
}

.register-form-fields .form-section-title:first-child {
    margin-top: 0;
}

.register-form-fields .register-form-actions {
    border-top: 1px solid #e3e6f0;
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

/* Select2 — school search, match form controls */
.register-form-fields .select2-container {
    width: 100% !important;
}

.register-form-fields .select2-container--default .select2-selection--single {
    min-height: var(--rf-height);
    height: var(--rf-height);
    border: 1px solid var(--rf-border);
    border-radius: var(--rf-radius);
    background-color: var(--rf-bg);
    transition: var(--rf-transition);
}

.register-form-fields .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--rf-height) - 2px);
    padding-left: 0.875rem;
    padding-right: 2rem;
    color: var(--rf-text);
    font-size: 0.9375rem;
}

.register-form-fields .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6c757d;
}

.register-form-fields .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(var(--rf-height) - 2px);
    right: 0.5rem;
}

.register-form-fields .select2-container--default.select2-container--focus .select2-selection--single,
.register-form-fields .select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--rf-border-hover);
    box-shadow: var(--rf-shadow-focus);
}

.select2-container--default .select2-results > .select2-results__options {
    max-height: 280px;
}

.select2-container--default .select2-results__option {
    font-family: 'Noto Sans Thai', 'Mitr', sans-serif;
    font-size: 0.9375rem;
    padding: 0.55rem 0.875rem;
    color: var(--rf-text);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #eef2ff;
    color: var(--rf-primary-dark);
}

.select2-dropdown {
    border: 1px solid var(--rf-border);
    border-radius: var(--rf-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    z-index: 1050;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid var(--rf-border);
    border-radius: var(--rf-radius);
    padding: 0.5rem 0.875rem;
    font-family: 'Noto Sans Thai', 'Mitr', sans-serif;
    font-size: 0.9375rem;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--rf-border-hover);
    box-shadow: var(--rf-shadow-focus);
    outline: none;
}

.register-form-fields .school-contact-notice {
    background-color: #fff8e1;
    border: 1px solid #f6c23e;
    border-left-width: 4px;
    border-radius: var(--rf-radius);
    color: #5a5c69;
    font-size: 0.875rem;
    line-height: 1.6;
}

.register-form-fields .school-search-status {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.register-form-fields .studcid-status {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    line-height: 1.5;
}

.register-form-fields .studcid-status.is-success {
    color: #1cc88a;
}

.register-form-fields .studcid-status.is-error {
    color: #e74a3b;
}

.register-form-fields .studcid-status.is-checking {
    color: #4e73df;
}

@media (max-width: 991.98px) {
    .register-form-fields .col-form-label {
        text-align: left;
        padding-bottom: 0.25rem;
    }

    .register-form-fields .register-form-actions .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Register flow pages (register.php, profile.php, …) */
body.register-flow-body {
    color: #2c3e50;
    background-color: #f4f6f9;
}

.register-card .card-header {
    border-bottom: 0;
}

.register-card .card-body {
    padding: 2rem;
}

.register-intro {
    line-height: 1.75;
    color: #495057;
    margin-bottom: 1.25rem;
}

.register-notice {
    background-color: #f8f9fc;
    border-left: 4px solid #4e73df;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 0 6px 6px 0;
}

.register-notice .notice-title {
    font-weight: 600;
    color: #2e59d9;
    margin-bottom: 0.35rem;
}

.register-notice p {
    margin-bottom: 0;
    line-height: 1.65;
    color: #495057;
}

.consent-panel {
    background-color: #fff;
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.consent-panel:last-of-type {
    margin-bottom: 0;
}

.consent-panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #858796;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
}

.register-actions {
    border-top: 1px solid #e3e6f0;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.register-actions .btn {
    min-width: 200px;
}

/* Review / confirmation page */

.register-error-summary {
    border-left: 4px solid #e74a3b;
    background-color: #fdf2f2;
    border-radius: 0 var(--rf-radius) var(--rf-radius) 0;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.register-error-summary ul {
    margin-bottom: 0;
    padding-left: 1.25rem;
}

.review-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.review-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    border-radius: var(--rf-radius);
    border: 1px solid #e3e6f0;
    border-left-width: 4px;
    background-color: #fff;
}

.review-row.is-ok {
    background-color: #f0faf4;
    border-color: #c3e6cb;
    border-left-color: #1cc88a;
}

.review-row.is-error {
    background-color: #fdf2f2;
    border-color: #f5c6cb;
    border-left-color: #e74a3b;
}

.review-row.is-locked {
    background-color: #fffbf0;
    border-color: #f6e0a8;
    border-left-color: #f6c23e;
}

.review-row.is-locked .review-label {
    color: #856404;
}

.review-value .review-icon-lock {
    color: #f6c23e;
}

/* Profile view (profile.php) */

.profile-view-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-view-avatar {
    flex-shrink: 0;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.profile-view-subtitle {
    display: block;
    margin-top: 0.15rem;
    opacity: 0.9;
    line-height: 1.5;
}

.profile-panel {
    display: flex;
    flex-direction: column;
    background: var(--rf-bg);
    border: 1px solid #e3e6f0;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(78, 115, 223, 0.06);
    overflow: hidden;
}

.profile-panel-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(180deg, #f8f9fc 0%, #fff 100%);
    border-bottom: 1px solid #eef0f5;
}

.profile-panel-icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: rgba(78, 115, 223, 0.12);
    color: var(--rf-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.profile-panel-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--rf-text);
    letter-spacing: 0.01em;
}

.profile-fields {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    flex: 1;
}

.profile-field {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: var(--rf-bg-muted);
    border: 1px solid #eef0f5;
    border-radius: var(--rf-radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-field:hover {
    border-color: #dce3f5;
    box-shadow: 0 2px 8px rgba(78, 115, 223, 0.07);
}

.profile-field-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    margin-top: 0.1rem;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e3e6f0;
    color: var(--rf-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.profile-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858796;
    margin-bottom: 0.2rem;
}

.profile-field-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--rf-text);
    line-height: 1.55;
    word-break: break-word;
}

.profile-field-hint {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
}

.profile-field-hint--muted {
    background: #eef0f5;
    color: #6c757d;
}

.profile-field-hint--locked {
    background: #fff8e6;
    color: #856404;
    border: 1px solid #f6e0a8;
}

.profile-field-hint--warn {
    background: #fff5f5;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.profile-panels-row .profile-panel {
    margin-bottom: 0;
}

.profile-panels-row + .register-actions {
    margin-top: 1.5rem;
}

/* Profile edit form (profile_form.php) */

.profile-form-fields.profile-fields {
    padding: 1rem 1.25rem 1.25rem;
}

.profile-form-group {
    padding: 0.875rem 1rem;
    background: var(--rf-bg-muted);
    border: 1px solid #eef0f5;
    border-radius: var(--rf-radius);
}

.profile-form-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858796;
    margin-bottom: 0.45rem;
    display: block;
}

.profile-form-fields .form-control[readonly] {
    background-color: #e9ecef;
    color: #5a5c69;
    cursor: not-allowed;
}

.profile-form-fields .profile-form-group .invalid-feedback {
    font-size: 0.8125rem;
}

.profile-form-fields .profile-form-group .form-text {
    margin-top: 0.35rem;
}

.profile-form-fields .profile-form-group .profile-field-hint {
    margin-top: 0.4rem;
}

.profile-form-name-row > [class*="col-"] .invalid-feedback {
    display: block;
}

.register-notice a {
    color: #2e59d9;
    font-weight: 600;
}

.register-notice a:hover {
    color: #1a3a8a;
}

@media (max-width: 991.98px) {
    .profile-view-card .card-body {
        padding: 1.25rem;
    }

    .profile-fields {
        padding: 0.875rem 1rem 1rem;
    }
}

.review-label {
    flex: 0 0 100%;
    font-weight: 600;
    color: #5a5c69;
    font-size: 0.875rem;
    margin-bottom: 0.2rem;
}

.review-row.is-ok .review-label {
    color: #1a7a43;
}

.review-row.is-error .review-label {
    color: #c0392b;
}

.review-value {
    flex: 0 0 100%;
    color: var(--rf-text);
    font-size: 0.9375rem;
    line-height: 1.6;
    word-break: break-word;
}

.review-row.is-ok .review-value {
    color: #155724;
}

.review-row.is-error .review-value {
    color: #c0392b;
    font-weight: 600;
}

.review-value .review-icon-ok {
    color: #1cc88a;
}

.review-value .review-icon-error {
    color: #e74a3b;
}

@media (min-width: 992px) {
    .review-label {
        flex: 0 0 35%;
        max-width: 35%;
        margin-bottom: 0;
        padding-right: 1rem;
        text-align: right;
    }

    .review-value {
        flex: 0 0 65%;
        max-width: 65%;
    }
}

.register-captcha-note {
    font-size: 0.875rem;
    color: var(--rf-muted);
    margin-bottom: 0.75rem;
}

.register-form-actions {
    border-top: 1px solid #e3e6f0;
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

@media (max-width: 991.98px) {
    .register-form-actions .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}
