/* Form UI/UX Enhancements for All Portals */

/* Form Field Enhancements */
.form-label {
    font-weight: 500;
    color: var(--text, #1f2933);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-label .text-danger {
    margin-left: 0.125rem;
}

.form-control,
.form-select {
    border: 1.5px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary, #5b7cfd);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 91, 124, 253), 0.1);
    outline: none;
    background-color: #fff;
}

.form-control:hover:not(:disabled):not(:read-only),
.form-select:hover:not(:disabled) {
    border-color: #cbd5e1;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: #f8f9fa;
    opacity: 0.7;
    cursor: not-allowed;
}

.form-control-lg,
.form-select-lg {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 10px;
}

.form-control-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 6px;
}

/* Helper Text Styling */
small.text-muted,
.help-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--muted, #6b7280);
    line-height: 1.4;
}

.help-text {
    margin-top: 0.5rem;
    color: var(--muted, #6b7280);
}

/* Form Groups with Better Spacing */
.form-group,
.mb-3 {
    margin-bottom: 1.25rem !important;
}

.form-group:last-child,
.mb-3:last-child {
    margin-bottom: 0 !important;
}

/* Input Groups */
.input-group {
    position: relative;
}

.input-group-text {
    background-color: #f8f9fa;
    border: 1.5px solid var(--border, #e5e7eb);
    border-right: none;
    color: var(--muted, #6b7280);
    transition: all 0.2s ease;
}

.input-group:focus-within .input-group-text {
    border-color: var(--primary, #5b7cfd);
    background-color: #fff;
    color: var(--primary, #5b7cfd);
}

.input-group .form-control:first-child {
    border-left: none;
}

.input-group:focus-within .form-control {
    border-left: 1.5px solid var(--primary, #5b7cfd);
}

/* Form Sections/Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.card-header {
    border-bottom: 1px solid var(--border, #e5e7eb);
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}

.card-body {
    padding: 1.25rem 1.5rem;
}

.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-info,
.card-header.bg-secondary,
.card-header.bg-dark {
    border-bottom: none;
}

/* Form Row Spacing */
.row.g-3 > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.row.mb-3 {
    margin-bottom: 1.25rem !important;
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary, #5b7cfd), var(--primary-dark, #4554d6));
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark, #4554d6), var(--primary, #5b7cfd));
    color: #fff;
}

.btn-secondary {
    background-color: #6b7280;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #4b5563;
    color: #fff;
}

.btn-outline-primary {
    border: 1.5px solid var(--primary, #5b7cfd);
    color: var(--primary, #5b7cfd);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary, #5b7cfd);
    color: #fff;
}

.btn-outline-secondary {
    border: 1.5px solid #6b7280;
    color: #6b7280;
    background: transparent;
}

.btn-outline-secondary:hover {
    background: #6b7280;
    color: #fff;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 10px;
}

/* Form Check */
.form-check {
    padding-left: 1.75rem;
    margin-bottom: 0.75rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
    margin-left: -1.75rem;
    border: 1.5px solid var(--border, #e5e7eb);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.form-check-input:checked {
    background-color: var(--primary, #5b7cfd);
    border-color: var(--primary, #5b7cfd);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 91, 124, 253), 0.1);
}

.form-check-label {
    font-size: 0.9375rem;
    color: var(--text, #1f2933);
    cursor: pointer;
}

/* Form Switch */
.form-switch .form-check-input {
    width: 2rem;
    height: 1.125rem;
    border-radius: 0.5625rem;
    background-color: #cbd5e1;
    border: none;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary, #5b7cfd);
}

/* Textarea */
textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

textarea.form-control:focus {
    min-height: 120px;
}

/* File Input */
.form-control[type="file"] {
    padding: 0.5rem;
    cursor: pointer;
}

.form-control[type="file"]:hover {
    background-color: #f8f9fa;
}

.form-control[type="file"]::-webkit-file-upload-button {
    padding: 0.5rem 1rem;
    margin-right: 0.75rem;
    background-color: var(--primary, #5b7cfd);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-control[type="file"]::-webkit-file-upload-button:hover {
    background-color: var(--primary-dark, #4554d6);
}

/* Modal Forms */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border, #e5e7eb);
    padding: 1.5rem;
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text, #1f2933);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border, #e5e7eb);
    padding: 1.25rem 1.5rem;
    border-radius: 0 0 16px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Required Field Indicator */
.form-label .text-danger {
    font-weight: 600;
    font-size: 1rem;
}

/* Form Validation States */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: #28a745;
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.invalid-feedback,
.valid-feedback {
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    display: block;
}

/* Form Sections with Icons */
.card-header h6 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 600;
    font-size: 0.9375rem;
}

/* Better Spacing for Form Rows */
.row.g-3 {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row.g-3 > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin-bottom: 1rem;
}

/* Responsive Form Adjustments */
@media (max-width: 768px) {
    .form-control-lg,
    .form-select-lg {
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Loading States */
.btn .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Placeholder Styling */
.form-control::placeholder,
.form-select option:first-child {
    color: #9ca3af;
    opacity: 1;
}

/* Select Dropdown Styling */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-select:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235b7cfd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* Table Forms */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted, #6b7280);
    border-bottom: 2px solid var(--border, #e5e7eb);
    padding: 0.75rem 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Form Card Enhancements */
.card-modern {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border, #e5e7eb);
}

/* Input Group Button */
.input-group .btn {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

.input-group .form-control:first-child {
    border-radius: 8px 0 0 8px;
}

/* Better Visual Hierarchy */
.form-label.fw-semibold {
    font-weight: 600;
    color: var(--text, #1f2933);
}

/* Focus Visible for Accessibility */
.form-control:focus-visible,
.form-select:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary, #5b7cfd);
    outline-offset: 2px;
}

