/**
 * Unified Form Component System
 * Extracted from send-message.css and blade files
 * Standardized form styling for the entire admin system
 *
 * Usage:
 * - .form-group, .form-row (form layout)
 * - .enhanced-label (labels with icons)
 * - .enhanced-input, .enhanced-select, .enhanced-textarea (form inputs)
 * - .form-control (standard input class)
 * - .form-hint, .help-text (helper text)
 * - .form-actions (button container)
 *
 * Note: All !important rules have been removed for better CSS specificity
 */

/* ===== FORM LAYOUT ===== */
.form-group {
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 0;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 24px;
}

.form-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid rgba(38, 65, 67, 0.1);
}

/* ===== LABELS ===== */
label,
.form-label {
    display: block;
    font-weight: 600;
    color: #264143;
    margin-bottom: 8px;
    font-size: 14px;
}

.enhanced-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #264143;
    margin-bottom: 8px;
    font-size: 14px;
}

.enhanced-label i {
    color: #DE5499;
    width: 16px;
    text-align: center;
}

label i {
    color: #DE5499;
    width: 16px;
    text-align: center;
}

/* ===== INPUT FIELDS ===== */
.form-input,
.form-control,
.enhanced-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #264143;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    color: #264143;
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

.form-input:focus,
.form-control:focus,
.enhanced-input:focus {
    border-color: #DE5499;
    box-shadow: 0 0 0 3px rgba(222, 84, 153, 0.1);
    background: rgba(222, 84, 153, 0.02);
}

.form-input::placeholder,
.form-control::placeholder,
.enhanced-input::placeholder {
    color: rgba(38, 65, 67, 0.6);
}

/* ===== SELECT FIELDS ===== */
.form-select,
.enhanced-select,
select.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #264143;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    color: #264143;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

.form-select:focus,
.enhanced-select:focus,
select.form-control:focus {
    border-color: #DE5499;
    box-shadow: 0 0 0 3px rgba(222, 84, 153, 0.1);
}

select.form-control option,
.form-select option,
.enhanced-select option {
    background: #EDDCD9;
    color: #264143;
    padding: 8px;
}

.form-select:disabled {
    background: #f3f4f6;
    color: #6B7280;
    cursor: not-allowed;
}

/* ===== TEXTAREA FIELDS ===== */
.form-textarea,
.enhanced-textarea,
textarea.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #264143;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: white;
    color: #264143;
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 120px;
    outline: none;
    box-sizing: border-box;
}

.form-textarea:focus,
.enhanced-textarea:focus,
textarea.form-control:focus {
    border-color: #DE5499;
    box-shadow: 0 0 0 3px rgba(222, 84, 153, 0.1);
    background: rgba(222, 84, 153, 0.02);
}

/* ===== HELPER TEXT ===== */
.form-hint,
.help-text {
    display: block;
    font-size: 12px;
    color: rgba(38, 65, 67, 0.6);
    margin-top: 6px;
    font-style: italic;
    line-height: 1.4;
}

.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.success-message {
    color: #28a745;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* ===== FORM NOTES ===== */
.form-note {
    background: #E8F4FD;
    border: 2px solid #17a2b8;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #0c5460;
}

.form-note i {
    font-size: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* ===== SWITCH GROUP ===== */
.switch-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.switch-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    margin: 0;
}

/* Custom Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    margin: 0;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(38, 65, 67, 0.2);
    border: 2px solid #264143;
    border-radius: 28px;
    transition: all 0.3s ease;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    top: 2px;
    background: #264143;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.switch input:checked + .switch-slider {
    background: rgba(222, 84, 153, 0.2);
    border-color: #DE5499;
}

.switch input:checked + .switch-slider:before {
    transform: translateX(22px);
    background: #DE5499;
}

.switch-label {
    font-size: 14px;
    font-weight: 500;
    color: #264143;
    margin: 0;
    cursor: pointer;
}

/* ===== INPUT GROUPS ===== */
.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group .form-input,
.input-group .form-control {
    flex: 1;
}

/* ===== FILE UPLOAD ===== */
.file-upload-area {
    border: 2px dashed #264143;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.file-upload-area:hover {
    border-color: #DE5499;
    background: #f0f8ff;
    transform: scale(1.02);
}

.upload-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-icon {
    font-size: 48px;
    color: #9CA3AF;
    margin-bottom: 10px;
}

.upload-preview p {
    margin: 0;
    color: #6B7280;
    font-weight: 500;
}

/* ===== USERNAME SEARCH ===== */
.username-search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #EDDCD9;
    border: 2px solid #264143;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result-item {
    padding: 12px;
    border-bottom: 1px solid rgba(38, 65, 67, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.search-result-item:hover {
    background: rgba(222, 84, 153, 0.1);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-no-results {
    padding: 16px;
    text-align: center;
    color: rgba(38, 65, 67, 0.6);
    font-style: italic;
}

.result-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(222, 84, 153, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #DE5499;
    font-size: 14px;
    flex-shrink: 0;
}

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 600;
    color: #264143;
    font-size: 14px;
}

.result-username {
    font-size: 12px;
    color: #DE5499;
    font-weight: 500;
}

.result-email {
    font-size: 12px;
    color: rgba(38, 65, 67, 0.7);
}

/* ===== RECIPIENT PREVIEW ===== */
.recipient-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(222, 84, 153, 0.05);
    border: 2px solid rgba(222, 84, 153, 0.2);
    border-radius: 12px;
    margin-top: 12px;
}

.preview-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #DE5499;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #EDDCD9;
    font-size: 20px;
    flex-shrink: 0;
}

.preview-info {
    flex: 1;
}

.preview-name {
    font-weight: 700;
    color: #264143;
    font-size: 16px;
    margin-bottom: 4px;
}

.preview-username {
    color: #DE5499;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.preview-email {
    color: rgba(38, 65, 67, 0.7);
    font-size: 13px;
}

/* ===== FORM VALIDATION STATES ===== */
.form-input.is-invalid,
.form-control.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: #dc3545;
}

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

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

.form-input.is-valid:focus,
.form-control.is-valid:focus,
.form-select.is-valid:focus,
.form-textarea.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

/* ===== DISABLED STATES ===== */
.form-input:disabled,
.form-control:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: #f3f4f6;
    color: #6B7280;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        width: 100%;
    }

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

    .form-actions button,
    .form-actions .system-action-btn {
        width: 100%;
    }

    .input-group {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .switch-group {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .form-group {
        margin-bottom: 18px;
    }

    label,
    .form-label,
    .enhanced-label {
        font-size: 13px;
    }

    .form-input,
    .form-control,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 14px;
    }

    .form-hint,
    .help-text {
        font-size: 11px;
    }

    .file-upload-area {
        padding: 20px 15px;
    }

    .upload-icon {
        font-size: 36px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .form-input,
    .form-control,
    .form-select,
    .form-textarea,
    .switch-slider,
    .file-upload-area {
        transition: none;
    }

    .file-upload-area:hover {
        transform: none;
    }
}

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

    .switch-slider {
        border-width: 3px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .form-input,
    .form-control,
    .form-select,
    .form-textarea {
        background: #374151;
        color: #F9FAFB;
        border-color: #6B7280;
    }

    .form-input::placeholder,
    .form-control::placeholder {
        color: #9CA3AF;
    }

    label,
    .form-label,
    .enhanced-label,
    .switch-label {
        color: #F9FAFB;
    }

    .form-hint,
    .help-text {
        color: #9CA3AF;
    }

    .file-upload-area {
        background: #4B5563;
        border-color: #6B7280;
    }

    .file-upload-area:hover {
        background: #6B7280;
    }

    .upload-preview p {
        color: #D1D5DB;
    }

    .search-results {
        background: #1F2937;
        border-color: #374151;
    }

    .search-result-item:hover {
        background: rgba(222, 84, 153, 0.2);
    }

    .recipient-preview {
        background: rgba(222, 84, 153, 0.1);
        border-color: rgba(222, 84, 153, 0.3);
    }

    .preview-name,
    .result-name {
        color: #F9FAFB;
    }

    .preview-email,
    .result-email {
        color: #9CA3AF;
    }
}
